Added TrainingRecordService

This commit is contained in:
Chase Tucker
2024-03-04 13:07:51 -07:00
parent 1a3f0de8a7
commit 41a01fcf14
98 changed files with 388 additions and 3698 deletions

View File

@ -0,0 +1,112 @@
using FabApprovalWorkerService.Models;
using FabApprovalWorkerService.Services;
using Microsoft.Extensions.Logging;
using Moq;
using System.Collections.Concurrent;
namespace FabApprovalWorkerServiceTests;
public class TrainingRecordServiceTests {
private static readonly ILogger<TrainingRecordService> MOCK_LOGGER = Mock.Of<ILogger<TrainingRecordService>>();
private TrainingRecordService _trainingRecordService;
[SetUp]
public void Setup() {
_trainingRecordService = new TrainingRecordService(MOCK_LOGGER);
}
[Test]
public void ScrapeTrainingRecordsWithNullCsvReaderShouldThrowException() {
Assert.Throws<ArgumentNullException>(() => _trainingRecordService.ScrapeTrainingRecordsFromCsvFile(null));
}
[Test]
public void SortAndFilterWithNullArgShouldThrowException() {
Assert.Throws<ArgumentNullException>(() => _trainingRecordService.SortAndFilterTrainingRecordsByCompletionDate(null));
}
[Test]
public void SortAndFilterShouldProduceExpectedResult() {
List<TrainingRecord> trainingRecords = new List<TrainingRecord>() {
new TrainingRecord() {
ItemId = "item1",
UserId = "User1",
LastName = "LastName1",
FirstName = "FirstName1",
CompletionDate = DateTime.Now
},
new TrainingRecord() {
ItemId = "item1",
UserId = "User2",
LastName = "LastName2",
FirstName = "FirstName2",
CompletionDate = DateTime.Now
},
new TrainingRecord() {
ItemId = "item1",
UserId = "User1",
LastName = "LastName1",
FirstName = "FirstName1",
CompletionDate = DateTime.Now.AddDays(-1)
},
new TrainingRecord() {
ItemId = "item1",
UserId = "User2",
LastName = "LastName2",
FirstName = "FirstName2",
CompletionDate = DateTime.Now.AddDays(-1)
},
new TrainingRecord() {
ItemId = "item1",
UserId = "User1",
LastName = "LastName1",
FirstName = "FirstName1",
CompletionDate = DateTime.Now.AddDays(-30)
},
new TrainingRecord() {
ItemId = "item1",
UserId = "User2",
LastName = "LastName2",
FirstName = "FirstName2",
CompletionDate = DateTime.Now.AddDays(-30)
},
new TrainingRecord() {
ItemId = "item2",
UserId = "User1",
LastName = "LastName1",
FirstName = "FirstName1",
CompletionDate = DateTime.Now
},
new TrainingRecord() {
ItemId = "item2",
UserId = "User2",
LastName = "LastName2",
FirstName = "FirstName2",
CompletionDate = DateTime.Now
},
new TrainingRecord() {
ItemId = "item2",
UserId = "User1",
LastName = "LastName1",
FirstName = "FirstName1",
CompletionDate = DateTime.Now.AddDays(-5)
},
new TrainingRecord() {
ItemId = "item2",
UserId = "User2",
LastName = "LastName2",
FirstName = "FirstName2",
CompletionDate = DateTime.Now.AddDays(-5)
}
};
ConcurrentDictionary<(string, string), TrainingRecord> actualRecords = _trainingRecordService.SortAndFilterTrainingRecordsByCompletionDate(trainingRecords);
Assert.That(actualRecords.Count, Is.EqualTo(4));
Assert.That(actualRecords[("FirstName1LastName1", "item1")].CompletionDate, Is.GreaterThan(DateTime.Now.AddDays(-1)));
Assert.That(actualRecords[("FirstName2LastName2", "item2")].CompletionDate, Is.GreaterThan(DateTime.Now.AddDays(-5)));
}
}

