Skip to content

Commit 9ab463b

Browse files
committed
Corrected and simplified test
1 parent 10c123e commit 9ab463b

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

tests/LinkDotNet.Blog.UnitTests/Web/Features/Admin/Dashboard/DashboardPageTests.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
using System.Data.Common;
22
using System.Linq;
33
using LinkDotNet.Blog.Domain;
4-
using LinkDotNet.Blog.Infrastructure.Persistence;
5-
using LinkDotNet.Blog.Infrastructure.Persistence.Sql;
64
using LinkDotNet.Blog.Web;
75
using LinkDotNet.Blog.Web.Features.Admin.Dashboard;
86
using LinkDotNet.Blog.Web.Features.Admin.Dashboard.Components;
97
using LinkDotNet.Blog.Web.Features.Admin.Dashboard.Services;
108
using Microsoft.Data.Sqlite;
11-
using Microsoft.EntityFrameworkCore;
129
using Microsoft.Extensions.DependencyInjection;
1310

1411
namespace LinkDotNet.Blog.UnitTests.Web.Features.Admin.Dashboard;
@@ -20,15 +17,11 @@ public class DashboardPageTests : TestContext
2017
[InlineData(false)]
2118
public void ShouldShowAboutMeStatisticsAccordingToConfig(bool aboutMeEnabled)
2219
{
23-
var options = new DbContextOptionsBuilder()
24-
.UseSqlite(CreateInMemoryConnection())
25-
.Options;
20+
ComponentFactories.AddStub<VisitCountPerPage>();
2621
var dashboardService = new Mock<IDashboardService>();
2722
this.AddTestAuthorization().SetAuthorized("test");
2823
Services.AddScoped(_ => CreateAppConfiguration(aboutMeEnabled));
2924
Services.AddScoped(_ => dashboardService.Object);
30-
Services.AddScoped(_ => Mock.Of<IRepository<BlogPost>>());
31-
Services.AddScoped(_ => new BlogDbContext(options));
3225
dashboardService.Setup(d => d.GetDashboardDataAsync())
3326
.ReturnsAsync(new DashboardData());
3427

0 commit comments

Comments
 (0)