add new tests
This commit is contained in:
parent
48da4621c6
commit
9ce5690584
@ -102,8 +102,10 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DataModelsTests\CustomerDataModelTests.cs" />
|
||||
<Compile Include="DataModelsTests\IngredientStockDataModelTests.cs" />
|
||||
<Compile Include="DataModelsTests\OrderDataModelTests.cs" />
|
||||
<Compile Include="DataModelsTests\ProductStockDataModelTests.cs" />
|
||||
<Compile Include="DataModelsTests\SupplyItemDataModelTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
|
@ -0,0 +1,40 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user