2025-02-12 22:24:57 +04:00

40 lines
1.3 KiB
C#

using System;
using NUnit.Framework;
using CandyHouseBase.DataModels;
using CandyHouseBase.Exceptions;
namespace CandyHouseTests.DataModelsTests
{
[TestFixture]
public class IngredientStockDataModelTests
{
[Test]
public void IngredientStock_ShouldThrowException_WhenIdIsInvalid()
{
var stock = new IngredientStockDataModel("", 10);
Assert.Throws<ValidationException>(stock.Validate);
}
[Test]
public void IngredientStock_ShouldThrowException_WhenQuantityIsNegative()
{
var stock = new IngredientStockDataModel(Guid.NewGuid().ToString(), -5);
Assert.Throws<ValidationException>(stock.Validate);
}
[Test]
public void IngredientStock_ShouldAddStockCorrectly()
{
var stock = new IngredientStockDataModel(Guid.NewGuid().ToString(), 10);
stock.AddStock(5);
Assert.That(stock.Quantity, Is.EqualTo(15));
}
[Test]
public void IngredientStock_ShouldThrowException_WhenRemovingTooMuchStock()
{
var stock = new IngredientStockDataModel(Guid.NewGuid().ToString(), 10);
Assert.Throws<ValidationException>(() => stock.RemoveStock(15));
}
}
}