Skip to content

Commit 79a6b8c

Browse files
committed
Added SmokeTest for SQL
1 parent 9c2a529 commit 79a6b8c

File tree

2 files changed

+45
-30
lines changed

2 files changed

+45
-30
lines changed

LinkDotNet.Blog.IntegrationTests/SmokeTest.cs

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System.Threading.Tasks;
2+
using FluentAssertions;
3+
using LinkDotNet.Blog.Infrastructure.Persistence;
4+
using LinkDotNet.Blog.Web;
5+
using Microsoft.AspNetCore.Mvc.Testing;
6+
using Xunit;
7+
8+
namespace LinkDotNet.Blog.IntegrationTests;
9+
10+
public class SmokeTests : IClassFixture<WebApplicationFactory<Program>>
11+
{
12+
private readonly WebApplicationFactory<Program> factory;
13+
14+
public SmokeTests(WebApplicationFactory<Program> factory)
15+
{
16+
this.factory = factory.WithWebHostBuilder(builder =>
17+
{
18+
builder.UseSetting("PersistenceProvider", PersistenceProvider.InMemory.Key);
19+
});
20+
}
21+
22+
[Fact]
23+
public async Task ShouldBootUpApplication()
24+
{
25+
var client = factory.CreateClient();
26+
27+
var result = await client.GetAsync("/");
28+
29+
result.IsSuccessStatusCode.Should().BeTrue();
30+
}
31+
32+
[Fact]
33+
public async Task ShouldBootUpWithSqlDatabase()
34+
{
35+
var client = factory.WithWebHostBuilder(builder =>
36+
{
37+
builder.UseSetting("PersistenceProvider", PersistenceProvider.SqliteServer.Key);
38+
builder.UseSetting("ConnectionString", "DataSource=file::memory:?cache=shared");
39+
}).CreateClient();
40+
41+
var result = await client.GetAsync("/");
42+
43+
result.IsSuccessStatusCode.Should().BeTrue();
44+
}
45+
}

0 commit comments

Comments
 (0)