2025-02-13 16:25:09 +04:00

63 lines
2.2 KiB
C#

using System;
using System.Collections.Generic;
using NUnit.Framework;
using CandyHouseBase.DataModels;
using CandyHouseBase.Exceptions;
namespace CandyHouseTests.DataModelsTests
{
[TestFixture]
public class ProductDataModelTests
{
[Test]
public void CreateProductDataModel_ValidData_ShouldCreateSuccessfully()
{
var id = Guid.NewGuid().ToString();
var name = "Candy";
var description = "Delicious candy";
var ingredients = new List<IngredientDataModel>();
var product = new ProductDataModel(id, name, description, ingredients);
Assert.AreEqual(id, product.Id);
Assert.AreEqual(name, product.Name);
Assert.AreEqual(description, product.Description);
Assert.AreEqual(ingredients, product.IngredientsItems);
}
[Test]
public void CreateProductDataModel_InvalidId_ShouldThrowArgumentException()
{
var invalidId = "";
var name = "Candy";
var description = "Delicious candy";
var ingredients = new List<IngredientDataModel>();
var product = new ProductDataModel(invalidId, name, description, ingredients);
Assert.Throws<ValidationException>(() => product.Validate());
}
[Test]
public void CreateProductDataModel_InvalidName_ShouldThrowArgumentException()
{
var id = Guid.NewGuid().ToString();
var invalidName = "";
var description = "Delicious candy";
var ingredients = new List<IngredientDataModel>();
var product = new ProductDataModel(id, invalidName, description, ingredients);
Assert.Throws<ValidationException>(() => product.Validate());
}
[Test]
public void CreateProductDataModel_InvalidDescription_ShouldThrowArgumentException()
{
var id = Guid.NewGuid().ToString();
var name = "Candy";
var invalidDescription = "";
var ingredients = new List<IngredientDataModel>();
var product = new ProductDataModel(id, name, invalidDescription, ingredients);
Assert.Throws<ValidationException>(() => product.Validate());
}
}
}