43 lines
1.5 KiB
C#
Raw Normal View History

2025-02-12 22:24:57 +04:00
using System;
using NUnit.Framework;
using CandyHouseBase.DataModels;
using CandyHouseBase.Enums;
using CandyHouseBase.Exceptions;
namespace CandyHouseTests.DataModelsTests
{
[TestFixture]
public class SupplyItemDataModelTests
{
[Test]
public void SupplyItem_ShouldThrowException_WhenSupplyIdIsInvalid()
{
var supplyItem = new SupplyItemDataModel("", Guid.NewGuid().ToString(), 10, ItemType.Ingredient);
Assert.Throws<ValidationException>(supplyItem.Validate);
}
[Test]
public void SupplyItem_ShouldThrowException_WhenItemIdIsInvalid()
{
var supplyItem = new SupplyItemDataModel(Guid.NewGuid().ToString(), "", 10, ItemType.Product);
Assert.Throws<ValidationException>(supplyItem.Validate);
}
[Test]
public void SupplyItem_ShouldThrowException_WhenQuantityIsZeroOrNegative()
{
var supplyItem = new SupplyItemDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 0,
ItemType.Product);
Assert.Throws<ValidationException>(supplyItem.Validate);
}
[Test]
public void SupplyItem_ShouldCreateSuccessfully_WithValidData()
{
var supplyItem = new SupplyItemDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 10,
ItemType.Ingredient);
Assert.That(supplyItem.Quantity, Is.EqualTo(10));
Assert.That(supplyItem.ItemType, Is.EqualTo(ItemType.Ingredient));
}
}
}