Пример #1
0
        public async Task GivenAtLeastOneProductInDatabase()
        {
            var product = new Product
            {
                Id            = Faker.Random.Guid(),
                Name          = Faker.Random.String(),
                Description   = Faker.Random.String(),
                DeliveryPrice = Faker.Random.Decimal()
            };

            GetDependency <IProductRepository>()
            .Setup(x => x.ListAsync())
            .Returns(Task.FromResult((IEnumerable <Product>)(new List <Product> {
                product
            })));

            var httpActionResult = await TestInstance.GetAll();

            var dto = ((OkNegotiatedContentResult <ProductsDto>)httpActionResult).Content.Items.First();

            dto.ShouldSatisfyAllConditions(
                () => dto.Id.ShouldBe(product.Id),
                () => dto.Name.ShouldBe(product.Name),
                () => dto.Description.ShouldBe(product.Description),
                () => dto.DeliveryPrice.ShouldBe(product.DeliveryPrice)
                );
        }