-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSampleTest.cs
39 lines (36 loc) · 1.38 KB
/
SampleTest.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
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Wd3w.AspNetCore.EasyTesting.EntityFrameworkCore;
using Wd3w.AspNetCore.EasyTesting.Hestify;
using Wd3w.AspNetCore.EasyTesting.Moq;
using Wd3w.AspNetCore.EasyTesting.SampleApi.Entities;
using Wd3w.AspNetCore.EasyTesting.SampleApi.Services;
using Wd3w.AspNetCore.EasyTesting.Test.Common;
using Xunit;
namespace Wd3w.AspNetCore.EasyTesting.Test
{
public class SampleTest : EasyTestingTestBase
{
[Fact]
public async Task EasyTesting_Make_IntegrationTest_Easy()
{
// Given
SUT.ReplaceInMemoryDbContext<SampleDb>()
.SetupFixture<SampleDb>(async db =>
{
db.SampleDataEntities.Add(new SampleDataEntity());
await db.SaveChangesAsync();
})
.MockService<ISampleService>(mock => mock
.Setup(s => s.GetSampleDate())
.Returns("MockedData"));
// When
await SUT.Resource("api/get/sample").GetAsync();
// Then
SUT.UsingService<ISampleService>(service => service.GetSampleDate().Should().Be("MockedData"));
SUT.VerifyCallOnce<ISampleService>(service => service.GetSampleDate());
}
}
}