Exemplo n.º 1
0
        public ActionResult <List <Representative> > GetReps(string address)
        {
            try
            {
                var googleUri = _config["GoogleUri"];

                var googleResult = _helper.CallGoogleApi(address, googleUri);
                var reps         = _helper.ProcessGoogleResult(googleResult);
                return(reps);
            }
            catch (Exception ex)
            {
                return(StatusCode(500, $"Error returning representative data: {ex.Message}"));
            }
        }
Exemplo n.º 2
0
        public void ProcessGoogleResults_ReturnsFullyPopulatedRepresentative_GoogleAPIResultISWellFormed()
        {
            //Arrange
            var googleResult = GetValidGoogleApiResult();

            //Act
            var result = _helper.ProcessGoogleResult(googleResult).FirstOrDefault();

            //Assert
            Assert.IsTrue(result.Name == "Josiah Bartlett", $"Did not populate Name property correctly. Expected Josiah Bartlett but got {result.Name}");
            Assert.IsTrue(result.Party == "Democrat Party", $"Did not populate Party property correctly. Expected Democrat Party but got {result.Party}");
            Assert.IsTrue(result.PhoneNumber == "(111)-111-1111", $"Did not populate PhoneNumber property correctly. Expected (111)-111-1111 but got {result.PhoneNumber}");
            Assert.IsTrue(result.Email == "*****@*****.**", $"Did not populate Email property correctly. Expected [email protected] but got {result.Email}");
            Assert.IsTrue(result.Office == "President of the United States", $"Did not populate Office property correctly. Expected President of the United States but got {result.Office}");
            Assert.IsTrue(result.ImageUrl == "www.TheWestWing.fake", $"Did not populate ImageUrl property correctly. Expected www.TheWestWing.fake but got {result.ImageUrl}");
        }