View File

@ -61,6 +61,11 @@ public class UserServiceTests {
Assert.True(users.Count() == 2);
}
[Test]
public void UpdateUserCertificateDataWithNullListShouldThrowException() {
Assert.ThrowsAsync<ArgumentNullException>(async () => await _userService.UpdateUserCertificationData(null));
}
[Test]
public async Task UpdateUserCertificationDataShouldReturnTrue() {
bool result = await _userService.UpdateUserCertificationData(MOCK_USERS.ToList());

View File

@ -8,6 +8,7 @@
".NETCoreApp,Version=v8.0": {
"FabApprovalWorkerService/1.0.0": {
"dependencies": {
"CsvHelper": "31.0.0",
"Dapper": "2.1.28",
"Dapper.Contrib": "2.0.78",
"Microsoft.Extensions.Hosting": "8.0.0",
@ -19,6 +20,17 @@
"FabApprovalWorkerService.dll": {}
}
},
"CsvHelper/31.0.0": {
"dependencies": {
"System.Linq.Async": "4.0.0"
},
"runtime": {
"lib/net8.0/CsvHelper.dll": {
"assemblyVersion": "31.0.0.0",
"fileVersion": "31.0.0.12"
}
}
},
"Dapper/2.1.28": {
"runtime": {
"lib/net7.0/Dapper.dll": {
@ -513,6 +525,14 @@
}
}
},
"System.Linq.Async/4.0.0": {
"runtime": {
"lib/netcoreapp3.0/System.Linq.Async.dll": {
"assemblyVersion": "4.0.0.0",
"fileVersion": "4.0.0.2"
}
}
},
"System.Security.AccessControl/4.7.0": {
"dependencies": {
"Microsoft.NETCore.Platforms": "3.1.0",
@ -534,6 +554,13 @@
"serviceable": false,
"sha512": ""
},
"CsvHelper/31.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-PypRJq7AugnCJjq6Zu5EqFDTfRv7Gh+MtSH2T/kwiGmg1UHAflq4cE8j3uMkvXSxaayVtcwi+8hC0w+30YzzWA==",
"path": "csvhelper/31.0.0",
"hashPath": "csvhelper.31.0.0.nupkg.sha512"
},
"Dapper/2.1.28": {
"type": "package",
"serviceable": true,
@ -814,6 +841,13 @@
"path": "system.diagnostics.eventlog/8.0.0",
"hashPath": "system.diagnostics.eventlog.8.0.0.nupkg.sha512"
},
"System.Linq.Async/4.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-WbiYEedFZeM+psmMyoCt1AKbZppAZg8Eq1ZTQ+521fGNeXqlgJj0tZYV5n1LsKRO5osQuitYxGNuzPTy3213sg==",
"path": "system.linq.async/4.0.0",
"hashPath": "system.linq.async.4.0.0.nupkg.sha512"
},
"System.Security.AccessControl/4.7.0": {
"type": "package",
"serviceable": true,

View File

@ -33,6 +33,17 @@
}
},
"coverlet.collector/6.0.0": {},
"CsvHelper/31.0.0": {
"dependencies": {
"System.Linq.Async": "4.0.0"
},
"runtime": {
"lib/net8.0/CsvHelper.dll": {
"assemblyVersion": "31.0.0.0",
"fileVersion": "31.0.0.12"
}
}
},
"Dapper/2.1.28": {
"runtime": {
"lib/net7.0/Dapper.dll": {
@ -845,6 +856,14 @@
}
}
},
"System.Linq.Async/4.0.0": {
"runtime": {
"lib/netcoreapp3.0/System.Linq.Async.dll": {
"assemblyVersion": "4.0.0.0",
"fileVersion": "4.0.0.2"
}
}
},
"System.Reflection.Metadata/1.6.0": {},
"System.Security.AccessControl/4.7.0": {
"dependencies": {
@ -861,6 +880,7 @@
},
"FabApprovalWorkerService/1.0.0": {
"dependencies": {
"CsvHelper": "31.0.0",
"Dapper": "2.1.28",
"Dapper.Contrib": "2.0.78",
"Microsoft.Extensions.Hosting": "8.0.0",
@ -894,6 +914,13 @@
"path": "coverlet.collector/6.0.0",
"hashPath": "coverlet.collector.6.0.0.nupkg.sha512"
},
"CsvHelper/31.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-PypRJq7AugnCJjq6Zu5EqFDTfRv7Gh+MtSH2T/kwiGmg1UHAflq4cE8j3uMkvXSxaayVtcwi+8hC0w+30YzzWA==",
"path": "csvhelper/31.0.0",
"hashPath": "csvhelper.31.0.0.nupkg.sha512"
},
"Dapper/2.1.28": {
"type": "package",
"serviceable": true,
@ -1258,6 +1285,13 @@
"path": "system.diagnostics.eventlog/8.0.0",
"hashPath": "system.diagnostics.eventlog.8.0.0.nupkg.sha512"
},
"System.Linq.Async/4.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-WbiYEedFZeM+psmMyoCt1AKbZppAZg8Eq1ZTQ+521fGNeXqlgJj0tZYV5n1LsKRO5osQuitYxGNuzPTy3213sg==",
"path": "system.linq.async/4.0.0",
"hashPath": "system.linq.async.4.0.0.nupkg.sha512"
},
"System.Reflection.Metadata/1.6.0": {
"type": "package",
"serviceable": true,

View File

@ -1 +1 @@
139961083
1746945455

View File

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("FabApprovalWorkerServiceTests")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a2390c83e41ab9bd8767e521b89ac723645aa691")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1a3f0de8a787432164f8346d2c0b0d71a7c7885a")]
[assembly: System.Reflection.AssemblyProductAttribute("FabApprovalWorkerServiceTests")]
[assembly: System.Reflection.AssemblyTitleAttribute("FabApprovalWorkerServiceTests")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
6078bbecd34e7eba6707e829fc154152e69a093327c0952b3ca71c9703f3c89c
fe5a15ae144da7072102d9b190cc119b988da084de26c128bdef2c0864ba0c04

View File

@ -1 +1 @@
144de9080ebc56e38e826b84feddde40f11dc8b73bb346233aac4dd42afdcb36
c71a4935f78260bfb9f152472d70ed9d614a94e9b67b45605a1e4e2c688f4033

View File

@ -150,3 +150,5 @@ C:\Users\tuckerc\FabApprovalWorkerService\FabApprovalWorkerServiceTests\obj\Debu
C:\Users\tuckerc\FabApprovalWorkerService\FabApprovalWorkerServiceTests\obj\Debug\net8.0\FabApprovalWorkerServiceTests.pdb
C:\Users\tuckerc\FabApprovalWorkerService\FabApprovalWorkerServiceTests\obj\Debug\net8.0\FabApprovalWorkerServiceTests.genruntimeconfig.cache
C:\Users\tuckerc\FabApprovalWorkerService\FabApprovalWorkerServiceTests\obj\Debug\net8.0\ref\FabApprovalWorkerServiceTests.dll
C:\Users\tuckerc\FabApprovalWorkerService\FabApprovalWorkerServiceTests\bin\Debug\net8.0\CsvHelper.dll
C:\Users\tuckerc\FabApprovalWorkerService\FabApprovalWorkerServiceTests\bin\Debug\net8.0\System.Linq.Async.dll

View File

@ -147,6 +147,10 @@
"net8.0": {
"targetAlias": "net8.0",
"dependencies": {
"CsvHelper": {
"target": "Package",
"version": "[31.0.0, )"
},
"Dapper": {
"target": "Package",
"version": "[2.1.28, )"

View File

@ -24,6 +24,22 @@
"build/netstandard1.0/coverlet.collector.targets": {}
}
},
"CsvHelper/31.0.0": {
"type": "package",
"dependencies": {
"System.Linq.Async": "4.0.0"
},
"compile": {
"lib/net8.0/CsvHelper.dll": {
"related": ".xml"
}
},
"runtime": {
"lib/net8.0/CsvHelper.dll": {
"related": ".xml"
}
}
},
"Dapper/2.1.28": {
"type": "package",
"compile": {
@ -1182,6 +1198,19 @@
}
}
},
"System.Linq.Async/4.0.0": {
"type": "package",
"compile": {
"ref/netcoreapp3.0/System.Linq.Async.dll": {
"related": ".xml"
}
},
"runtime": {
"lib/netcoreapp3.0/System.Linq.Async.dll": {
"related": ".xml"
}
}
},
"System.Reflection.Metadata/1.6.0": {
"type": "package",
"compile": {
@ -1286,6 +1315,7 @@
"type": "project",
"framework": ".NETCoreApp,Version=v8.0",
"dependencies": {
"CsvHelper": "31.0.0",
"Dapper": "2.1.28",
"Dapper.Contrib": "2.0.78",
"Microsoft.Extensions.Hosting": "8.0.0",
@ -1380,6 +1410,34 @@
"coverlet.collector.nuspec"
]
},
"CsvHelper/31.0.0": {
"sha512": "PypRJq7AugnCJjq6Zu5EqFDTfRv7Gh+MtSH2T/kwiGmg1UHAflq4cE8j3uMkvXSxaayVtcwi+8hC0w+30YzzWA==",
"type": "package",
"path": "csvhelper/31.0.0",
"files": [
".nupkg.metadata",
".signature.p7s",
"Icon.png",
"csvhelper.31.0.0.nupkg.sha512",
"csvhelper.nuspec",
"lib/net462/CsvHelper.dll",
"lib/net462/CsvHelper.xml",
"lib/net47/CsvHelper.dll",
"lib/net47/CsvHelper.xml",
"lib/net48/CsvHelper.dll",
"lib/net48/CsvHelper.xml",
"lib/net6.0/CsvHelper.dll",
"lib/net6.0/CsvHelper.xml",
"lib/net7.0/CsvHelper.dll",
"lib/net7.0/CsvHelper.xml",
"lib/net8.0/CsvHelper.dll",
"lib/net8.0/CsvHelper.xml",
"lib/netstandard2.0/CsvHelper.dll",
"lib/netstandard2.0/CsvHelper.xml",
"lib/netstandard2.1/CsvHelper.dll",
"lib/netstandard2.1/CsvHelper.xml"
]
},
"Dapper/2.1.28": {
"sha512": "ha49pzOEDmCPkMxwfPSR/wxa/6RD3r42TESIgpzpi7FXq/gNVUuJVEO+wtUzntNRhtmq3BKCl0s0aAlSZLkBUA==",
"type": "package",
@ -3174,6 +3232,33 @@
"useSharedDesignerContext.txt"
]
},
"System.Linq.Async/4.0.0": {
"sha512": "WbiYEedFZeM+psmMyoCt1AKbZppAZg8Eq1ZTQ+521fGNeXqlgJj0tZYV5n1LsKRO5osQuitYxGNuzPTy3213sg==",
"type": "package",
"path": "system.linq.async/4.0.0",
"files": [
".nupkg.metadata",
".signature.p7s",
"lib/net461/System.Linq.Async.dll",
"lib/net461/System.Linq.Async.xml",
"lib/netcoreapp3.0/System.Linq.Async.dll",
"lib/netcoreapp3.0/System.Linq.Async.xml",
"lib/netstandard2.0/System.Linq.Async.dll",
"lib/netstandard2.0/System.Linq.Async.xml",
"lib/netstandard2.1/System.Linq.Async.dll",
"lib/netstandard2.1/System.Linq.Async.xml",
"ref/net461/System.Linq.Async.dll",
"ref/net461/System.Linq.Async.xml",
"ref/netcoreapp3.0/System.Linq.Async.dll",
"ref/netcoreapp3.0/System.Linq.Async.xml",
"ref/netstandard2.0/System.Linq.Async.dll",
"ref/netstandard2.0/System.Linq.Async.xml",
"ref/netstandard2.1/System.Linq.Async.dll",
"ref/netstandard2.1/System.Linq.Async.xml",
"system.linq.async.4.0.0.nupkg.sha512",
"system.linq.async.nuspec"
]
},
"System.Reflection.Metadata/1.6.0": {
"sha512": "COC1aiAJjCoA5GBF+QKL2uLqEBew4JsCkQmoHKbN3TlOZKa2fKLz5CpiRQKDz0RsAOEGsVKqOD5bomsXq/4STQ==",
"type": "package",

View File

@ -1,11 +1,12 @@
{
"version": 2,
"dgSpecHash": "cNiQqwBqo4pgfcwIzjgEdK0Qt5Yz+13OJZ8sqx2vQ1BwK1/MHWtPLOeuWe74iUwBIVZuDG5sxcYbYLkUkN5naw==",
"dgSpecHash": "pEQzZHVXDq0XPy0uEZPKE3+A9GB/wOA0vmChqnnFwnGoJdbESnO+PsRpUjbhUGxZ9vcsFnJWYuOpnt/dAbDTyg==",
"success": true,
"projectFilePath": "C:\\Users\\tuckerc\\FabApprovalWorkerService\\FabApprovalWorkerServiceTests\\FabApprovalWorkerServiceTests.csproj",
"expectedPackageFiles": [
"C:\\Users\\tuckerc\\.nuget\\packages\\castle.core\\5.1.1\\castle.core.5.1.1.nupkg.sha512",
"C:\\Users\\tuckerc\\.nuget\\packages\\coverlet.collector\\6.0.0\\coverlet.collector.6.0.0.nupkg.sha512",
"C:\\Users\\tuckerc\\.nuget\\packages\\csvhelper\\31.0.0\\csvhelper.31.0.0.nupkg.sha512",
"C:\\Users\\tuckerc\\.nuget\\packages\\dapper\\2.1.28\\dapper.2.1.28.nupkg.sha512",
"C:\\Users\\tuckerc\\.nuget\\packages\\dapper.contrib\\2.0.78\\dapper.contrib.2.0.78.nupkg.sha512",
"C:\\Users\\tuckerc\\.nuget\\packages\\microsoft.codecoverage\\17.8.0\\microsoft.codecoverage.17.8.0.nupkg.sha512",
@ -58,6 +59,7 @@
"C:\\Users\\tuckerc\\.nuget\\packages\\system.data.sqlclient\\4.8.6\\system.data.sqlclient.4.8.6.nupkg.sha512",
"C:\\Users\\tuckerc\\.nuget\\packages\\system.diagnostics.diagnosticsource\\8.0.0\\system.diagnostics.diagnosticsource.8.0.0.nupkg.sha512",
"C:\\Users\\tuckerc\\.nuget\\packages\\system.diagnostics.eventlog\\8.0.0\\system.diagnostics.eventlog.8.0.0.nupkg.sha512",
"C:\\Users\\tuckerc\\.nuget\\packages\\system.linq.async\\4.0.0\\system.linq.async.4.0.0.nupkg.sha512",
"C:\\Users\\tuckerc\\.nuget\\packages\\system.reflection.metadata\\1.6.0\\system.reflection.metadata.1.6.0.nupkg.sha512",
"C:\\Users\\tuckerc\\.nuget\\packages\\system.security.accesscontrol\\4.7.0\\system.security.accesscontrol.4.7.0.nupkg.sha512",
"C:\\Users\\tuckerc\\.nuget\\packages\\system.security.principal.windows\\4.7.0\\system.security.principal.windows.4.7.0.nupkg.sha512",