public void ComputeAdapterNameResolvesActualProtocolTypeNameForWcfCustomAdapter() { var sut = new NamingConventionDouble(); IAdapter adapter = new CustomAdapterFake <NetTcpBindingElement, CustomRLConfig>(); Assert.That(sut.ComputeAdapterNameSpy(adapter), Is.EqualTo("WCF-CustomNetTcp")); adapter = new CustomAdapterFake <System.ServiceModel.Configuration.NetMsmqBindingElement, CustomRLConfig>(); Assert.That(sut.ComputeAdapterNameSpy(adapter), Is.EqualTo("WCF-CustomNetMsmq")); adapter = new CustomAdapterFake <Be.Stateless.BizTalk.Dsl.Binding.ServiceModel.Configuration.NetMsmqBindingElement, CustomRLConfig>(); Assert.That(sut.ComputeAdapterNameSpy(adapter), Is.EqualTo("WCF-CustomNetMsmq")); adapter = new CustomAdapterFake <OracleDBBindingConfigurationElement, CustomRLConfig>(); Assert.That(sut.ComputeAdapterNameSpy(adapter), Is.EqualTo("WCF-CustomOracleDB")); adapter = new CustomAdapterFake <SqlAdapterBindingConfigurationElement, CustomRLConfig>(); Assert.That(sut.ComputeAdapterNameSpy(adapter), Is.EqualTo("WCF-CustomSql")); adapter = new WcfCustomAdapter.Outbound <CustomBindingElement>(a => a.Binding.Add(new MtomMessageEncodingElement(), new HttpsTransportElement())); Assert.That(sut.ComputeAdapterNameSpy(adapter), Is.EqualTo("WCF-CustomHttps")); adapter = new WcfCustomAdapter.Outbound <CustomBindingElement>(a => a.Binding.Add(new TcpTransportElement())); Assert.That(sut.ComputeAdapterNameSpy(adapter), Is.EqualTo("WCF-CustomTcp")); adapter = new WcfCustomAdapter.Outbound <CustomBindingElement>(a => a.Binding.Add(new SAPAdapterExtensionElement())); Assert.That(sut.ComputeAdapterNameSpy(adapter), Is.EqualTo("WCF-CustomSap")); adapter = new WcfCustomAdapter.Outbound <CustomBindingElement>(a => a.Binding.Add(new SqlAdapterBindingElementExtensionElement())); Assert.That(sut.ComputeAdapterNameSpy(adapter), Is.EqualTo("WCF-CustomSql")); // notice that OracleDBAdapterExtensionElement cannot be used because it is internal :( //adapter = new WcfCustomAdapter.Outbound<CustomBindingElement>(a => a.Binding.Add(new OracleDBAdapterExtensionElement())); }
public void ComputeReceiveLocationNameRequiresAreaToMatchItsReceivePortOneIfItHasOne() { var applicationBindingMock = new Mock <IApplicationBinding <NamingConventionDouble> >(); applicationBindingMock.As <ISupportNamingConvention>().Setup(snc => snc.Name).Returns("SomeApplication"); var receivePortMock = new Mock <IReceivePort <NamingConventionDouble> >(); receivePortMock.Setup(rp => rp.GetType()).Returns(typeof(TaxAgencyReceivePort)); receivePortMock.Setup(rp => rp.ApplicationBinding).Returns(applicationBindingMock.Object); receivePortMock.Setup(rp => rp.Name).Returns(new NamingConventionDouble { Party = "ReceivePortParty" }); var receiveLocationMock = new Mock <IReceiveLocation <NamingConventionDouble> >(); receiveLocationMock.Setup(rl => rl.GetType()).Returns(typeof(BankReceiveLocation)); receiveLocationMock.Setup(rl => rl.ReceivePort).Returns(receivePortMock.Object); receiveLocationMock.Setup(rl => rl.Transport).Returns(new ReceiveLocationTransport { Adapter = new FileAdapter.Inbound(t => { }) }); var sut = new NamingConventionDouble { MessageName = "SomeMessage", MessageFormat = "SomeFormat" }; Assert.That( () => sut.ComputeReceiveLocationNameSpy(receiveLocationMock.Object), Throws.TypeOf <NamingConventionException>().With.Message.EqualTo( string.Format( "'{0}' ReceiveLocation's Area, 'Income', does not match its ReceivePort's one, 'Invoice'.", typeof(BankReceiveLocation).Name))); }
public void ComputeReceiveLocationNameDoesNotRequireAreaToMatchItsReceivePortOneIfItHasNone() { var applicationBindingMock = new Mock <IApplicationBinding <NamingConventionDouble> >(); applicationBindingMock.As <ISupportNamingConvention>().Setup(snc => snc.Name).Returns("SomeApplication"); var receivePortMock = new Mock <IReceivePort <NamingConventionDouble> >(); receivePortMock.Setup(rp => rp.GetType()).Returns(typeof(StandaloneReceivePort)); receivePortMock.Setup(rp => rp.ApplicationBinding).Returns(applicationBindingMock.Object); receivePortMock.Setup(rp => rp.Name).Returns(new NamingConventionDouble { Party = "ReceivePortParty" }); var receiveLocationMock = new Mock <IReceiveLocation <NamingConventionDouble> >(); receiveLocationMock.Setup(rl => rl.GetType()).Returns(typeof(BankReceiveLocation)); receiveLocationMock.Setup(rl => rl.ReceivePort).Returns(receivePortMock.Object); receiveLocationMock.Setup(rl => rl.Transport).Returns(new ReceiveLocationTransport { Adapter = new FileAdapter.Inbound(t => { }) }); var sut = new NamingConventionDouble { MessageName = "SomeMessage", MessageFormat = "SomeFormat" }; Assert.That(() => sut.ComputeReceiveLocationNameSpy(receiveLocationMock.Object), Throws.Nothing); }
public void ComputeReceiveLocationNameTwoWay() { var applicationBindingMock = new Mock <IApplicationBinding <NamingConventionDouble> >(); applicationBindingMock.As <ISupportNamingConvention>().Setup(snc => snc.Name).Returns("SomeApplication"); var receivePortMock = new Mock <IReceivePort <NamingConventionDouble> >(); receivePortMock.Setup(rp => rp.GetType()).Returns(typeof(StandaloneReceivePort)); receivePortMock.Setup(rp => rp.ApplicationBinding).Returns(applicationBindingMock.Object); receivePortMock.Setup(rp => rp.Name).Returns(new NamingConventionDouble { Party = "SomeParty" }); receivePortMock.Setup(rp => rp.IsTwoWay).Returns(true); var receiveLocationMock = new Mock <IReceiveLocation <NamingConventionDouble> >(); receiveLocationMock.Setup(rl => rl.GetType()).Returns(typeof(StandaloneReceiveLocation)); receiveLocationMock.Setup(rl => rl.ReceivePort).Returns(receivePortMock.Object); receiveLocationMock.Setup(rl => rl.Transport).Returns(new ReceiveLocationTransport { Adapter = new FileAdapter.Inbound(t => { }) }); var sut = new NamingConventionDouble { MessageName = "SomeMessage", MessageFormat = "SomeFormat" }; Assert.That(sut.ComputeReceiveLocationNameSpy(receiveLocationMock.Object), Is.EqualTo("SomeApplication.RL2.SomeParty.SomeMessage.FILE.SomeFormat")); }
public void ComputeAreaReturnsNullWhenTypeQualifiedNameIsNotMadeOfExactlyFiveTokens() { var sut = new NamingConventionDouble(); Assert.That(sut.ComputeAreaSpy(typeof(SampleApplication)), Is.Null); Assert.That(sut.ComputeAreaSpy(typeof(SampleApplicationWithArea)), Is.Null); Assert.That(sut.ComputeAreaSpy(typeof(StandaloneReceivePort)), Is.Null); }
public void ComputeApplicationNameReturnsGivenName() { var applicationBindingMock = new Mock <IApplicationBinding <NamingConventionDouble> >(); var sut = new NamingConventionDouble { ApplicationName = "SampleApplicationName" }; Assert.That(sut.ComputeApplicationNameSpy(applicationBindingMock.Object), Is.EqualTo("SampleApplicationName")); }
public void ComputeApplicationNameReturnsTypeNameIfNotGiven() { var applicationBindingMock = new Mock <IApplicationBinding <NamingConventionDouble> >(); applicationBindingMock.Setup(ab => ab.GetType()).Returns(typeof(SampleApplication)); var sut = new NamingConventionDouble(); Assert.That(sut.ComputeApplicationNameSpy(applicationBindingMock.Object), Is.EqualTo("SampleApplication")); }
public void ComputeAdapterNameResolvesActualProtocolTypeNameForWcfCustomIsolatedAdapter() { var sut = new NamingConventionDouble(); IAdapter adapter = new CustomIsolatedAdapterFake <NetTcpBindingElement, CustomRLConfig>(); Assert.That(sut.ComputeAdapterNameSpy(adapter), Is.EqualTo("WCF-CustomIsolatedNetTcp")); adapter = new CustomIsolatedAdapterFake <WSHttpBindingElement, CustomRLConfig>(); Assert.That(sut.ComputeAdapterNameSpy(adapter), Is.EqualTo("WCF-CustomIsolatedWsHttp")); adapter = new CustomIsolatedAdapterFake <BasicHttpBindingElement, CustomRLConfig>(); Assert.That(sut.ComputeAdapterNameSpy(adapter), Is.EqualTo("WCF-CustomIsolatedBasicHttp")); }
public void ComputeSendPortNameRequiresApplicationBinding() { var sendPortMock = new Mock <ISendPort <NamingConventionDouble> >(); sendPortMock.Setup(sp => sp.GetType()).Returns(typeof(StandaloneSendPort)); var sut = new NamingConventionDouble(); Assert.That( () => sut.ComputeSendPortNameSpy(sendPortMock.Object), Throws.TypeOf <NamingConventionException>().With.Message.EqualTo( string.Format( "'{0}' SendPort is not bound to application's send port collection.", typeof(StandaloneSendPort).Name))); }
public void ComputeReceivePortNameEmbedsApplicationNameAndParty() { var applicationBindingMock = new Mock <IApplicationBinding <NamingConventionDouble> >(); applicationBindingMock.As <ISupportNamingConvention>().Setup(snc => snc.Name).Returns("SomeApplication"); var receivePortMock = new Mock <IReceivePort <NamingConventionDouble> >(); receivePortMock.Setup(rp => rp.GetType()).Returns(typeof(StandaloneReceivePort)); receivePortMock.Setup(rp => rp.ApplicationBinding).Returns(applicationBindingMock.Object); var sut = new NamingConventionDouble { Party = "SomeParty" }; Assert.That(sut.ComputeReceivePortNameSpy(receivePortMock.Object), Is.EqualTo("SomeApplication.RP1.SomeParty")); }
public void ComputeReceivePortNameRequiresParty() { var applicationBindingMock = new Mock <IApplicationBinding <NamingConventionDouble> >(); var receivePortMock = new Mock <IReceivePort <NamingConventionDouble> >(); receivePortMock.Setup(rp => rp.GetType()).Returns(typeof(StandaloneReceivePort)); receivePortMock.Setup(rp => rp.ApplicationBinding).Returns(applicationBindingMock.Object); var sut = new NamingConventionDouble(); Assert.That( () => sut.ComputeReceivePortNameSpy(receivePortMock.Object), Throws.TypeOf <NamingConventionException>().With.Message.EqualTo( string.Format( "'{0}' ReceivePort's Party is required.", typeof(StandaloneReceivePort).Name))); }
public void ComputeSendPortNameRequiresNonNullMessageFormat() { var applicationBindingMock = new Mock <IApplicationBinding <NamingConventionDouble> >(); applicationBindingMock.As <ISupportNamingConvention>().Setup(snc => snc.Name).Returns("SomeApplication"); var sendPortMock = new Mock <ISendPort <NamingConventionDouble> >(); sendPortMock.Setup(sp => sp.GetType()).Returns(typeof(StandaloneSendPort)); sendPortMock.Setup(sp => sp.ApplicationBinding).Returns(applicationBindingMock.Object); var sut = new NamingConventionDouble { Party = "SomeParty", MessageName = "SomeMessage" }; Assert.That( () => sut.ComputeSendPortNameSpy(sendPortMock.Object), Throws.TypeOf <NamingConventionException>().With.Message.EqualTo("A non null MessageFormat is required.")); }
public void ComputeSendPortNameEmbedsEmptyMessageFormat() { var applicationBindingMock = new Mock <IApplicationBinding <NamingConventionDouble> >(); applicationBindingMock.As <ISupportNamingConvention>().Setup(snc => snc.Name).Returns("SomeApplication"); var sendPortMock = new Mock <ISendPort <NamingConventionDouble> >(); sendPortMock.Setup(sp => sp.GetType()).Returns(typeof(StandaloneSendPort)); sendPortMock.Setup(sp => sp.ApplicationBinding).Returns(applicationBindingMock.Object); sendPortMock.Setup(sp => sp.Transport).Returns(new SendPortTransport { Adapter = new FileAdapter.Outbound(t => { }) }); var sut = new NamingConventionDouble { Party = "SomeParty", MessageName = "SomeMessage", MessageFormat = string.Empty }; Assert.That(sut.ComputeSendPortNameSpy(sendPortMock.Object), Is.EqualTo("SomeApplication.SP1.SomeParty.SomeMessage.FILE")); }
public void ComputeReceiveLocationNameRequiresNonNullMessageFormat() { var receivePortMock = new Mock <IReceivePort <NamingConventionDouble> >(); receivePortMock.Setup(rp => rp.Name).Returns(new NamingConventionDouble { Party = "ReceivePortParty" }); var receiveLocationMock = new Mock <IReceiveLocation <NamingConventionDouble> >(); receiveLocationMock.Setup(rl => rl.ReceivePort).Returns(receivePortMock.Object); var sut = new NamingConventionDouble { MessageName = "SomeMessage" }; Assert.That( () => sut.ComputeReceiveLocationNameSpy(receiveLocationMock.Object), Throws.TypeOf <NamingConventionException>().With.Message.EqualTo("A non null MessageFormat is required.")); }
public void ComputeReceiveLocationNameRequiresParty() { var receivePortMock = new Mock <IReceivePort <NamingConventionDouble> >(); receivePortMock.Setup(rp => rp.Name).Returns(new NamingConventionDouble()); var receiveLocationMock = new Mock <IReceiveLocation <NamingConventionDouble> >(); receiveLocationMock.Setup(rp => rp.GetType()).Returns(typeof(BankReceiveLocation)); receiveLocationMock.Setup(rl => rl.ReceivePort).Returns(receivePortMock.Object); var sut = new NamingConventionDouble(); Assert.That( () => sut.ComputeReceiveLocationNameSpy(receiveLocationMock.Object), Throws.TypeOf <NamingConventionException>().With.Message.EqualTo( string.Format( "'{0}' ReceiveLocation's Party is required.", typeof(BankReceiveLocation).Name))); }
public void ComputeReceiveLocationNameRequiresPartyToMatchItsReceivePortOne() { var receivePortMock = new Mock <IReceivePort <NamingConventionDouble> >(); receivePortMock.Setup(rp => rp.Name).Returns(new NamingConventionDouble { Party = "ReceivePortParty" }); var receiveLocationMock = new Mock <IReceiveLocation <NamingConventionDouble> >(); receiveLocationMock.Setup(rp => rp.GetType()).Returns(typeof(BankReceiveLocation)); receiveLocationMock.Setup(rl => rl.ReceivePort).Returns(receivePortMock.Object); var sut = new NamingConventionDouble { Party = "ReceiveLocationParty", MessageName = "SomeMessage", MessageFormat = "SomeFormat" }; Assert.That( () => sut.ComputeReceiveLocationNameSpy(receiveLocationMock.Object), Throws.TypeOf <NamingConventionException>().With.Message.EqualTo( string.Format( "'{0}' ReceiveLocation's Party, 'ReceiveLocationParty', does not match its ReceivePort's one, 'ReceivePortParty'.", typeof(BankReceiveLocation).Name))); }
public void ComputeAreaReturnsFourthTokenOfTypeQualifiedNameMadeOfExactlyFiveTokens() { var sut = new NamingConventionDouble(); Assert.That(sut.ComputeAreaSpy(typeof(TaxAgencyReceivePort)), Is.EqualTo("Invoice")); }