Skip to content
Open
5 changes: 3 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project>
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand Down Expand Up @@ -35,7 +35,8 @@
<PackageVersion Include="GoogleReCaptcha.V3" Version="1.3.1" />
<PackageVersion Include="Markdig" Version="1.3.2" />
<PackageVersion Include="MediaInfo.Wrapper.Core" Version="21.9.3" />
<PackageVersion Include="MediatR" Version="14.2.0" />
<PackageVersion Include="Mediator.Abstractions" Version="3.0.2" />
<PackageVersion Include="Mediator.SourceGenerator" Version="3.0.2" />
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="10.2.0" />
<PackageVersion Include="Microsoft.Extensions.ServiceDiscovery" Version="10.2.0" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.15.0" />
Expand Down
2 changes: 1 addition & 1 deletion src/DevBetterWeb.Core/DevBetterWeb.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PackageReference Include="Ardalis.SmartEnum" />
<PackageReference Include="Ardalis.Specification" />
<PackageReference Include="CSharpFunctionalExtensions" />
<PackageReference Include="MediatR" />
<PackageReference Include="Mediator.Abstractions" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" />
<PackageReference Include="NimblePros.Vimeo" />
Expand Down
2 changes: 1 addition & 1 deletion src/DevBetterWeb.Core/Events/AppStartedEvent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using DevBetterWeb.Core.SharedKernel;
using MediatR;
using Mediator;

namespace DevBetterWeb.Core.Events;

Expand Down
2 changes: 1 addition & 1 deletion src/DevBetterWeb.Core/Interfaces/IHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Threading.Tasks;
using DevBetterWeb.Core.Events;
using DevBetterWeb.Core.SharedKernel;
using MediatR;
using Mediator;

namespace DevBetterWeb.Core.Interfaces;

Expand Down
2 changes: 1 addition & 1 deletion src/DevBetterWeb.Core/SharedKernel/BaseDomainEvent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using MediatR;
using Mediator;

namespace DevBetterWeb.Core.SharedKernel;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<ItemGroup>
<PackageReference Include="Ardalis.Specification.EntityFrameworkCore" />
<PackageReference Include="Markdig" />
<PackageReference Include="MediatR" />
<PackageReference Include="Mediator.Abstractions" />
<PackageReference Include="NimblePros.Vimeo" />
<PackageReference Include="Ardalis.EFCore.Extensions" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Threading.Tasks;
using DevBetterWeb.Core.Interfaces;
using DevBetterWeb.Core.SharedKernel;
using MediatR;
using Mediator;

namespace DevBetterWeb.Infrastructure.DomainEvents;

Expand All @@ -17,7 +17,7 @@ public DomainEventHandler(IEnumerable<IHandle<TDomainEvent>> handlers)
_handlers = handlers;
}

