Refactor products and buildings to support modding
This commit is contained in:
81
backend/tests/MyBiz.Tests/BuildingTests.cs
Normal file
81
backend/tests/MyBiz.Tests/BuildingTests.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using MyBiz.Core;
|
||||
|
||||
namespace MyBiz.Tests;
|
||||
|
||||
public class BuildingTests
|
||||
{
|
||||
[Fact]
|
||||
public void Building_CalculateEfficiency_FullWorkers_ShouldBeMax()
|
||||
{
|
||||
// Arrange
|
||||
var config = new BuildingTypeConfig
|
||||
{
|
||||
Id = "factory",
|
||||
BaseEfficiency = 100,
|
||||
WorkerSlots = 10
|
||||
};
|
||||
|
||||
var building = new Building
|
||||
{
|
||||
TypeConfig = config,
|
||||
Workers = 10,
|
||||
Level = 1
|
||||
};
|
||||
|
||||
// Act
|
||||
building.CalculateEfficiency();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(100, building.CurrentEfficiency);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Building_CalculateEfficiency_NoWorkers_ShouldBeZero()
|
||||
{
|
||||
// Arrange
|
||||
var config = new BuildingTypeConfig
|
||||
{
|
||||
Id = "factory",
|
||||
BaseEfficiency = 100,
|
||||
WorkerSlots = 10
|
||||
};
|
||||
|
||||
var building = new Building
|
||||
{
|
||||
TypeConfig = config,
|
||||
Workers = 0,
|
||||
Level = 1
|
||||
};
|
||||
|
||||
// Act
|
||||
building.CalculateEfficiency();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(0, building.CurrentEfficiency);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Building_LevelBonus_ShouldIncreaseEfficiency()
|
||||
{
|
||||
// Arrange
|
||||
var config = new BuildingTypeConfig
|
||||
{
|
||||
Id = "factory",
|
||||
BaseEfficiency = 100,
|
||||
WorkerSlots = 10
|
||||
};
|
||||
|
||||
var building = new Building
|
||||
{
|
||||
TypeConfig = config,
|
||||
Workers = 10,
|
||||
Level = 5
|
||||
};
|
||||
|
||||
// Act
|
||||
building.CalculateEfficiency();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(120, building.CurrentEfficiency); // 100 + (4 * 5)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user