Example #1
0
        public async Task TestCanGetOnlyMalePeople()
        {
            PetFinder sut    = CreateMockPetFinder();
            var       result = (await sut.GetPeopleAsync("mel", gender: Gender.Female)).ToList();

            // confirm that the pet finder used the client injected.
            Assert.That(result, Has.Count.EqualTo(3));
        }
Example #2
0
        public async Task TestGetNoIndeterminatePeople()
        {
            PetFinder sut    = CreateMockPetFinder();
            var       result = (await sut.GetPeopleAsync("mel", gender: Gender.DeclinedToSay)).ToList();

            // confirm that the pet finder used the client injected.
            Assert.That(result, Has.Count.EqualTo(0));
        }
Example #3
0
        public async Task TestCanFilterPetsByOwnerGender()
        {
            PetFinder sut    = CreateMockPetFinder();
            var       result = (await sut.GetPeopleAsync("mel")).ToList();

            // confirm that the pet finder used the client injected.
            Assert.That(result, Has.Count.EqualTo(6));
        }
Example #4
0
        public async Task TestPetFinderCollatesAllPets()
        {
            PetFinder sut    = CreateMockPetFinder();
            var       result = (await sut.GetPetsAsync("mel")).ToList();

            // confirm that the pet finder used the client injected.
            Assert.That(result, Has.Count.EqualTo(8));
        }
Example #5
0
        public async Task TestCanGetByAgePeople()
        {
            PetFinder sut    = CreateMockPetFinder();
            var       result = (await sut.GetPeopleAsync("mel", age: 18)).ToList();

            // confirm that the pet finder used the client injected.
            result.Should().HaveCount(1);
            result.ElementAt(0).Name.Should().Be("Jennifer");
        }
Example #6
0
        private PetFinder CreateMockPetFinder()
        {
            var mock = new Mock <IPetFinderRepositoryClient>();

            mock.Setup(foo => foo.GetAsync(It.IsAny <string>())).Returns(Task.FromResult(GetMelbourneTestData()));
            var sut = new PetFinder(mock.Object);

            return(sut);
        }
Example #7
0
        public async Task TestCanRetrievePeopleByNameAsync()
        {
            PetFinder sut    = CreateMockPetFinder();
            var       result = (await sut.GetPeopleAsync("mel", name: "Bob")).Single();

            // confirm that the pet finder used the client injected.
            result.Should().NotBeNull();
            result.Name.Should().Be("Bob");
            result.Age.Should().Be(23);
        }