Ejemplo n.º 1
0
        public async Task GetAllPets_by_client_orders_by_name()
        {
            var id = new Guid("994aa42a-e292-42f1-b5d4-749cd19a4d29");

            var data = new List <Pet>
            {
                new Pet {
                    Name = "BBB", Client = new Client {
                        Id = id
                    }
                },
                new Pet {
                    Name = "ZZZ", Client = new Client {
                        Id = id
                    }
                },
                new Pet {
                    Name = "AAA", Client = new Client {
                        Id = Guid.NewGuid()
                    }
                },
            }.AsQueryable().BuildMockDbSet();

            var mockContext = new Mock <PetShopDbContext>();

            mockContext.Setup(c => c.Pets).Returns(data.Object);

            var repository = new PetRepository(mockContext.Object);
            var pets       = await repository.GetAllByClient(id);

            pets.Count().Should().Be(2);
            pets.ElementAt(0).Name.Should().BeEquivalentTo("BBB");
            pets.ElementAt(1).Name.Should().BeEquivalentTo("ZZZ");
        }