本文整理汇总了C#中Bus.CreateStream方法的典型用法代码示例。如果您正苦于以下问题:C# Bus.CreateStream方法的具体用法?C# Bus.CreateStream怎么用?C# Bus.CreateStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bus
的用法示例。
在下文中一共展示了Bus.CreateStream方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateStreamShouldCreateAMessageBusWriteStream
public void CreateStreamShouldCreateAMessageBusWriteStream()
{
// Arrange
var mockConfiguration = new Mock<IConfiguration>();
var mockProducer = new Mock<IProducer>();
var mockContainer = new Mock<IBusContainer>();
var mockRequestConfiguration = new Mock<IRequestConfiguration>();
var mockStream = new Mock<IMessageBusWriteStream>();
mockConfiguration.Setup(x => x.GetContainer()).Returns(mockContainer.Object);
mockConfiguration.Setup(x => x.GetProducer()).Returns(mockProducer.Object);
mockConfiguration.SetupGet(x => x.TransportSettings).Returns(new TransportSettings ());
mockConfiguration.Setup(x => x.GetRequestConfiguration(It.IsAny<Guid>())).Returns(mockRequestConfiguration.Object);
mockConfiguration.Setup(x=> x.GetMessageBusWriteStream(It.IsAny<IProducer>(), "TestEndpoint", It.IsAny<string>(), It.IsAny<IConfiguration>())).Returns(mockStream.Object);
var task = new Task(() => { });
mockRequestConfiguration.Setup(x => x.SetHandler(It.IsAny<Action<object>>())).Returns(task);
var message = new FakeMessage1(Guid.NewGuid())
{
Username = "Tim Watson"
};
mockProducer.Setup(x => x.Send(It.IsAny<string>(), It.IsAny<Type>(), It.IsAny<byte[]>(), It.IsAny<Dictionary<string, string>>())).Callback(task.Start);
// Act
var bus = new Bus(mockConfiguration.Object);
// Act
var stream = bus.CreateStream("TestEndpoint", message);
// Assert
Assert.NotNull(stream);
Assert.Equal(mockStream.Object, stream);
}
示例2: CreateStreamShouldSendARequestMessageToTheSpecifiedEndpoint
public void CreateStreamShouldSendARequestMessageToTheSpecifiedEndpoint()
{
// Arrange
var mockConfiguration = new Mock<IConfiguration>();
var mockProducer = new Mock<IProducer>();
var mockContainer = new Mock<IBusContainer>();
var mockRequestConfiguration = new Mock<IRequestConfiguration>();
mockConfiguration.Setup(x => x.GetContainer()).Returns(mockContainer.Object);
mockConfiguration.Setup(x => x.GetProducer()).Returns(mockProducer.Object);
mockConfiguration.SetupGet(x => x.TransportSettings).Returns(new TransportSettings());
mockConfiguration.Setup(x => x.GetRequestConfiguration(It.IsAny<Guid>())).Returns(mockRequestConfiguration.Object);
var task = new Task(() => { });
mockRequestConfiguration.Setup(x => x.SetHandler(It.IsAny<Action<object>>())).Returns(task);
var message = new FakeMessage1(Guid.NewGuid())
{
Username = "Tim Watson"
};
mockProducer.Setup(x => x.Send(It.IsAny<string>(), It.IsAny<Type>(), It.IsAny<byte[]>(), It.IsAny<Dictionary<string, string>>())).Callback(task.Start);
// Act
var bus = new Bus(mockConfiguration.Object);
// Act
bus.CreateStream("TestEndpoint", message);
// Assert
mockProducer.Verify(x => x.Send("TestEndpoint",It.IsAny<Type>(), It.IsAny<byte[]>(), It.Is<Dictionary<string, string>>(y => y["MessageType"] == "ByteStream" && y.ContainsKey("Start"))));
}