blob: 3e4dc643b4b4644baaad7b768b77fe1f01c7cb4b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using WikiWaka.Api.Controllers;
using WikiWaka.Api.Models;
namespace Tests;
[TestClass]
public class UnitTest1
{
private ContentApiController controller;
private DbWikiWakaContext dbContext;
[TestInitialize]
public async Task TestInit()
{
SqliteConnection connection = new SqliteConnection("Filename=:memory:");
connection.Open();
var _contextOptions = new DbContextOptionsBuilder<DbWikiWakaContext>()
.UseSqlite(connection)
.Options;
dbContext = new(_contextOptions);
await dbContext.Database.EnsureCreatedAsync();
await DbInit.InitializeLanguages(dbContext);
controller = new(dbContext);
}
[TestCleanup]
public async Task TestClean()
{
await dbContext.Database.EnsureDeletedAsync();
await dbContext.DisposeAsync();
}
[TestMethod]
public async Task TestMethod1()
{
WikiWaka.Api.Contract.NewContent parameter = new()
{
Text = "Hello, world",
LanguageCode = "en-US",
};
Content newContent = await controller.PostContents(parameter);
IAsyncEnumerable<Content> contents = controller.GetContents();
Content newGetContent = contents.ToBlockingEnumerable().Single();
Assert.AreEqual(parameter.Text, newContent.Properties.Single().Text);
Assert.AreEqual(parameter.Text, newGetContent.Properties.Single().Text);
}
}
|