AbpCoreEf6Sample.Tests和AbpCoreEf6Sample.Web.Tests是ABP框架中的两个测试项目。
AbpCoreEf6Sample.Tests项目是基于.NET Core和xUnit的测试项目,用于测试应用程序中定义的服务、存储库、验证器等功能是否正确实现。
AbpCoreEf6Sample.Web.Tests项目是基于.NET Core和Selenium的测试项目,用于测试Web应用程序中的UI和用户操作是否正确。
以下是两个测试项目的示例代码:
AbpCoreEf6Sample.Tests示例代码:
public class SampleAppService_Tests : AbpCoreEf6SampleTestBase
{
private readonly ISampleAppService _sampleAppService;
public SampleAppService_Tests()
{
_sampleAppService = Resolve();
}
[Fact]
public async Task Should_Get_All_Samples()
{
//Arrange
//Act
var samples = await _sampleAppService.GetAll();
//Assert
samples.Count.ShouldBe(10);
}
}
AbpCoreEf6Sample.Web.Tests示例代码:
public class SampleAppUi_Tests : AbpCoreEf6SampleWebTestBase
{
private readonly IWebDriver _webDriver;
public SampleAppUi_Tests()
{
_webDriver = Resolve();
}
[Fact]
public void Should_Display_All_Sample_Items_When_Navigate_To_Index_Page()
{
//Arrange
var expectedSampleCount = 10;
//Act
_webDriver.Navigate().GoToUrl("/");
//Assert
_webDriver.FindElement(By.TagName("tbody")).FindElements(By.TagName("tr")).Count.ShouldBe(expectedSampleCount);
}
}