示例#1
0
        public async Task GetManufacturersTest()
        {
            var manufacturers = new List <Manufacturer>
            {
                new Manufacturer()
                {
                    Name = "Said", Address = "USA LA"
                },
                new Manufacturer()
                {
                    Name = "Said", Address = "USA LA"
                },
            };

            var fakeRepositoryMock = new Mock <IManufacturerRepository>();

            fakeRepositoryMock.Setup(x => x.GetManufacturers()).ReturnsAsync(manufacturers);


            var manufacturerService = new ManufacturerService(fakeRepositoryMock.Object);

            var resultManufacturers = await manufacturerService.GetManufacturers();

            Assert.Collection(resultManufacturers, manufacturer =>
            {
                Assert.Equal("Said", manufacturer.Name);
            },
                              manufacturer =>
            {
                Assert.Equal("USA LA", manufacturer.Address);
            });
        }