Пример #1
0
        public void If_Pet_Is_Null_Return_False()
        {
            //
            // Arrange
            //
            var specification = new PetTypeSpecification();
            //
            // Act
            //
            var status = specification.IsSatisfiedBy(null, PetType.Dog);

            //
            // Assert
            //
            Assert.False(status);
        }
Пример #2
0
        public void If_Requested_PetType_Matches_The_PetType_Must_Return_True()
        {
            //
            // Arrange
            //
            var specification = new PetTypeSpecification();
            //
            // Act
            //
            var status = specification.IsSatisfiedBy(new Pet {
                Type = PetType.Dog
            }, PetType.Dog);

            //
            // Assert
            //
            Assert.True(status);
        }
Пример #3
0
        public async Task If_There_Are_No_Owners_For_The_Requested_PetType_Must_Return_Success_With_Empty_People_List()
        {
            //
            // Arrange
            //
            var mockedClient = new Mock <IPeopleAreUsHttpClient>();

            mockedClient.Setup(x => x.GetPeopleAsync()).ReturnsAsync(OperationResult <List <Person> > .Success(new List <Person>
            {
                new Person
                {
                    Name = "some name1", Age = 18, Gender = "Male", Pets = new List <Pet>
                    {
                        new Pet {
                            Name = "some dog 1", Type = "Dog"
                        },
                        new Pet {
                            Name = "some dog 2", Type = "Dog"
                        },
                    }
                }
            }));
            var petMapper     = new DtoPetToBusinessPet();
            var personMapper  = new DtoPersonToBusinessPerson(petMapper);
            var specification = new PetTypeSpecification();
            var service       = new PeopleService(mockedClient.Object, specification, personMapper, Mock.Of <ILogger <PeopleService> >());
            //
            // Act
            //
            var operation = await service.GetPetOwnersAsync(new GetPetOwnersRequest(PetType.Cat));

            //
            // Assert
            //
            Assert.True(operation.Status);
            Assert.NotNull(operation.Data);
            Assert.Empty(operation.Data.People);
        }