Beispiel #1
0
        public void GivenAInvalidAddressShouldReturnInvalidAddress()
        {
            const int employerId           = 2;
            var       employerService      = new Mock <IEmployerService>();
            var       geoCodeLookupService = new Mock <IGeoCodeLookupService>();
            var       postalAddress        = new PostalAddress();

            employerService.Setup(es => es.GetEmployer(employerId, It.IsAny <bool>())).Returns(new Employer {
                Address = postalAddress
            });
            geoCodeLookupService.Setup(gs => gs.GetGeoPointFor(postalAddress)).Returns(GeoPoint.NotSet);

            var geoCodingProvider =
                new GeoCodingProviderBuilder().With(employerService).With(geoCodeLookupService).Build();

            var result = geoCodingProvider.EmployerHasAValidAddress(employerId);

            result.Should().Be(GeoCodeAddressResult.InvalidAddress);
        }
Beispiel #2
0
        public void GivenAnAlreadyGeoCodedAddressShouldNotCallGeoCodingService()
        {
            const int employerId           = 2;
            var       employerService      = new Mock <IEmployerService>();
            var       geoCodeLookupService = new Mock <IGeoCodeLookupService>();

            var postalAddress = new Fixture().Create <PostalAddress>();

            employerService.Setup(es => es.GetEmployer(employerId, It.IsAny <bool>())).Returns(new Employer {
                Address = postalAddress
            });

            var geoCodingProvider =
                new GeoCodingProviderBuilder().With(employerService).With(geoCodeLookupService).Build();

            var result = geoCodingProvider.EmployerHasAValidAddress(employerId);

            geoCodeLookupService.Verify(gs => gs.GetGeoPointFor(postalAddress), Times.Never);
            result.Should().Be(GeoCodeAddressResult.Ok);
        }
Beispiel #3
0
        public void GivenAValidAddressShouldReturnOk()
        {
            const int employerId           = 2;
            var       employerService      = new Mock <IEmployerService>();
            var       geoCodeLookupService = new Mock <IGeoCodeLookupService>();
            var       postalAddress        = new PostalAddress {
                County = "something"
            };

            employerService.Setup(es => es.GetEmployer(employerId, It.IsAny <bool>())).Returns(new Employer {
                Address = postalAddress
            });
            geoCodeLookupService.Setup(gs => gs.GetGeoPointFor(postalAddress)).Returns(new Fixture().Create <GeoPoint>());

            var geoCodingProvider =
                new GeoCodingProviderBuilder().With(employerService).With(geoCodeLookupService).Build();

            var result = geoCodingProvider.EmployerHasAValidAddress(employerId);

            result.Should().Be(GeoCodeAddressResult.Ok);
        }
Beispiel #4
0
        public void GivenANonGeoCodedAddressShouldCallGeoCodingService()
        {
            const int employerId           = 2;
            var       employerService      = new Mock <IEmployerService>();
            var       geoCodeLookupService = new Mock <IGeoCodeLookupService>();
            var       postalAddress        = new PostalAddress {
                County = "something"
            };

            geoCodeLookupService.Setup(gs => gs.GetGeoPointFor(postalAddress)).Returns(GeoPoint.NotSet);

            employerService.Setup(es => es.GetEmployer(employerId, It.IsAny <bool>())).Returns(new Employer {
                Address = postalAddress
            });

            var geoCodingProvider =
                new GeoCodingProviderBuilder().With(employerService).With(geoCodeLookupService).Build();

            geoCodingProvider.EmployerHasAValidAddress(employerId);

            employerService.Verify(es => es.GetEmployer(employerId, It.IsAny <bool>()));
            geoCodeLookupService.Verify(gs => gs.GetGeoPointFor(postalAddress), Times.Once());
        }