我正在开发一个项目,并且必须在 C# 中对工厂设计模式进行单元测试。目前我陷入困境,我不知道我还要做什么。有人可以帮我吗?我想对这段代码进行单元测试:
public class CinemaFactory : AbstractFactory //inheritance of AbstractFactory
{
public override Space createspace(AddItemsInProps item)
{
//returns new Cinema
return new Cinema(item.AreaType, item.Position, item.Dimension);
}
}
Run Code Online (Sandbox Code Playgroud)
我还制作了一个单元测试项目并创建了这个:
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
//Arrange
Game1.Design_Patterns.CinemaFactory cinemaFactory = new Game1.Design_Patterns.CinemaFactory();
//Act
//Assert
}
}
Run Code Online (Sandbox Code Playgroud)
电影:
public class Cinema : Space //inheritance of Space class
{
//Named arguments free you from the need to remember or to look up the order of parameters in the parameter …Run Code Online (Sandbox Code Playgroud)