[英]Storage setting on Azure Cosmos DB keeps changing from Unlimited to Fixed when deleting and re-creating database using API
[英]Getting 404 Not Found only when re-creating database in tests for 2nd API call
我正在嘗試為繼承的舊代碼創建API集成測試。
目前,我有一段測試代碼:
如果我跳過第一步並且僅執行2)3)4),則效果很好。
我也能夠執行步驟1)2)3)(這使得auth API調用可與數據庫娛樂一起使用)有點奇怪。
我以為我的Web api不能正常工作,但是當我不重新創建數據庫時,我能夠執行基本路徑。 然后,我認為重新創建數據庫時可能根本無法工作,但是我可以授權用戶。 我不知道我現在可以嘗試什么。
[Collection("Database Create collection")]
public class RoleControllerTests : IDisposable
{
private readonly IDisposable _server;
private readonly string _url = new Configuration().ServerUrl;
public RoleControllerTests()
{
_server = WebApp.Start<Startup>(_url);
}
public void Dispose()
{
_server.Dispose();
}
[Fact]
public async Task basic_roles_should_exist_in_the_database()
{
// Arrange
var roleApi = RestClient.For<IRoleController>(_url);
IAuthorize auth = new Authorize();
roleApi.AuthenticationHeader = await auth.GetAuthenticationHeaderAsync();
// Act
var rolesData = await roleApi.List();
// Assert
rolesData.ShouldContain(x => x.Name == "User");
rolesData.ShouldContain(x => x.Name == "Displayer");
}
}
因此,我已將測試框架更改為NUnit,並且可以正常工作。 我不知道為什么,XUnit在運行時更改事物時會有一些問題嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.