Ejemplo n.º 1
0
        public async Task TestDeserialization_GetPeople_ExpectFailure()
        {
            //Arrange
            var config = new ConfigurationBuilder()
                         .AddJsonFile("appsettings-fail-deserialization.json")
                         .Build();

            _sut = new PeopleExternalService(config);

            //Act
            var peopleResponse = await _sut.GetPeople();

            //Assert
            Assert.NotNull(peopleResponse);
            Assert.True(peopleResponse.ResponseStatus == ResponseStatusEnum.Failure);
            Assert.True(peopleResponse.Errors.Any());
            Assert.True(peopleResponse.Errors.Count() == 1);
            Assert.True(peopleResponse.Errors.FirstOrDefault() == ErrorMessages.CannotDeserializePeople_02);

            var people = peopleResponse.Data;

            Assert.Null(people);
        }
Ejemplo n.º 2
0
        public async Task Test_GetPeople_ExpectSuccess()
        {
            //Arrange
            var config = new ConfigurationBuilder()
                         .AddJsonFile("appsettings.json")
                         .Build();

            _sut = new PeopleExternalService(config);

            //Act
            var peopleResponse = await _sut.GetPeople();

            //Assert
            Assert.NotNull(peopleResponse);
            Assert.True(peopleResponse.ResponseStatus == ResponseStatusEnum.Success);
            Assert.False(peopleResponse.Errors.Any());

            var people = peopleResponse.Data;

            Assert.NotNull(people);
            Assert.True(people.Any());

            //additional testing not required. Data may change over time and influence test results.
        }