58 lines
2.0 KiB
C#
Raw Normal View History

2025-02-13 16:13:21 +04:00
using System;
using NUnit.Framework;
using CandyHouseBase.DataModels;
using CandyHouseBase.Exceptions;
namespace CandyHouseTests.DataModelsTests
{
[TestFixture]
public class RecipeDataModelTests
{
[Test]
public void CreateRecipeDataModel_ValidData_ShouldCreateSuccessfully()
{
var productId = Guid.NewGuid().ToString();
var ingredientId = Guid.NewGuid().ToString();
var quantity = 5;
var recipe = new RecipeDataModel(productId, ingredientId, quantity);
Assert.AreEqual(productId, recipe.ProductId);
Assert.AreEqual(ingredientId, recipe.IngredientId);
Assert.AreEqual(quantity, recipe.Quantity);
}
[Test]
public void CreateRecipeDataModel_InvalidProductId_ShouldThrowValidationException()
{
var invalidProductId = "";
var ingredientId = Guid.NewGuid().ToString();
var quantity = 5;
var recipe = new RecipeDataModel(invalidProductId, ingredientId, quantity);
Assert.Throws<ValidationException>(() => recipe.Validate());
}
[Test]
public void CreateRecipeDataModel_InvalidIngredientId_ShouldThrowValidationException()
{
var productId = Guid.NewGuid().ToString();
var invalidIngredientId = "";
var quantity = 5;
var recipe = new RecipeDataModel(productId, invalidIngredientId, quantity);
Assert.Throws<ValidationException>(() => recipe.Validate());
}
[Test]
public void CreateRecipeDataModel_InvalidQuantity_ShouldThrowValidationException()
{
var productId = Guid.NewGuid().ToString();
var ingredientId = Guid.NewGuid().ToString();
var invalidQuantity = -1;
var recipe = new RecipeDataModel(productId, ingredientId, invalidQuantity);
Assert.Throws<ValidationException>(() => recipe.Validate());
}
}
}