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 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 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 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 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)));
        }