public void FindMetaEA_EmptyName_ExcMessage()
        {
            // Arrange
            string name = "";
            string profile = "Development";
            decimal? version = 1.0m;
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name = name,
                Profile = profile,
                Version = version
            };

            var mock = new Mock<IServiceLocationDataMapper>(MockBehavior.Strict);

            var target = new ServiceLocatorService(mock.Object);

            // Act
            try
            {
                var result = target.FindMetadataEndpointAddress(serviceLocation);
            }
            catch (FaultException<FunctionalErrorList> ex)
            {
                // Assert
                Assert.AreEqual(1, ex.Detail.Details.Length);
                Assert.AreEqual("Name or Profile is null", ex.Detail.Details[0].Message);
            }
        }
        public void FindMetaEA_WithVersion_FoundMultiple_ExcMessage()
        {
            // Arrange
            string name = "BSKlantBeheer";
            string profile = "Development";
            decimal? version = 1.0m;
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name = name,
                Profile = profile,
                Version = version
            };

            var mock = new Mock<IServiceLocationDataMapper>(MockBehavior.Strict);
            mock.Setup(m => m.FindMetadataEndpointAddress(name, profile, version))
                .Throws(new MultipleRecordsFoundException("Multiple location services found instead of one"));
            var target = new ServiceLocatorService(mock.Object);

            try
            {
                // Act
                var result = target.FindMetadataEndpointAddress(serviceLocation);
                Assert.Fail();
            }
            catch (FaultException<FunctionalErrorList> ex)
            {
                // Assert
                Assert.AreEqual(1, ex.Detail.Details.Length);
                Assert.AreEqual("Multiple location services found instead of one", ex.Detail.Details[0].Message);
            }
        }
        public void Integration_FindMetaEA_WithVersion()
        {
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name = "BSCurusadministatie",
                Profile = "Production"
            };

            IServiceLocatorService proxy = _factory.CreateChannel();

            string uri = proxy.FindMetadataEndpointAddress(serviceLocation);

            Assert.AreEqual("http://infosupport.intranet/CAS/mex", uri);
        }
        public void Integration_FindMetaEA_WithoutVersion_Integration()
        {
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name = "PcSPlanningmaken",
                Profile = "Acceptation",
                Version = 1.0M
            };

            IServiceLocatorService proxy = _factory.CreateChannel();

            string uri = proxy.FindMetadataEndpointAddress(serviceLocation);

            Assert.AreEqual("http://infosupport.test/CAS/metadata", uri);
        }
        public void FindMetaEA_WithoutVersion_FoundNone()
        {
            // Arrange
            string name = "BSKlantBeheer";
            string profile = "Development";
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name = name,
                Profile = profile
            };

            var mock = new Mock<IServiceLocationDataMapper>(MockBehavior.Strict);
            mock.Setup(m => m.FindMetadataEndpointAddress(name, profile))
                .Throws(new NoRecordsFoundException("No location services found"));
            var target = new ServiceLocatorService(mock.Object);

            // Act
            var result = target.FindMetadataEndpointAddress(serviceLocation);

            // Assert
            //Exception thrown
        }
        public void FindMetaEA_EmptyName()
        {
            // Arrange
            string name = "";
            string profile = "Development";
            decimal? version = 1.0m;
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name = name,
                Profile = profile,
                Version = version
            };

            var mock = new Mock<IServiceLocationDataMapper>(MockBehavior.Strict);

            var target = new ServiceLocatorService(mock.Object);

            // Act
            var result = target.FindMetadataEndpointAddress(serviceLocation);

            // Assert
            //Exception thrown
        }
        public void FindMetaEA_WithVersion_FoundMultiple()
        {
            // Arrange
            string name = "BSKlantBeheer";
            string profile = "Development";
            decimal? version = 1.0m;
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name = name,
                Profile = profile,
                Version = version
            };

            var mock = new Mock<IServiceLocationDataMapper>(MockBehavior.Strict);
            mock.Setup(m => m.FindMetadataEndpointAddress(name, profile, version))
                .Throws(new MultipleRecordsFoundException("Multiple location services found instead of one"));
            var target = new ServiceLocatorService(mock.Object);

            // Act
            var result = target.FindMetadataEndpointAddress(serviceLocation);

            // Assert
            //Exception thrown
        }
        public void FindMetaEA_WithVersion_FoundSingle()
        {
            // Arrange
            string name = "BSKlantBeheer";
            string profile = "Development";
            decimal? version = 1.0m;
            string expected = "http://localhost:30412/BSKlantbeheer/mex";
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name = name,
                Profile = profile,
                Version = version
            };

            var mock = new Mock<IServiceLocationDataMapper>(MockBehavior.Strict);
            mock.Setup(m => m.FindMetadataEndpointAddress(name, profile, version)).Returns(expected);
            var target = new ServiceLocatorService(mock.Object);

            // Act
            var result = target.FindMetadataEndpointAddress(serviceLocation);

            // Assert
            mock.Verify(m => m.FindMetadataEndpointAddress(name, profile, version), Times.Once);
            Assert.AreEqual(expected, result);
        }
        public void FindMetaEA_WithoutVersion_FoundVersion_ExcMessage()
        {
            // Arrange
            string name = "BSKlantBeheer";
            string profile = "Development";
            ServiceLocation serviceLocation = new ServiceLocation
            {
                Name = name,
                Profile = profile
            };

            var mock = new Mock<IServiceLocationDataMapper>(MockBehavior.Strict);
            mock.Setup(m => m.FindMetadataEndpointAddress(name, profile))
                .Throws(new VersionedRecordFoundException(
                    "The location service found has a version, so specify the version"));
            var target = new ServiceLocatorService(mock.Object);

            try
            {
                // Act
                var result = target.FindMetadataEndpointAddress(serviceLocation);
                Assert.Fail();
            }
            catch (FaultException<FunctionalErrorList> ex)
            {
                // Assert
                Assert.AreEqual(1, ex.Detail.Details.Length);
                Assert.AreEqual("The location service found has a version, so specify the version", ex.Detail.Details[0].Message);
            }
        }