/
ResourceListServiceTests.cs
50 lines (45 loc) · 1.51 KB
/
ResourceListServiceTests.cs
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
using Microsoft.EntityFrameworkCore;
using NetLearner.SharedLib.Data;
using NetLearner.SharedLib.Models;
using NetLearner.SharedLib.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;
namespace NetLearner.SharedLib.Tests
{
public class ResourceListServiceTests
{
[Trait("Resource List Tests", "Adding RL")]
[Theory(DisplayName = "Add New Resource List")]
[InlineData("RL1")]
public async void TestAdd(string expectedName)
{
var options = new DbContextOptionsBuilder<LibDbContext>()
.UseInMemoryDatabase(databaseName: "TestNewListDb").Options;
// Set up a context (connection to the "DB") for writing
using (var context = new LibDbContext(options))
{
// 1. Arrange
var rl = new ResourceList
{
Name = "RL1"
};
// 2. Act
var rls = new ResourceListService(context);
await rls.Add(rl);
}
using (var context = new LibDbContext(options))
{
var rls = new ResourceListService(context);
var result = await rls.Get();
// 3. Assert
Assert.NotEmpty(result);
Assert.Single(result);
Assert.NotEmpty(result.First().Name);
Assert.Equal(expectedName, result.First().Name);
}
}
}
}