58 lines
1.9 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 ProductDataModelTests
{
[Test]
public void CreateProductDataModel_ValidData_ShouldCreateSuccessfully()
{
var id = Guid.NewGuid().ToString();
var name = "Candy";
var description = "Delicious candy";
var product = new ProductDataModel(id, name, description);
Assert.AreEqual(id, product.Id);
Assert.AreEqual(name, product.Name);
Assert.AreEqual(description, product.Description);
}
[Test]
public void CreateProductDataModel_InvalidId_ShouldThrowArgumentException()
{
var invalidId = "";
var name = "Candy";
var description = "Delicious candy";
var product = new ProductDataModel(invalidId, name, description);
Assert.Throws<ValidationException>(() => product.Validate());
}
[Test]
public void CreateProductDataModel_InvalidName_ShouldThrowArgumentException()
{
var id = Guid.NewGuid().ToString();
var invalidName = "";
var description = "Delicious candy";
var product = new ProductDataModel(id, invalidName, description);
Assert.Throws<ValidationException>(() => product.Validate());
}
[Test]
public void CreateProductDataModel_InvalidDescription_ShouldThrowArgumentException()
{
var id = Guid.NewGuid().ToString();
var name = "Candy";
var invalidDescription = "";
var product = new ProductDataModel(id, name, invalidDescription);
Assert.Throws<ValidationException>(() => product.Validate());
}
}
}