public void GetZipInfo_ReturnsZipCodeInfo() { // Arrange var mockZipCodeRepository = Substitute.For<IZipCodeRepository>(); var zipCode = new ZipCode { City = "LINCOLN PARK", State = new State { Abbreviation = "NJ" }, Zip = "07035" }; mockZipCodeRepository.GetByZip("07035").Returns(zipCode); var manager = new GeoManager(mockZipCodeRepository); // Act var actual = manager.GetZipInfo("07035"); // Assert Assert.Equal(zipCode.City, actual.City); Assert.Equal(zipCode.State.Abbreviation, actual.State); }
public void TestStatesRetrieval() { var mockStateRepository = new Mock<IStateRepository>(); var states = new List<State>() { new State() { Abbreviation = "NJ" }, new State() { Abbreviation = "NY" }, new State() { Abbreviation = "AR" } }; mockStateRepository.Setup(repository => repository.Get(true)) .Returns(states); var geoService = new GeoManager(mockStateRepository.Object); var data = geoService.GetStates(true).ToList(); var statesAbbr = states.Select(state => state.Abbreviation).ToList(); Assert.IsTrue(!statesAbbr.Except(data).Any()); Assert.IsTrue(statesAbbr.Count == data.Count); }
public void Return_corresponding_zipcode_given_a_zip() { var zipCode = new ZipCode() { City = "LINCOLN PARK", State = new State() {Abbreviation = "NJ"}, Zip = "07035" }; var zipRepository = Substitute.For<IZipCodeRepository>(); zipRepository.GetByZip("07035").Returns(zipCode); var manager = new GeoManager(zipCodeRepository: zipRepository); var data = manager.GetZipInfo("07035"); data.City.Should().Be("LINCOLN PARK"); data.State.Should().Be("NJ"); data.ZipCode.Should().Be("07035"); }
public void TestZipCodeRetrieval() { Mock<IZipCodeRepository> mockZipCodeRepository = new Mock<IZipCodeRepository>(); ZipCode zipCode = new ZipCode() { City = "LINCOLN PARK", State = new State() { Abbreviation = "NJ"}, Zip = "07035" }; mockZipCodeRepository.Setup(i => i.GetByZip("07035")).Returns(zipCode); IGeoService geoService = new GeoManager(mockZipCodeRepository.Object); var data = geoService.GetZipInfo("07035"); Assert.IsTrue(data.City.ToUpper() == "LINCOLN PARK"); Assert.IsTrue(data.State == "NJ"); }
public void test_zip_code_retrieval() { Mock<IZipCodeRepository> mockZipCodeRepository = new Mock<IZipCodeRepository>(); ZipCode zipCode = new ZipCode() { City = "Lincoln Park", State = new State() { Abbreviation = "NJ" }, Zip = "07035" }; mockZipCodeRepository.Setup(obj => obj.GetByZip("07035")).Returns(zipCode); //-- IGeoService geoService = new GeoManager(mockZipCodeRepository.Object); ZipCodeData data = geoService.GetZipInfo("07035"); Assert.IsTrue(data.City == "Lincoln Park"); Assert.IsTrue(data.State == "NJ"); }
public void Check_Get_Zip_Data() { Mock<IZipCodeRepository> moqZipRepository = new Mock<IZipCodeRepository>(); ZipCode zipCode = new ZipCode { Zip = "122001", City = "Gurgaon", State = new State { Abbreviation = "HRY" } }; moqZipRepository.Setup(obj => obj.GetByZip("122001")).Returns(zipCode); IGeoService geoService = new GeoManager(moqZipRepository.Object); ZipCodeData zipCodeData = geoService.GetZipInfo("122001"); Assert.IsTrue(zipCodeData.City.ToUpper().Equals("GURGAON")); Assert.IsTrue(zipCodeData.State.ToUpper().Equals("HRY")); }
public void GetStatesCheck() { IGeoService geoManager = new GeoManager(); List<string> result = geoManager.GetStates(true).ToList(); Assert.IsTrue(result.Count > 0); }