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.Count);
                Assert.AreEqual("Name or Profile is null", ex.Detail.Details[0].Message);
            }
        }
Exemple #2
0
        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.Count);
                Assert.AreEqual("Multiple location services found instead of one", 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);
            }
        }
Exemple #4
0
        public void FindMetaEA_NoProfile_ExcMessage()
        {
            // Arrange
            string          name            = "BSKlantBeheer";
            string          profile         = null;
            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.Count);
                Assert.AreEqual("Name or Profile is null", ex.Detail.Details[0].Message);
            }
        }
Exemple #5
0
        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
        }
Exemple #6
0
        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);
        }
Exemple #7
0
        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.Count);
                Assert.AreEqual("The location service found has a version, so specify the version", ex.Detail.Details[0].Message);
            }
        }
        public void FindMetaEA_WithoutVersion_FoundMultiple()
        {
            // 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 MultipleRecordsFoundException("Multiple location services found instead of one"));
            var target = new ServiceLocatorService(mock.Object);

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

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

            var mock   = new Mock <IServiceLocationDatamapper>();
            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
        }
Exemple #11
0
        public void FindMetaEA_EmptyProfile()
        {
            // Arrange
            string          name            = "BSBeheerService";
            string          profile         = "";
            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
        }
Exemple #12
0
        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_WithVersion_FoundNone()
        {
            // 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 NoRecordsFoundException("No location services found"));
            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);
            }
        }
        public void FindMetaEA_WithoutVersion_FoundVersion()
        {
            // 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);

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

            // Assert
            //Exception thrown
        }