Skip to content

Commit

Permalink
Corrected and simplified test
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdotnet committed Sep 19, 2022
1 parent 10c123e commit 9ab463b
Showing 1 changed file with 1 addition and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
using System.Data.Common;
using System.Linq;
using LinkDotNet.Blog.Domain;
using LinkDotNet.Blog.Infrastructure.Persistence;
using LinkDotNet.Blog.Infrastructure.Persistence.Sql;
using LinkDotNet.Blog.Web;
using LinkDotNet.Blog.Web.Features.Admin.Dashboard;
using LinkDotNet.Blog.Web.Features.Admin.Dashboard.Components;
using LinkDotNet.Blog.Web.Features.Admin.Dashboard.Services;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;

namespace LinkDotNet.Blog.UnitTests.Web.Features.Admin.Dashboard;
Expand All @@ -20,15 +17,11 @@ public class DashboardPageTests : TestContext
[InlineData(false)]
public void ShouldShowAboutMeStatisticsAccordingToConfig(bool aboutMeEnabled)
{
var options = new DbContextOptionsBuilder()
.UseSqlite(CreateInMemoryConnection())
.Options;
ComponentFactories.AddStub<VisitCountPerPage>();
var dashboardService = new Mock<IDashboardService>();
this.AddTestAuthorization().SetAuthorized("test");
Services.AddScoped(_ => CreateAppConfiguration(aboutMeEnabled));
Services.AddScoped(_ => dashboardService.Object);
Services.AddScoped(_ => Mock.Of<IRepository<BlogPost>>());
Services.AddScoped(_ => new BlogDbContext(options));
dashboardService.Setup(d => d.GetDashboardDataAsync())
.ReturnsAsync(new DashboardData());

Expand Down

0 comments on commit 9ab463b

Please sign in to comment.