public async Task DeleteByUserIdAndRecipeIdAsync_WithExistentUserIdAndRecipeId_ShouldSuccessfullyDelete()
        {
            var errorMessagePrefix = "UserCookedRecipeService DeleteByUserIdAndRecipeIdAsync() method does not work properly.";

            // Arrange
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();
            var userCookedRecipeRepository = new EfRepository <UserCookedRecipe>(context);
            var userCookedRecipeService    = new UserCookedRecipeService(userCookedRecipeRepository);

            await this.SeedDataAsync(context);

            var userId   = context.Users.First(x => x.FullName == "User 1").Id;
            var recipeId = context.Recipes.First(x => x.Title == "Recipe 1").Id;

            // Act
            var userCookedRecipesCount = userCookedRecipeRepository.All().Count();
            await userCookedRecipeService
            .DeleteByUserIdAndRecipeIdAsync(userId, recipeId);

            var actualResult   = userCookedRecipeRepository.All().Count();
            var expectedResult = userCookedRecipesCount - 1;

            // Assert
            Assert.True(expectedResult == actualResult, errorMessagePrefix + " " + "Count is not reduced properly.");
        }
        public async Task DeleteByUserIdAndRecipeIdAsync_WithNonExistentUserIdAndRecipeId_ShouldThrowArgumentNullException()
        {
            // Arrange
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();
            var userCookedRecipeRepository = new EfRepository <UserCookedRecipe>(context);
            var userCookedRecipeService    = new UserCookedRecipeService(userCookedRecipeRepository);

            await this.SeedDataAsync(context);

            var nonExistentUserId   = Guid.NewGuid().ToString();
            var nonExistentRecipeId = Guid.NewGuid().ToString();

            // Act

            // Assert
            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                await userCookedRecipeService
                .DeleteByUserIdAndRecipeIdAsync(nonExistentUserId, nonExistentRecipeId);
            });
        }
        public async Task DeleteByUserIdAndRecipeIdAsync_WithExistentUserIdAndRecipeId_ShouldReturnCorrectResult()
        {
            var errorMessagePrefix = "UserCookedRecipeService DeleteByUserIdAndRecipeIdAsync() method does not work properly.";

            // Arrange
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();
            var userCookedRecipeRepository = new EfRepository <UserCookedRecipe>(context);
            var userCookedRecipeService    = new UserCookedRecipeService(userCookedRecipeRepository);

            await this.SeedDataAsync(context);

            var userId   = context.Users.First(x => x.FullName == "User 1").Id;
            var recipeId = context.Recipes.First(x => x.Title == "Recipe 1").Id;

            // Act
            var result = await userCookedRecipeService
                         .DeleteByUserIdAndRecipeIdAsync(userId, recipeId);

            // Assert
            Assert.True(result, errorMessagePrefix + " " + "Returns false.");
        }