Refactor products and buildings to support modding
This commit is contained in:
67
backend/tests/MyBiz.Tests/DefaultProductsTests.cs
Normal file
67
backend/tests/MyBiz.Tests/DefaultProductsTests.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using MyBiz.Core;
|
||||
|
||||
namespace MyBiz.Tests;
|
||||
|
||||
public class DefaultProductsTests
|
||||
{
|
||||
[Fact]
|
||||
public void DefaultProducts_GetAll_ShouldReturn12Products()
|
||||
{
|
||||
// Act
|
||||
var products = DefaultProducts.GetAll().ToList();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(12, products.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DefaultProducts_ShouldHaveAllCategories()
|
||||
{
|
||||
// Act
|
||||
var products = DefaultProducts.GetAll().ToList();
|
||||
|
||||
// Assert
|
||||
Assert.Contains(products, p => p.Category == ProductCategory.RawMaterial);
|
||||
Assert.Contains(products, p => p.Category == ProductCategory.Component);
|
||||
Assert.Contains(products, p => p.Category == ProductCategory.ConsumerGoods);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DefaultProducts_RegisterAll_ShouldAddToRegistry()
|
||||
{
|
||||
// Arrange
|
||||
var registry = new ProductRegistry();
|
||||
|
||||
// Act
|
||||
DefaultProducts.RegisterAll(registry);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(12, registry.Count);
|
||||
Assert.NotNull(registry.GetById("goods_food"));
|
||||
Assert.NotNull(registry.GetById("goods_automobile"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DefaultProducts_Automobile_ShouldHaveCorrectProperties()
|
||||
{
|
||||
// Act
|
||||
var automobile = DefaultProducts.GetAll().First(p => p.Id == "goods_automobile");
|
||||
|
||||
// Assert
|
||||
Assert.Equal("Автомобили", automobile.Name);
|
||||
Assert.Equal(5000m, automobile.BasePrice);
|
||||
Assert.Equal(1920, automobile.AvailableFromYear);
|
||||
Assert.False(automobile.IsPerishable);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DefaultProducts_Food_ShouldBePerishable()
|
||||
{
|
||||
// Act
|
||||
var food = DefaultProducts.GetAll().First(p => p.Id == "goods_food");
|
||||
|
||||
// Assert
|
||||
Assert.True(food.IsPerishable);
|
||||
Assert.Equal(5, food.ShelfLife);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user