Skip to content
This repository has been archived by the owner on Jun 25, 2022. It is now read-only.

Commit

Permalink
refactor(back-end): Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosPavajeau committed Apr 28, 2021
1 parent a1519dd commit 6ce9564
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Infrastructure.Test.Repositories
[TestFixture]
public class ApplicationUserRepositoryTest : BaseRepositoryTest
{
public static string SavedUserId;
public static string SavedUserId { get; private set; }

private IApplicationUserRepository _applicationUserRepository;

Expand Down
13 changes: 6 additions & 7 deletions Infrastructure.Test/Services/MailTemplates/MailTemplateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ namespace Infrastructure.Test.Services.MailTemplates
public class MailTemplateTest
{
private IMailTemplate _mailTemplate;
private Mock<IHostEnvironment> _hostEnvironment;

protected ServiceProvider ServiceProvider { get; private set; }
private ServiceProvider ServiceProvider { get; set; }

[OneTimeSetUp]
public void Init()
Expand All @@ -30,12 +29,12 @@ public void Init()
[SetUp]
public void SetUp()
{
_hostEnvironment = new Mock<IHostEnvironment>();
Mock<IHostEnvironment> hostEnvironment = new Mock<IHostEnvironment>();

string path = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
_hostEnvironment.Setup(h => h.ContentRootPath).Returns(path);
string path = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
hostEnvironment.Setup(h => h.ContentRootPath).Returns(path);

_mailTemplate = new MailTemplate(_hostEnvironment.Object,
_mailTemplate = new MailTemplate(hostEnvironment.Object,
ServiceProvider.GetService<ILogger<MailTemplate>>());
}

Expand Down Expand Up @@ -63,7 +62,7 @@ public void Load_Non_Existent_Template()
{
try
{
string template = _mailTemplate.LoadTemplate("NonExistentTemplate.html");
_ = _mailTemplate.LoadTemplate("NonExistentTemplate.html");
Assert.Fail("The template to search should not exist.");
}
catch (ArgumentException e)
Expand Down
1 change: 0 additions & 1 deletion Infrastructure/Repositories/UnitWork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public UnitWork(ApplicationDbContext applicationDbContext, IDomainEventDispatche
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

private void Dispose(bool disposing)
Expand Down
2 changes: 1 addition & 1 deletion Kaizen.Test/Helpers/TestAsyncEnumerable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ IDbAsyncEnumerator IDbAsyncEnumerable.GetAsyncEnumerator()
return GetAsyncEnumerator();
}

public IAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken)
public IAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken )
{
return new TestAsyncEnumerator<T>(this.AsEnumerable().GetEnumerator());
}
Expand Down
23 changes: 9 additions & 14 deletions Kaizen/DomainEvents/Handlers/SendNotificationWhenPaidInvoice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,16 @@ public async Task Handle(DomainEventNotification<PaidInvoice> notification,
{
await _statisticsRepository.RegisterProfits(notification.DomainEvent.Invoice.Total);

switch (notification.DomainEvent.Invoice)
if (notification.DomainEvent.Invoice is ProductInvoice productInvoice)
{
case ProductInvoice productInvoice:
{
await _invoiceHub.Clients.Group("Administrator")
.SendAsync("OnPaidProductInvoice", _mapper.Map<ProductInvoiceViewModel>(productInvoice),
cancellationToken);
break;
}
case ServiceInvoice serviceInvoice:
{
await _invoiceHub.Clients.Group("Administrator").SendAsync("OnPaidServiceInvoice",
_mapper.Map<ServiceInvoiceViewModel>(serviceInvoice), cancellationToken);
break;
}
await _invoiceHub.Clients.Group("Administrator")
.SendAsync("OnPaidProductInvoice", _mapper.Map<ProductInvoiceViewModel>(productInvoice),
cancellationToken);
}
else if (notification.DomainEvent.Invoice is ServiceInvoice serviceInvoice)
{
await _invoiceHub.Clients.Group("Administrator").SendAsync("OnPaidServiceInvoice",
_mapper.Map<ServiceInvoiceViewModel>(serviceInvoice), cancellationToken);
}
}
}
Expand Down

0 comments on commit 6ce9564

Please sign in to comment.