假设我希望单元测试的类构造函数中有一些逻辑,如果我使用 xUnit.net 和每个方法的嵌套测试类,我将如何构造它?
using Xunit;
public class MyClass
{
public MyClass()
{
// Some logic to test
}
public int GetResult()
{
return 123;
}
}
public class MyClassFacts
{
// How to test MyClass constructor?
// Nested classes to test each of MyClass' methods
public class GetResult
{
[Fact]
public void IsCorrect()
{
var myClass = new MyClass();
int result = myClass.GetResult();
Assert.Equal(123, result);
}
// Other tests for MyClass.GetResult()...
}
}
答案 0 :(得分:1)
您已经在IsCorrect()测试中进行了技术测试,但是如果您想进行明确的测试:
<div ng-repeat="(id, thread) in messageThreads | orderObjectBy:'last_message':true">
Thread ID: {{thread.key}} - Last message: {{thread.last_message}}
</div>