diff --git a/North_Bridge/North_Bridge_BusinessLogics/Implementations/PostBusinessLogicContract.cs b/North_Bridge/North_Bridge_BusinessLogics/Implementations/PostBusinessLogicContract.cs index e1264f2..52c098a 100644 --- a/North_Bridge/North_Bridge_BusinessLogics/Implementations/PostBusinessLogicContract.cs +++ b/North_Bridge/North_Bridge_BusinessLogics/Implementations/PostBusinessLogicContract.cs @@ -2,45 +2,96 @@ using Microsoft.Extensions.Logging; using North_Bridge_Contract.BusinessLogicsContracts; using North_Bridge_Contract.DataModels; -using North_Bridge_Contract.Enums; +using North_Bridge_Contract.Exceptions; +using North_Bridge_Contract.Extentions; using North_Bridge_Contract.StoragesContracts; +using System.Text.Json; namespace North_Bridge_BusinessLogics.Implementations; internal class PostBusinessLogicContract(IPostStorageContract postStorageContract, ILogger logger) : IPostBusinessLogicContract { private readonly ILogger _logger = logger; - + private readonly IPostStorageContract _postStorageContract = postStorageContract; - + public List GetAllPosts(bool onlyActive = true) { - return []; + _logger.LogInformation("GetAllPosts params: {onlyActive}", onlyActive); + return _postStorageContract.GetList(onlyActive) ?? throw new + NullListException(); } public List GetAllDataOfPost(string postId) { - return []; + _logger.LogInformation("GetAllDataOfPost for {postId}", postId); + if (postId.IsEmpty()) + { + throw new ArgumentNullException(nameof(postId)); + } + if (!postId.IsGuid()) + { + throw new ValidationException("The value in the field postId is not a unique identifier."); + } + return _postStorageContract.GetPostWithHistory(postId) ?? throw new NullListException(); } public PostDataModel GetPostByData(string data) { - return new("", "", PostType.None, 0, true, DateTime.UtcNow); + _logger.LogInformation("Get element by data: {data}", data); + if (data.IsEmpty()) + { + throw new ArgumentNullException(nameof(data)); + } + if (data.IsGuid()) + { + return _postStorageContract.GetElementById(data) ?? throw new + ElementNotFoundException(data); + } + return _postStorageContract.GetElementByName(data) ?? throw new + ElementNotFoundException(data); } public void InsertPost(PostDataModel postDataModel) { + _logger.LogInformation("New data: {json}", + JsonSerializer.Serialize(postDataModel)); + ArgumentNullException.ThrowIfNull(postDataModel); + postDataModel.Validate(); + _postStorageContract.AddElement(postDataModel); } - public void UpdatePost(PostDataModel postDataModel) { + _logger.LogInformation("Update data: {json}", + JsonSerializer.Serialize(postDataModel)); + ArgumentNullException.ThrowIfNull(postDataModel); + postDataModel.Validate(); + _postStorageContract.UpdElement(postDataModel); } - public void DeletePost(string id) { + _logger.LogInformation("Delete by id: {id}", id); + if (id.IsEmpty()) + { + throw new ArgumentNullException(nameof(id)); + } + if (!id.IsGuid()) + { + throw new ValidationException("Id is not a unique identifier"); + } + _postStorageContract.DelElement(id); } - public void RestorePost(string id) { + _logger.LogInformation("Restore by id: {id}", id); + if (id.IsEmpty()) + { + throw new ArgumentNullException(nameof(id)); + } + if (!id.IsGuid()) + { + throw new ValidationException("Id is not a unique identifier"); + } + _postStorageContract.ResElement(id); } } \ No newline at end of file diff --git a/North_Bridge/North_Bridge_BusinessLogics/Implementations/ProductBusinessLogicContract.cs b/North_Bridge/North_Bridge_BusinessLogics/Implementations/ProductBusinessLogicContract.cs index 7d8860d..09a697a 100644 --- a/North_Bridge/North_Bridge_BusinessLogics/Implementations/ProductBusinessLogicContract.cs +++ b/North_Bridge/North_Bridge_BusinessLogics/Implementations/ProductBusinessLogicContract.cs @@ -3,6 +3,9 @@ using North_Bridge_Contract.DataModels; using North_Bridge_Contract.Enums; using North_Bridge_Contract.StoragesContracts; using Microsoft.Extensions.Logging; +using North_Bridge_Contract.Exceptions; +using North_Bridge_Contract.Extentions; +using System.Text.Json; namespace North_Bridge_BusinessLogics.Implementations; @@ -14,28 +17,71 @@ internal class ProductBusinessLogicContract(IProductStorageContract productStora public List GetAllProducts(bool onlyActive) { - return []; + _logger.LogInformation("GetAllProducts params: {onlyActive}", onlyActive); + return _productStorageContract.GetList(onlyActive) ?? throw new + NullListException(); } - + public List GetProductHistoryByProduct(string productId) { - return []; + _logger.LogInformation("GetProductHistoryByProduct for {productId}", productId); + if (productId.IsEmpty()) + { + throw new ArgumentNullException(nameof(productId)); + } + if (!productId.IsGuid()) + { + throw new ValidationException("The value in the field productId is not a unique identifier."); + } + return _productStorageContract.GetHistoryByProductId(productId) ?? throw new NullListException(); } public ProductDataModel GetProductByData(string data) { - return new("", "", ProductType.None, 0, true); + _logger.LogInformation("Get element by data: {data}", data); + if (data.IsEmpty()) + { + throw new ArgumentNullException(nameof(data)); + } + if (data.IsGuid()) + { + return _productStorageContract.GetElementById(data) ?? throw + new ElementNotFoundException(data); + } + return _productStorageContract.GetElementByName(data) ?? throw new + ElementNotFoundException(data); } - + public void InsertProduct(ProductDataModel productDataModel) { + _logger.LogInformation("New data: {json}", + JsonSerializer.Serialize(productDataModel)); + ArgumentNullException.ThrowIfNull(productDataModel); + productDataModel.Validate(); + _productStorageContract.AddElement(productDataModel); + } - + public void UpdateProduct(ProductDataModel productDataModel) { + _logger.LogInformation("Update data: {json}", + JsonSerializer.Serialize(productDataModel)); + ArgumentNullException.ThrowIfNull(productDataModel); + productDataModel.Validate(); + _productStorageContract.UpdElement(productDataModel); } public void DeleteProduct(string id) { + _logger.LogInformation("Delete by id: {id}", id); + if (id.IsEmpty()) + { + throw new ArgumentNullException(nameof(id)); + } + if (!id.IsGuid()) + { + throw new ValidationException("Id is not a unique identifier"); + } + _productStorageContract.DelElement(id); } } \ No newline at end of file diff --git a/North_Bridge/North_Bridge_BusinessLogics/Implementations/SalaryBusinessLogicContract.cs b/North_Bridge/North_Bridge_BusinessLogics/Implementations/SalaryBusinessLogicContract.cs index a03e27b..d257bf6 100644 --- a/North_Bridge/North_Bridge_BusinessLogics/Implementations/SalaryBusinessLogicContract.cs +++ b/North_Bridge/North_Bridge_BusinessLogics/Implementations/SalaryBusinessLogicContract.cs @@ -2,6 +2,8 @@ using North_Bridge_Contract.DataModels; using North_Bridge_Contract.StoragesContracts; using Microsoft.Extensions.Logging; +using North_Bridge_Contract.Exceptions; +using North_Bridge_Contract.Extentions; namespace North_Bridge_BusinessLogics.Implementations; @@ -17,19 +19,53 @@ internal class SalaryBusinessLogicContract(ISalaryStorageContract salaryStorageC private readonly IWorkerStorageContract _workerStorageContract = workerStorageContract; - public List GetAllSalariesByPeriod(DateTime fromDate, - DateTime toDate) + public List GetAllSalariesByPeriod(DateTime fromDate, DateTime toDate) { - return []; + _logger.LogInformation("GetAllSalaries params: {fromDate}, {toDate}", fromDate, toDate); + if (fromDate.IsDateNotOlder(toDate)) + { + throw new IncorrectDatesException(fromDate, toDate); + } + return _salaryStorageContract.GetList(fromDate, toDate) ?? throw new + NullListException(); } - public List GetAllSalariesByPeriodByWorker(DateTime - fromDate, DateTime toDate, string workerId) + public List GetAllSalariesByPeriodByWorker(DateTime fromDate, DateTime toDate, string workerId) { - return []; + if (fromDate.IsDateNotOlder(toDate)) + { + throw new IncorrectDatesException(fromDate, toDate); + } + if (workerId.IsEmpty()) + { + throw new ArgumentNullException(nameof(workerId)); + } + if (!workerId.IsGuid()) + { + throw new ValidationException("The value in the field workerId is not a unique identifier."); + } + _logger.LogInformation("GetAllSalaries params: {fromDate}, {toDate}, { workerId}", fromDate, toDate, workerId); + return _salaryStorageContract.GetList(fromDate, toDate, workerId) ?? + throw new NullListException(); } public void CalculateSalaryByMounth(DateTime date) { + _logger.LogInformation("CalculateSalaryByMounth: {date}", date); + var startDate = new DateTime(date.Year, date.Month, 1); + var finishDate = new DateTime(date.Year, date.Month, + DateTime.DaysInMonth(date.Year, date.Month)); + var workers = _workerStorageContract.GetList() ?? throw new NullListException(); + foreach (var worker in workers) + { + var sales = _saleStorageContract.GetList(startDate, + finishDate, workerId: worker.Id)?.Sum(x => x.Sum) ?? + throw new NullListException(); + var post = _postStorageContract.GetElementById(worker.PostId) + ?? throw new NullListException(); + var salary = post.Salary + sales * 0.1; + _logger.LogDebug("The employee {workerId} was paid a salary of { salary}", worker.Id, salary); + _salaryStorageContract.AddElement(new SalaryDataModel(worker.Id, finishDate, salary)); + } } } \ No newline at end of file diff --git a/North_Bridge/North_Bridge_BusinessLogics/Implementations/SaleBusinessLogicContract.cs b/North_Bridge/North_Bridge_BusinessLogics/Implementations/SaleBusinessLogicContract.cs index a9a92a8..6e51fd7 100644 --- a/North_Bridge/North_Bridge_BusinessLogics/Implementations/SaleBusinessLogicContract.cs +++ b/North_Bridge/North_Bridge_BusinessLogics/Implementations/SaleBusinessLogicContract.cs @@ -1,7 +1,10 @@ using Microsoft.Extensions.Logging; using North_Bridge_Contract.BusinessLogicsContracts; using North_Bridge_Contract.DataModels; +using North_Bridge_Contract.Exceptions; +using North_Bridge_Contract.Extentions; using North_Bridge_Contract.StoragesContracts; +using System.Text.Json; namespace North_Bridge_BusinessLogics.Implementations; @@ -11,33 +14,89 @@ internal class SaleBusinessLogicContract(ISaleStorageContract saleStorageContrac private readonly ISaleStorageContract _saleStorageContract = saleStorageContract; - public List GetAllSalesByPeriod(DateTime fromDate, DateTime - toDate) + public List GetAllSalesByPeriod(DateTime fromDate, DateTime toDate) { - return []; + _logger.LogInformation("GetAllSales params: {fromDate}, {toDate}", fromDate, toDate); + if (fromDate.IsDateNotOlder(toDate)) + { + throw new IncorrectDatesException(fromDate, toDate); + } + return _saleStorageContract.GetList(fromDate, toDate) ?? throw new + NullListException(); } public List GetAllSalesByWorkerByPeriod(string workerId, DateTime fromDate, DateTime toDate) { - return []; + _logger.LogInformation("GetAllSales params: {workerId}, {fromDate}, { toDate}", workerId, fromDate, toDate); + if (fromDate.IsDateNotOlder(toDate)) + { + throw new IncorrectDatesException(fromDate, toDate); + } + if (workerId.IsEmpty()) + { + throw new ArgumentNullException(nameof(workerId)); + } + if (!workerId.IsGuid()) + { + throw new ValidationException("The value in the field workerId is not a unique identifier."); + } + return _saleStorageContract.GetList(fromDate, toDate, workerId: workerId) ?? throw new NullListException(); } public List GetAllSalesByProductByPeriod(string productId, DateTime fromDate, DateTime toDate) { - return []; + _logger.LogInformation("GetAllSales params: {productId}, {fromDate}, { toDate}", productId, fromDate, toDate); + if (fromDate.IsDateNotOlder(toDate)) + { + throw new IncorrectDatesException(fromDate, toDate); + } + if (productId.IsEmpty()) + { + throw new ArgumentNullException(nameof(productId)); + } + if (!productId.IsGuid()) + { + throw new ValidationException("The value in the field productId is not a unique identifier."); + } + return _saleStorageContract.GetList(fromDate, toDate, productId: productId) ?? throw new NullListException(); } public SaleDataModel GetSaleByData(string data) { - return new("", "", 0, false, []); + _logger.LogInformation("Get element by data: {data}", data); + if (data.IsEmpty()) + { + throw new ArgumentNullException(nameof(data)); + } + if (!data.IsGuid()) + { + throw new ValidationException("Id is not a unique identifier"); + } + return _saleStorageContract.GetElementById(data) ?? throw new + ElementNotFoundException(data); } public void InsertSale(SaleDataModel saleDataModel) { + _logger.LogInformation("New data: {json}", + JsonSerializer.Serialize(saleDataModel)); + ArgumentNullException.ThrowIfNull(saleDataModel); + saleDataModel.Validate(); + _saleStorageContract.AddElement(saleDataModel); } public void CancelSale(string id) { + _logger.LogInformation("Cancel by id: {id}", id); + if (id.IsEmpty()) + { + throw new ArgumentNullException(nameof(id)); + } + if (!id.IsGuid()) + { + throw new ValidationException("Id is not a unique identifier"); + } + _saleStorageContract.DelElement(id); } } \ No newline at end of file diff --git a/North_Bridge/North_Bridge_BusinessLogics/Implementations/WorkerBusinessLogicContract.cs b/North_Bridge/North_Bridge_BusinessLogics/Implementations/WorkerBusinessLogicContract.cs index c961f08..33d9c3c 100644 --- a/North_Bridge/North_Bridge_BusinessLogics/Implementations/WorkerBusinessLogicContract.cs +++ b/North_Bridge/North_Bridge_BusinessLogics/Implementations/WorkerBusinessLogicContract.cs @@ -1,7 +1,10 @@ using Microsoft.Extensions.Logging; using North_Bridge_Contract.BusinessLogicsContracts; using North_Bridge_Contract.DataModels; +using North_Bridge_Contract.Exceptions; +using North_Bridge_Contract.Extentions; using North_Bridge_Contract.StoragesContracts; +using System.Text.Json; namespace North_Bridge_BusinessLogics.Implementations; @@ -13,39 +16,92 @@ internal class WorkerBusinessLogicContract(IWorkerStorageContract workerStorageC public List GetAllWorkers(bool onlyActive = true) { - return []; + _logger.LogInformation("GetAllWorkers params: {onlyActive}", onlyActive); + return _workerStorageContract.GetList(onlyActive) ?? throw new NullListException(); } - + public List GetAllWorkersByPost(string postId, bool onlyActive = true) { - return []; + _logger.LogInformation("GetAllWorkers params: {postId}, { onlyActive},", postId, onlyActive); + if (postId.IsEmpty()) + { + throw new ArgumentNullException(nameof(postId)); + } + if (!postId.IsGuid()) + { + throw new ValidationException("The value in the field postId is not a unique identifier."); + } + return _workerStorageContract.GetList(onlyActive, postId) ?? throw new NullListException(); } - + public List GetAllWorkersByBirthDate(DateTime fromDate, DateTime toDate, bool onlyActive = true) { - return []; + _logger.LogInformation("GetAllWorkers params: {onlyActive}, { fromDate}, { toDate}", onlyActive, fromDate, toDate); + if (fromDate.IsDateNotOlder(toDate)) + { + throw new IncorrectDatesException(fromDate, toDate); + } + return _workerStorageContract.GetList(onlyActive, fromBirthDate: + fromDate, toBirthDate: toDate) ?? throw new NullListException(); } - + public List GetAllWorkersByEmploymentDate(DateTime fromDate, DateTime toDate, bool onlyActive = true) { - return []; + _logger.LogInformation("GetAllWorkers params: {onlyActive}, { fromDate}, { toDate}", onlyActive, fromDate, toDate); + if (fromDate.IsDateNotOlder(toDate)) + { + throw new IncorrectDatesException(fromDate, toDate); + } + return _workerStorageContract.GetList(onlyActive, fromEmploymentDate: + fromDate, toEmploymentDate: toDate) ?? throw new NullListException(); } - + public WorkerDataModel GetWorkerByData(string data) { - return new("", "", "", "", DateTime.Now, DateTime.Now, true); + _logger.LogInformation("Get element by data: {data}", data); + if (data.IsEmpty()) + { + throw new ArgumentNullException(nameof(data)); + } + if (data.IsGuid()) + { + return _workerStorageContract.GetElementById(data) ?? throw + new ElementNotFoundException(data); + } + return _workerStorageContract.GetElementByFIO(data) ?? throw new + ElementNotFoundException(data); } public void InsertWorker(WorkerDataModel workerDataModel) { + _logger.LogInformation("New data: {json}", + JsonSerializer.Serialize(workerDataModel)); + ArgumentNullException.ThrowIfNull(workerDataModel); + workerDataModel.Validate(); + _workerStorageContract.AddElement(workerDataModel); } public void UpdateWorker(WorkerDataModel workerDataModel) { + _logger.LogInformation("Update data: {json}", + JsonSerializer.Serialize(workerDataModel)); + ArgumentNullException.ThrowIfNull(workerDataModel); + workerDataModel.Validate(); + _workerStorageContract.UpdElement(workerDataModel); } public void DeleteWorker(string id) { + _logger.LogInformation("Delete by id: {id}", id); + if (id.IsEmpty()) + { + throw new ArgumentNullException(nameof(id)); + } + if (!id.IsGuid()) + { + throw new ValidationException("Id is not a unique identifier"); + } + _workerStorageContract.DelElement(id); } } \ No newline at end of file diff --git a/North_Bridge/North_Bridge_Contract/DataModels/WorkerDataModel.cs b/North_Bridge/North_Bridge_Contract/DataModels/WorkerDataModel.cs index b09cd89..cf18981 100644 --- a/North_Bridge/North_Bridge_Contract/DataModels/WorkerDataModel.cs +++ b/North_Bridge/North_Bridge_Contract/DataModels/WorkerDataModel.cs @@ -20,7 +20,7 @@ public class WorkerDataModel : IValidation public bool IsDeleted { get; private set; } - public WorkerDataModel(string id, string email, string fio, string postId, DateTime birthDate, DateTime employmentDate, bool isDeleted) + public WorkerDataModel(string id, string fio, string email, string postId, DateTime birthDate, DateTime employmentDate, bool isDeleted) { Id = id; FIO = fio; @@ -42,22 +42,25 @@ public class WorkerDataModel : IValidation if (FIO.IsEmpty()) throw new ValidationException("Field FIO is empty"); + if (Email.IsEmpty()) + throw new ValidationException("Field Email is empty"); + + if (!Regex.IsMatch(Email, @"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$")) + throw new ValidationException("Field Email is not a valid email address"); + if (PostId.IsEmpty()) throw new ValidationException("Field PostId is empty"); if (!PostId.IsGuid()) throw new ValidationException("The value in the field PostId is not a unique identifier"); - if (BirthDate.Date > DateTime.Now.AddYears(-16).Date) - throw new ValidationException($"Minors cannot be hired (BirthDate = { BirthDate.ToShortDateString() })"); + if (BirthDate.Date > DateTime.Now.AddYears(-18).Date) + throw new ValidationException($"Only adults can be hired (BirthDate = {BirthDate.ToShortDateString()})"); if (EmploymentDate.Date < BirthDate.Date) throw new ValidationException("The date of employment cannot be less than the date of birth"); - if ((EmploymentDate - BirthDate).TotalDays / 365 < 16) // EmploymentDate.Year - BirthDate.Year - throw new ValidationException($"Minors cannot be hired (EmploymentDate - { EmploymentDate.ToShortDateString() }, BirthDate - { BirthDate.ToShortDateString()})"); - - if (!Regex.IsMatch(Email, @"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$")) // example@example.com - throw new ValidationException("Field Email is not a email"); + if ((EmploymentDate - BirthDate).TotalDays / 365 < 18) + throw new ValidationException($"Only adults can be hired (EmploymentDate - {EmploymentDate.ToShortDateString()}, BirthDate - {BirthDate.ToShortDateString()})"); } } \ No newline at end of file diff --git a/North_Bridge/North_Bridge_Tests/BusinessLogicsContractsTests/WorkerBusinessLogicContractTests.cs b/North_Bridge/North_Bridge_Tests/BusinessLogicsContractsTests/WorkerBusinessLogicContractTests.cs index f6b9cd0..4af01f8 100644 --- a/North_Bridge/North_Bridge_Tests/BusinessLogicsContractsTests/WorkerBusinessLogicContractTests.cs +++ b/North_Bridge/North_Bridge_Tests/BusinessLogicsContractsTests/WorkerBusinessLogicContractTests.cs @@ -583,7 +583,7 @@ internal class WorkerBusinessLogicContractTests //Arrange var flag = false; var record = new WorkerDataModel(Guid.NewGuid().ToString(), "fio", "example@example.com", - Guid.NewGuid().ToString(), DateTime.Now.AddYears(-16).AddDays(-1), DateTime.Now, + Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18).AddDays(-1), DateTime.Now, false); _workerStorageContract.Setup(x => x.AddElement(It.IsAny())) @@ -612,7 +612,7 @@ internal class WorkerBusinessLogicContractTests //Act&Assert Assert.That(() => _workerBusinessLogicContract.InsertWorker(new(Guid.NewGuid().ToString(), "fio", "example@example.com", - Guid.NewGuid().ToString(), DateTime.Now.AddYears(-16).AddDays(-1), DateTime.Now, + Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18).AddDays(-1), DateTime.Now, false)), Throws.TypeOf()); _workerStorageContract.Verify(x => x.AddElement(It.IsAny()), Times.Once); @@ -649,7 +649,7 @@ internal class WorkerBusinessLogicContractTests //Act&Assert Assert.That(() => _workerBusinessLogicContract.InsertWorker(new(Guid.NewGuid().ToString(), "fio", "example@example.com", - Guid.NewGuid().ToString(), DateTime.Now.AddYears(-16).AddDays(-1), DateTime.Now, + Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18).AddDays(-1), DateTime.Now, false)), Throws.TypeOf()); _workerStorageContract.Verify(x => x.AddElement(It.IsAny()), Times.Once); @@ -661,7 +661,7 @@ internal class WorkerBusinessLogicContractTests //Arrange var flag = false; var record = new WorkerDataModel(Guid.NewGuid().ToString(), "fio", "example@example.com", - Guid.NewGuid().ToString(), DateTime.Now.AddYears(-16).AddDays(-1), DateTime.Now, + Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18).AddDays(-1), DateTime.Now, false); _workerStorageContract.Setup(x => x.UpdElement(It.IsAny())) @@ -690,7 +690,7 @@ internal class WorkerBusinessLogicContractTests //Act&Assert Assert.That(() => _workerBusinessLogicContract.UpdateWorker(new(Guid.NewGuid().ToString(), "fio", "example@example.com", - Guid.NewGuid().ToString(), DateTime.Now.AddYears(-16).AddDays(-1), DateTime.Now, + Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18).AddDays(-1), DateTime.Now, false)), Throws.TypeOf()); _workerStorageContract.Verify(x => x.UpdElement(It.IsAny()), Times.Once); @@ -727,7 +727,7 @@ internal class WorkerBusinessLogicContractTests //Act&Assert Assert.That(() => _workerBusinessLogicContract.UpdateWorker(new(Guid.NewGuid().ToString(), "fio", "example@example.com", - Guid.NewGuid().ToString(), DateTime.Now.AddYears(-16).AddDays(-1), DateTime.Now, + Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18).AddDays(-1), DateTime.Now, false)), Throws.TypeOf()); _workerStorageContract.Verify(x => x.UpdElement(It.IsAny()), Times.Once); diff --git a/North_Bridge/North_Bridge_Tests/DataModelsTests/WorkerDataModelTests.cs b/North_Bridge/North_Bridge_Tests/DataModelsTests/WorkerDataModelTests.cs index 751a89c..0baf001 100644 --- a/North_Bridge/North_Bridge_Tests/DataModelsTests/WorkerDataModelTests.cs +++ b/North_Bridge/North_Bridge_Tests/DataModelsTests/WorkerDataModelTests.cs @@ -99,26 +99,26 @@ internal class WorkerDataModelTests { var workerId = Guid.NewGuid().ToString(); var fio = "fio"; - var email = "example@example.com"; + var Email = "example@example.com"; var postId = Guid.NewGuid().ToString(); - var birthDate = DateTime.Now.AddYears(-16).AddDays(-1); + var birthDate = DateTime.Now.AddYears(-18).AddDays(-1); var employmentDate = DateTime.Now; var isDelete = false; - var worker = CreateDataModel(workerId, fio, email, postId, birthDate, employmentDate, isDelete); + var worker = CreateDataModel(workerId, fio, Email, postId, birthDate, employmentDate, isDelete); Assert.That(() => worker.Validate(), Throws.Nothing); Assert.Multiple(() => { Assert.That(worker.Id, Is.EqualTo(workerId)); Assert.That(worker.FIO, Is.EqualTo(fio)); - Assert.That(worker.Email, Is.EqualTo(email)); + Assert.That(worker.Email, Is.EqualTo(Email)); Assert.That(worker.PostId, Is.EqualTo(postId)); Assert.That(worker.BirthDate, Is.EqualTo(birthDate)); - Assert.That(worker.EmploymentDate,Is.EqualTo(employmentDate)); + Assert.That(worker.EmploymentDate, Is.EqualTo(employmentDate)); Assert.That(worker.IsDeleted, Is.EqualTo(isDelete)); }); } - private static WorkerDataModel CreateDataModel(string? id, string? fio, string email, + private static WorkerDataModel CreateDataModel(string? id, string? fio, string? email, string? postId, DateTime birthDate, DateTime employmentDate, bool isDeleted) => new(id, fio, email, postId, birthDate, employmentDate, isDeleted); } \ No newline at end of file