예제 #1
0
        public async void ShouldAddCorrectly()
        {
            var mediatorMock = new Mock <IMediator>();
            var controller   = new RecipeController(mediatorMock.Object);

            var model = new CreateRecipeModel
            {
                Name        = "sample-name",
                Description = "sample-description",
                PictureUrl  = "https://example.com/sample-picture.png",
                Calories    = 1234,
                MealTypes   = new[] { MealType.Snack },
                Steps       = new[] { "sample-step" },
                Ingredients = new[] { "sample-ingredient" }
            };
            await controller.Add(model);

            mediatorMock.Verify(x =>
                                x.Send(
                                    It.Is <CreateRecipe>(y => y.IsDeepEqual(model.Map())),
                                    It.IsAny <CancellationToken>()
                                    ), Times.Once);
            mediatorMock.VerifyNoOtherCalls();
        }