public RecipeController() { recipeService = new RecipeService(); categoryService = new CategoryService(); subcategoryService = new SubcategoryService(); ingredientService = new IngredientService(); instructionsService = new InstructionsService(); ratingService = new RatingService(); commentService = new CommentService(); }
public async Task IsSubcategoryExistingById_WithNonExistingSubcategoryIdAndIsDeletedIsTrue_ShouldReturnFalse() { // Arrange FitStoreDbContext database = this.Database; DatabaseHelper.SeedData(database); ISubcategoryService subcategoryService = new SubcategoryService(database); // Act bool result = await subcategoryService.IsSubcategoryExistingById(nonExistingSubcategoryId, true); // Assert result.Should().Be(false); }
public async Task GetCategoryIdBySubcategoryId_WithSubcategoryId_ShouldReturnValidCategoryId() { // Arrange FitStoreDbContext database = this.Database; DatabaseHelper.SeedData(database); ISubcategoryService subcategoryService = new SubcategoryService(database); // Act int result = await subcategoryService.GetCategoryIdBySubcategoryId(secondSubcategoryId); // Assert result.Should().Be(2); }
public async Task TotalSupplementsCountAsync_WithSubcategoryId_ShouldReturnValidSum() { // Arrange FitStoreDbContext database = this.Database; DatabaseHelper.SeedData(database); ISubcategoryService subcategoryService = new SubcategoryService(database); // Act int result = await subcategoryService.TotalSupplementsCountAsync(firstSubcategoryId); // Assert result.Should().Be(2); }
public async Task IsSubcategoryExistingByIdAndName_WithOtherSubcategoryIdAndNonExistingSubcategoryName_ShouldReturnFalse() { // Arrange FitStoreDbContext database = this.Database; DatabaseHelper.SeedData(database); ISubcategoryService subcategoryService = new SubcategoryService(database); // Act bool result = await subcategoryService.IsSubcategoryExistingByIdAndName(firstSubcategoryId, nonExistingSubcategoryName); // Assert result.Should().Be(false); }
public async Task IsSubcategoryExistingByIdAndName_WithSubcategoryIdAndSubcategoryName_ShouldReturnTrue() { // Arrange FitStoreDbContext database = this.Database; DatabaseHelper.SeedData(database); ISubcategoryService subcategoryService = new SubcategoryService(database); // Act bool result = await subcategoryService.IsSubcategoryExistingByIdAndName(secondSubcategoryId, subcategoryName); // Assert result.Should().Be(true); }
public async Task GetDetailsByIdAsync_WithSupplementIdAndPage_ShouldReturnValidServiceModel() { // Arrange FitStoreDbContext database = this.Database; DatabaseHelper.SeedData(database); ISubcategoryService subcategoryService = new SubcategoryService(database); // Act SubcategoryDetailsServiceModel result = await subcategoryService.GetDetailsByIdAsync(firstSubcategoryId, 1); // Assert result.Id.Should().Be(1); result.Name.Should().Be("Subcategory 1"); result.CategoryId.Should().Be(1); result.CategoryName.Should().Be("Category 1"); result.Supplements.Count().Should().Be(2); }