public void WhenGivenDifferentQueue_ShouldReturnDifferentSenderInstance() { // arrange var configuration = new Mock <IServiceBusConfiguration>(); configuration.SetupGet(_ => _.DefaultConnectionString).Returns(DummyServiceBusConnectionString); configuration.SetupGet(_ => _.OtherConnectionStrings).Returns(new System.Collections.Generic.Dictionary <string, string>()); var sut = new AzureServiceBusEndpointFactory(configuration.Object, Enumerable.Empty <IMessageEnricher>()); // act var sender = sut.Create("MyQueue"); var sender2 = sut.Create("MyQueue2"); // assert sender.Should().NotBeSameAs(sender2); }
public void WhenGivenExistingPayload_ShouldReturnSameSenderInstance() { // arrange var configuration = new Mock <IServiceBusConfiguration>(); configuration.SetupGet(_ => _.DefaultConnectionString).Returns(DummyServiceBusConnectionString); configuration.SetupGet(_ => _.OtherConnectionStrings).Returns(new System.Collections.Generic.Dictionary <string, string>()); var serviceProvider = new Mock <IServiceProvider>(); serviceProvider.Setup(_ => _.GetService(typeof(IEnumerable <IMessageEnricher>))).Returns(Enumerable.Empty <IMessageEnricher>()); var sut = new AzureServiceBusEndpointFactory(configuration.Object, serviceProvider.Object); // act var sender = sut.Create <Foo>(); var sender2 = sut.Create <Foo>(); // assert sender.Should().BeSameAs(sender2); }