This repository has been archived by the owner on Jun 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(back-end): Add StatisticsRepository tests
See also: #119
- Loading branch information
1 parent
8152454
commit 0f381fb
Showing
1 changed file
with
129 additions
and
0 deletions.
There are no files selected for viewing
129 changes: 129 additions & 0 deletions
129
Infrastructure.Test/Repositories/StatisticsRepositoryTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Kaizen.Domain.Repositories; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using NUnit.Framework; | ||
|
||
namespace Infrastructure.Test.Repositories | ||
{ | ||
[TestFixture] | ||
public class StatisticsRepositoryTest : BaseRepositoryTest | ||
{ | ||
private IStatisticsRepository _statisticsRepository; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
_statisticsRepository = ServiceProvider.GetService<IStatisticsRepository>(); | ||
} | ||
|
||
[Test, Order(0)] | ||
public void Check_StatisticsRepository() | ||
{ | ||
Assert.IsNotNull(_statisticsRepository); | ||
} | ||
|
||
[Test, Order(1)] | ||
public async Task Register_New_Applied_activity() | ||
{ | ||
try | ||
{ | ||
await _statisticsRepository.RegisterNewAppliedActivity(); | ||
|
||
Assert.Pass(); | ||
} | ||
catch (DbUpdateException e) | ||
{ | ||
Console.WriteLine(e.InnerException?.Message); | ||
Assert.Fail(e.Message); | ||
} | ||
} | ||
|
||
[Test, Order(2)] | ||
public async Task Register_New_Client_Register() | ||
{ | ||
try | ||
{ | ||
await _statisticsRepository.RegisterNewClientRegister(); | ||
|
||
Assert.Pass(); | ||
} | ||
catch (DbUpdateException e) | ||
{ | ||
Console.WriteLine(e.InnerException?.Message); | ||
Assert.Fail(e.Message); | ||
} | ||
} | ||
|
||
[Test, Order(3)] | ||
public async Task Register_New_Client_Visited() | ||
{ | ||
try | ||
{ | ||
await _statisticsRepository.RegisterNewClientVisited(); | ||
|
||
Assert.Pass(); | ||
} | ||
catch (DbUpdateException e) | ||
{ | ||
Console.WriteLine(e.InnerException?.Message); | ||
Assert.Fail(e.Message); | ||
} | ||
} | ||
|
||
[Test, Order(4)] | ||
public async Task Register_Profits() | ||
{ | ||
try | ||
{ | ||
await _statisticsRepository.RegisterProfits(5000m); | ||
|
||
Assert.Pass(); | ||
} | ||
catch (DbUpdateException e) | ||
{ | ||
Console.WriteLine(e.InnerException?.Message); | ||
Assert.Fail(e.Message); | ||
} | ||
} | ||
|
||
[Test, Order(5)] | ||
public async Task Search_Day_Statistics() | ||
{ | ||
var dayStatistics = await _statisticsRepository.GetDayStatistics(DateTime.Now); | ||
|
||
Assert.IsNotNull(dayStatistics); | ||
Assert.AreEqual(1, dayStatistics.ClientsRegistered); | ||
Assert.AreEqual(1, dayStatistics.ClientsVisited); | ||
Assert.AreEqual(1, dayStatistics.AppliedActivities); | ||
Assert.AreEqual(5000m, dayStatistics.Profits); | ||
} | ||
|
||
[Test, Order(6)] | ||
public async Task Search_Month_Statistics() | ||
{ | ||
var monthStatistics = await _statisticsRepository.GetMonthStatistics(DateTime.Now); | ||
|
||
Assert.IsNotNull(monthStatistics); | ||
Assert.IsNotNull(monthStatistics.DayStatistics); | ||
Assert.AreEqual(1, monthStatistics.ClientsRegistered); | ||
Assert.AreEqual(1, monthStatistics.ClientsVisited); | ||
Assert.AreEqual(1, monthStatistics.AppliedActivities); | ||
Assert.AreEqual(5000m, monthStatistics.Profits); | ||
} | ||
|
||
[Test, Order(7)] | ||
public async Task Search_Year_Statistics() | ||
{ | ||
var yearStatistics = await _statisticsRepository.GetYearStatistics(DateTime.Now.Year); | ||
|
||
Assert.IsNotNull(yearStatistics); | ||
Assert.IsNotNull(yearStatistics.MonthStatistics); | ||
Assert.AreEqual(1, yearStatistics.ClientsRegistered); | ||
Assert.AreEqual(1, yearStatistics.ClientsVisited); | ||
Assert.AreEqual(1, yearStatistics.AppliedActivities); | ||
Assert.AreEqual(5000m, yearStatistics.Profits); | ||
} | ||
} | ||
} |