コード例 #1
0
        public async void Dihes_AddAsync_Positive_Test()
        {
            var options = new DbContextOptionsBuilder <DreamFoodDeliveryContext>()
                          .UseInMemoryDatabase(databaseName: "Dihes_AddAsync_Positive_Test")
                          .Options;

            using (var context = new DreamFoodDeliveryContext(options))
            {
                var tagService = new TagService(_mapper, context);
                var service    = new DishService(_mapper, context, tagService);

                TagToAdd[] tags = new TagToAdd[] {
                    new TagToAdd
                    {
                        TagName = "New"
                    }
                };
                DishToAdd dish = new DishToAdd()
                {
                    Name        = "Name",
                    Composition = "Composition",
                    Description = "Description",
                    Weight      = "Weight",
                    TagNames    = new HashSet <TagToAdd>(tags)
                };

                var resultPositive = await service.AddAsync(dish);

                resultPositive.IsSuccess.Should().BeTrue();
                resultPositive.Data.Name.Should().BeEquivalentTo(dish.Name);
                resultPositive.Data.Composition.Should().BeEquivalentTo(dish.Composition);
                resultPositive.Data.Description.Should().BeEquivalentTo(dish.Description);
                resultPositive.Data.Weight.Should().BeEquivalentTo(dish.Weight);
            }
        }