public async Task Handle(TDomainEvent notification, CancellationToken cancellationToken)
public async ValueTask Handle(TDomainEvent notification, CancellationToken cancellationToken)
{
foreach (var handler in _handlers)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
using System.Threading.Tasks;
using DevBetterWeb.Core.Interfaces;
using DevBetterWeb.Core.SharedKernel;
using MediatR;
using Mediator;
using Microsoft.Extensions.Logging;

namespace DevBetterWeb.Infrastructure.DomainEvents;

public class MediatRDomainEventDispatcher : IDomainEventDispatcher
public class MediatorDomainEventDispatcher : IDomainEventDispatcher
{
private readonly IMediator _mediator;
private readonly ILogger<MediatRDomainEventDispatcher> _logger;
private readonly ILogger<MediatorDomainEventDispatcher> _logger;

public MediatRDomainEventDispatcher(IMediator mediator, ILogger<MediatRDomainEventDispatcher> logger)
public MediatorDomainEventDispatcher(IMediator mediator, ILogger<MediatorDomainEventDispatcher> logger)
{
_mediator = mediator;
_logger = logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using DevBetterWeb.Core.Events;
using DevBetterWeb.Core.Interfaces;
using DevBetterWeb.Infrastructure.DiscordWebooks;
using MediatR;
using Mediator;

namespace DevBetterWeb.Core.Handlers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static IServiceCollection AddInfrastructureServices(this IServiceCollecti
}

// Common Dependencies
services.AddScoped<IDomainEventDispatcher,MediatRDomainEventDispatcher>();
services.AddScoped<IDomainEventDispatcher, MediatorDomainEventDispatcher>();
// services.AddScoped<IDomainEventDispatcher>(sp => sp.GetRequiredService<DomainEventDispatcher>());

services.AddScoped<IMemberRegistrationService, MemberRegistrationService>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using DevBetterWeb.Core.Exceptions;
using DevBetterWeb.Core.Interfaces;
using DevBetterWeb.Infrastructure.Identity.Data;
using MediatR;
using Mediator;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using DevBetterWeb.Core.Exceptions;
using DevBetterWeb.Core.Interfaces;
using DevBetterWeb.Infrastructure.Identity.Data;
using MediatR;
using Mediator;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using DevBetterWeb.Core.Events;
using DevBetterWeb.Infrastructure.DomainEvents;
using DevBetterWeb.Infrastructure.Identity.Data;
using MediatR;
using Mediator;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI.Services;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using DevBetterWeb.Core.Interfaces;
using DevBetterWeb.Infrastructure.Identity.Data;
using GoogleReCaptcha.V3.Interface;
using MediatR;
using Mediator;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using DevBetterWeb.Core.Interfaces;
using DevBetterWeb.Infrastructure.Identity.Data;
using GoogleReCaptcha.V3.Interface;
using MediatR;
using Mediator;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
Expand Down
2 changes: 1 addition & 1 deletion src/DevBetterWeb.Web/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using DevBetterWeb.Core.Events;
using MediatR;
using Mediator;
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
Expand Down
6 changes: 5 additions & 1 deletion src/DevBetterWeb.Web/DevBetterWeb.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
<PackageReference Include="CSharpFunctionalExtensions" />
<PackageReference Include="Dapper" />
<PackageReference Include="GoogleReCaptcha.V3" />
<PackageReference Include="MediatR" />
<PackageReference Include="Mediator.Abstractions" />
<PackageReference Include="Mediator.SourceGenerator">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" />
<PackageReference Include="Microsoft.AspNetCore.AzureAppServices.HostingStartup" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using DevBetterWeb.Core.Interfaces;
using DevBetterWeb.Core.Specs;
using DevBetterWeb.Infrastructure.Identity.Data;
using MediatR;
using Mediator;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
Expand Down
14 changes: 9 additions & 5 deletions src/DevBetterWeb.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,15 @@

builder.Services.AddInfrastructureServices(isDevelopment, vimeoToken);

builder.Services.AddMediatR(cfg =>
cfg.RegisterServicesFromAssemblies(
typeof(IAggregateRoot).Assembly,
typeof(AppDbContext).Assembly,
typeof(Program).Assembly));
builder.Services.AddMediator(options =>
{
options.Assemblies =
[
typeof(IAggregateRoot),
typeof(AppDbContext),
typeof(Program)
];
});

builder.Services.AddScoped(typeof(IRepository<>), typeof(EfRepository<>));

Expand Down
2 changes: 1 addition & 1 deletion src/DevBetterWeb.Web/Services/DailyCheckService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using DevBetterWeb.Core.Events;
using DevBetterWeb.Core.Interfaces;
using DevBetterWeb.Core.Specs;
using MediatR;
using Mediator;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Threading.Tasks;
using DevBetterWeb.Core.Events;
using DevBetterWeb.Core.Interfaces;
using MediatR;
using Mediator;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using DevBetterWeb.Web;
using DevBetterWeb.Web.Areas.Identity;
using DevBetterWeb.Web.Models;
using MediatR;
using Mediator;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc.Testing;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MediatR" />
<PackageReference Include="Mediator.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
Expand Down
42 changes: 29 additions & 13 deletions tests/DevBetterWeb.FunctionalTests/NoOpMediator.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System.Collections.Generic;
#nullable enable
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Mediator;

namespace DevBetterWeb.FunctionalTests;

Expand All @@ -12,33 +13,48 @@ public IAsyncEnumerable<TResponse> CreateStream<TResponse>(IStreamRequest<TRespo
throw new System.NotImplementedException();
}

public IAsyncEnumerable<object> CreateStream(object request, CancellationToken cancellationToken = default)
public IAsyncEnumerable<TResponse> CreateStream<TResponse>(IStreamQuery<TResponse> query, CancellationToken cancellationToken = default)
{
throw new System.NotImplementedException();
}

public Task Publish(object notification, CancellationToken cancellationToken = default)
public IAsyncEnumerable<TResponse> CreateStream<TResponse>(IStreamCommand<TResponse> command, CancellationToken cancellationToken = default)
{
return Task.CompletedTask;
throw new System.NotImplementedException();
}

public IAsyncEnumerable<object?> CreateStream(object request, CancellationToken cancellationToken = default)
{
throw new System.NotImplementedException();
}

public ValueTask Publish(object notification, CancellationToken cancellationToken = default)
{
return ValueTask.CompletedTask;
}

public ValueTask Publish<TNotification>(TNotification notification, CancellationToken cancellationToken = default) where TNotification : INotification
{
return ValueTask.CompletedTask;
}

public Task Publish<TNotification>(TNotification notification, CancellationToken cancellationToken = default) where TNotification : INotification
public ValueTask<TResponse> Send<TResponse>(IRequest<TResponse> request, CancellationToken cancellationToken = default)
{
return Task.CompletedTask;
return ValueTask.FromResult<TResponse>(default!);
}

public Task<TResponse> Send<TResponse>(IRequest<TResponse> request, CancellationToken cancellationToken = default)
public ValueTask<TResponse> Send<TResponse>(ICommand<TResponse> command, CancellationToken cancellationToken = default)
{
return Task.FromResult<TResponse>(default);
return ValueTask.FromResult<TResponse>(default!);
}

public Task Send<TRequest>(TRequest request, CancellationToken cancellationToken = default) where TRequest : IRequest
public ValueTask<TResponse> Send<TResponse>(IQuery<TResponse> query, CancellationToken cancellationToken = default)
{
return Task.CompletedTask;
return ValueTask.FromResult<TResponse>(default!);
}

public Task<object> Send(object request, CancellationToken cancellationToken = default)
public ValueTask<object?> Send(object request, CancellationToken cancellationToken = default)
{
return Task.FromResult<object>(default);
return ValueTask.FromResult<object?>(default);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public async Task OrdersMemberRanksCorrectlyGivenUnorderedRanks()
_rankAndOrderServiceMock.When(x => x.OrderByRankForMembersAndBooks(Arg.Any<List<BookCategoryDto>>()))
.Do(callInfo =>
{
foreach (var category in callInfo.Arg<List<BookCategoryDto>>())
foreach (var category in callInfo.Arg<List<BookCategoryDto>>()!)
{
category.Members = category.Members.OrderBy(m => m.BooksRank).ToList();
}
Expand Down Expand Up @@ -178,7 +178,7 @@ public async Task OrdersMembersCorrectlyByBooksReadCountGivenUnorderedMembers()
_rankAndOrderServiceMock.When(x => x.OrderByRankForMembersAndBooks(Arg.Any<List<BookCategoryDto>>()))
.Do(callInfo =>
{
foreach (var category in callInfo.Arg<List<BookCategoryDto>>())
foreach (var category in callInfo.Arg<List<BookCategoryDto>>()!)
{
category.Members = category.Members.OrderByDescending(m => m.BooksReadCount).ThenBy(m => m.BooksRank).ToList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void UpdateBooksRankGivenCategoriesWithMultipleBooks()
_mockRankingService.When(rs => rs.CalculateBookRank(Arg.Any<List<BookDto>>()))
.Do(callInfo =>
{
foreach (var book in callInfo.Arg<List<BookDto>>())
foreach (var book in callInfo.Arg<List<BookDto>>()!)
{
book.Rank = book.Id!.Value;
}
Expand Down
Loading