diff --git a/.gitignore b/.gitignore index ca1c7a3..2578d88 100644 --- a/.gitignore +++ b/.gitignore @@ -397,4 +397,4 @@ FodyWeavers.xsd # JetBrains Rider *.sln.iml - +*/*.idea \ No newline at end of file diff --git a/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/ClientDataModel.cs b/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/ClientDataModel.cs index 54f2779..74960d7 100644 --- a/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/ClientDataModel.cs +++ b/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/ClientDataModel.cs @@ -20,17 +20,17 @@ public class ClientDataModel(string id, string fio, string phoneNumber) : IValid public void Validate() { - if (id.isEmpty()) + if (Id.isEmpty()) throw new ValidationFieldException("Field Id is empty"); - if (!id.isGuid()) + if (!Id.isGuid()) throw new ValidationFieldException("The value in the field Id is not a unique identifier"); if (FIO.isEmpty()) throw new ValidationFieldException("Field FIO is empty"); - if (!Regex.IsMatch(FIO, @"^[A-ZА-ЯЁ][a-zа-яё]+ [A-ZА-ЯЁ][a-zа-яё]+ [A-ZA-ЯЁ][a-zа-яё]+$")) - throw new ValidationFieldException("Field FIO is not a fio"); + if (!Regex.IsMatch(FIO, @"^[A-ZА-ЯЁ][a-zа-яё]+(?:-[A-ZА-ЯЁ][a-zа-яё]+)?\s[A-ZА-ЯЁ][a-zа-яё]+(?:-[A-ZА-ЯЁ][a-zа-яё]+)?\s[A-ZА-ЯЁ][a-zа-яё]+(?:-[A-ZА-ЯЁ][a-zа-яё]+)?$")) + throw new ValidationFieldException("Field FIO is not a valid full name."); if (PhoneNumber.isEmpty()) throw new ValidationFieldException("Field PhoneNumber is empty"); diff --git a/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/CompanyDataModel.cs b/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/CompanyDataModel.cs index 5fc8066..135ad43 100644 --- a/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/CompanyDataModel.cs +++ b/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/CompanyDataModel.cs @@ -11,12 +11,17 @@ using System.Threading.Tasks; namespace SoftwareInstallationContracts.DataModels; -public class CompanyDataModel(string id, string companyName, string prevCompanyName, string prevPrevCompanyName) : IValidation +public class CompanyDataModel(string id, string companyName, string prevCompanyName, + string prevPrevCompanyName) : IValidation { public string Id { get; private set; } = id; + public string CompanyName { get; private set; } = companyName; + public string? PrevCompanyName { get; private set; } = prevCompanyName; + public string? PrevPrevCompanyName { get; private set; } = prevPrevCompanyName; + public void Validate() { if (Id.isEmpty()) diff --git a/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/InstallationDataModel.cs b/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/InstallationDataModel.cs index 57af1db..6406171 100644 --- a/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/InstallationDataModel.cs +++ b/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/InstallationDataModel.cs @@ -10,7 +10,8 @@ using System.Threading.Tasks; namespace SoftwareInstallationContracts.DataModels; -public class InstallationDataModel(string id, string workerId, string clientId, double sum, bool isCancel, List programs) : IValidation +public class InstallationDataModel(string id, string workerId, string clientId, + double sum, bool isCancel, List programs) : IValidation { public string Id { get; private set; } = id; @@ -18,7 +19,7 @@ public class InstallationDataModel(string id, string workerId, string clientId, public string? ClientId { get; private set; } = clientId; - public DateTime SaleDate { get; private set; } = DateTime.UtcNow; + public DateTime InstallationDate { get; private set; } = DateTime.UtcNow; public double Sum { get; private set; } = sum; diff --git a/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/InstallationSoftwareDataModel.cs b/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/InstallationSoftwareDataModel.cs index ce61a22..e69e364 100644 --- a/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/InstallationSoftwareDataModel.cs +++ b/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/InstallationSoftwareDataModel.cs @@ -9,11 +9,11 @@ using System.Threading.Tasks; namespace SoftwareInstallationContracts.DataModels; -public class InstallationSoftwareDataModel(string saleId, string programId, int count) : IValidation +public class InstallationSoftwareDataModel(string installationId, string programId, int count) : IValidation { public string ProgramId { get; private set; } = programId; - public string SaleId { get; private set; } = saleId; + public string InstallationId { get; private set; } = installationId; public int Count { get; private set; } = count; @@ -25,11 +25,11 @@ public class InstallationSoftwareDataModel(string saleId, string programId, int if (!ProgramId.isGuid()) throw new ValidationFieldException("The value in the field ProgramId is not a unique identifier"); - if (SaleId.isEmpty()) - throw new ValidationFieldException("Field SaleId is empty"); + if (InstallationId.isEmpty()) + throw new ValidationFieldException("Field InstallationId is empty"); - if (!SaleId.isGuid()) - throw new ValidationFieldException("The value in the field SaleId is not a unique identifier"); + if (!InstallationId.isGuid()) + throw new ValidationFieldException("The value in the field InstallationId is not a unique identifier"); if (Count <= 0) throw new ValidationFieldException("Field Count is less than or equal to 0"); diff --git a/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/PostDataModel.cs b/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/PostDataModel.cs index a2f02d8..562ad9f 100644 --- a/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/PostDataModel.cs +++ b/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/PostDataModel.cs @@ -10,7 +10,8 @@ using System.Threading.Tasks; namespace SoftwareInstallationContracts.DataModels; -public class PostDataModel(string id, string postId, string postName, PostType postType, double salary, bool isActual, DateTime changeDate) : IValidation +public class PostDataModel(string id, string postId, string postName, PostType postType, + double salary, bool isActual, DateTime changeDate) : IValidation { public string Id { get; private set; } = id; diff --git a/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/SoftwareDataModel.cs b/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/SoftwareDataModel.cs index bcacf82..6d633be 100644 --- a/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/SoftwareDataModel.cs +++ b/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/SoftwareDataModel.cs @@ -10,7 +10,8 @@ using System.Threading.Tasks; namespace SoftwareInstallationContracts.DataModels; -public class SoftwareDataModel(string id, string softwareName, SoftwareType softwareType, string companyId, double price, bool isDeleted) : IValidation +public class SoftwareDataModel(string id, string softwareName, SoftwareType softwareType, + string companyId, double price, bool isDeleted) : IValidation { public string Id { get; private set; } = id; @@ -33,10 +34,10 @@ public class SoftwareDataModel(string id, string softwareName, SoftwareType soft throw new ValidationFieldException("The value in the field Id is not a unique identifier"); if (SoftwareName.isEmpty()) - throw new ValidationFieldException("Field ProgramName is empty"); + throw new ValidationFieldException("Field SoftwareName is empty"); if (SoftwareType == SoftwareType.None) - throw new ValidationFieldException("Field ProgramType is empty"); + throw new ValidationFieldException("Field SoftwareType is empty"); if (CompanyId.isEmpty()) throw new ValidationFieldException("Field CompanyId is empty"); diff --git a/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/SoftwareHistoryDataModel.cs b/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/SoftwareHistoryDataModel.cs index b0ea582..d3a7cfe 100644 --- a/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/SoftwareHistoryDataModel.cs +++ b/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/SoftwareHistoryDataModel.cs @@ -21,10 +21,10 @@ public class SoftwareHistoryDataModel(string softwareId, double oldPrice) : IVal public void Validate() { if (SoftwareId.isEmpty()) - throw new ValidationFieldException("Field ProgramId is empty"); + throw new ValidationFieldException("Field SoftwareId is empty"); if (!SoftwareId.isGuid()) - throw new ValidationFieldException("The value in the field ProgramId is not a unique identifier"); + throw new ValidationFieldException("The value in the field SoftwareId is not a unique identifier"); if (OldPrice <= 0) throw new ValidationFieldException("Field OldPrice is less than or equal to 0"); diff --git a/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/WorkerDataModel.cs b/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/WorkerDataModel.cs index a0376b7..c752cc2 100644 --- a/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/WorkerDataModel.cs +++ b/SoftwareInstallationContracts/SoftwareInstallationContracts/DataModels/WorkerDataModel.cs @@ -10,13 +10,19 @@ using System.Threading.Tasks; namespace SoftwareInstallationContracts.DataModels; -public class WorkerDataModel(string id, string fio, string postId, DateTime birthDate, DateTime employmentDate, bool isDeleted) : IValidation +public class WorkerDataModel(string id, string fio, string postId, DateTime birthDate, DateTime employmentDate, + bool isDeleted) : IValidation { public string Id { get; private set; } = id; + public string FIO { get; private set; } = fio; + public string PostId { get; private set; } = postId; + public DateTime BirthDate { get; private set; } = birthDate; + public DateTime EmploymentDate { get; private set; } = employmentDate; + public bool IsDeleted { get; private set; } = isDeleted; public void Validate() @@ -43,6 +49,8 @@ public class WorkerDataModel(string id, string fio, string postId, DateTime birt throw new ValidationFieldException("The date of employment cannot be less than the date of birth"); if ((EmploymentDate - BirthDate).TotalDays / 365 < 16) - throw new ValidationFieldException($"Minors cannot be hired (EmploymentDate - {EmploymentDate.ToShortDateString()}, BirthDate - {BirthDate.ToShortDateString()}"); + throw new ValidationFieldException($"Minors cannot be hired " + + $"(EmploymentDate - {EmploymentDate.ToShortDateString()}," + + $" BirthDate - {BirthDate.ToShortDateString()}"); } } diff --git a/SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/ClientDataModelTests.cs b/SoftwareInstallationTests/DataModelsTests/ClientDataModelTests.cs similarity index 79% rename from SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/ClientDataModelTests.cs rename to SoftwareInstallationTests/DataModelsTests/ClientDataModelTests.cs index 98aa58a..cd6d011 100644 --- a/SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/ClientDataModelTests.cs +++ b/SoftwareInstallationTests/DataModelsTests/ClientDataModelTests.cs @@ -16,48 +16,48 @@ internal class ClientDataModelTests [Test] public void IdIsNullOrEmptyTest() { - client = CreateDataModel(null, "fio", "number"); + client = CreateDataModel(null, "Fio Fio Fio", "+7-777-777-77-77"); Assert.That(() => client.Validate(), Throws.TypeOf()); - client = CreateDataModel(string.Empty, "fio", "number"); + client = CreateDataModel(string.Empty, "Fio Fio Fio", "+7-777-777-77-77"); Assert.That(() => client.Validate(), Throws.TypeOf()); } [Test] public void IdIsNotGuidTest() { - client = CreateDataModel("id", "fio", "number"); + client = CreateDataModel("id", "Fio Fio Fio", "+7-777-777-77-77"); Assert.That(() => client.Validate(), Throws.TypeOf()); } [Test] public void FIOIsNullOrEmptyTest() { - client = CreateDataModel(Guid.NewGuid().ToString(), null, "number"); + client = CreateDataModel(Guid.NewGuid().ToString(), null, "+7-777-777-77-77"); Assert.That(() => client.Validate(), Throws.TypeOf()); - client = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, "number"); + client = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, "+7-777-777-77-77"); Assert.That(() => client.Validate(), Throws.TypeOf()); } [Test] public void FIOIsIncorrectTest() { - client = CreateDataModel(Guid.NewGuid().ToString(), "fio", "number"); + client = CreateDataModel(Guid.NewGuid().ToString(), "fio", "+7-777-777-77-77"); Assert.That(() => client.Validate(), Throws.TypeOf()); } [Test] public void PhoneNumberIsNullOrEmptyTest() { - client = CreateDataModel(Guid.NewGuid().ToString(), "fio", null); + client = CreateDataModel(Guid.NewGuid().ToString(), "Fio Fio Fio", null); Assert.That(() => client.Validate(), Throws.TypeOf()); - client = CreateDataModel(Guid.NewGuid().ToString(), "fio", string.Empty); + client = CreateDataModel(Guid.NewGuid().ToString(), "Fio Fio Fio", string.Empty); Assert.That(() => client.Validate(), Throws.TypeOf()); } [Test] public void PhoneNumberIsIncorrectTest() { - client = CreateDataModel(Guid.NewGuid().ToString(), "fio", "777"); + client = CreateDataModel(Guid.NewGuid().ToString(), "Fio Fio Fio", "777"); Assert.That(() => client.Validate(), Throws.TypeOf()); } @@ -65,7 +65,7 @@ internal class ClientDataModelTests public void AllFieldsIsCorrectTest() { string phoneNumber = "+7-777-777-77-77"; - string fio = "Василий Васильевич Васильев"; + string fio = "Vasiliy Vasiliev Vasilievich"; string id = Guid.NewGuid().ToString(); client = CreateDataModel(id, fio, phoneNumber); Assert.That(() => client.Validate(), Throws.Nothing); diff --git a/SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/CompanyDataModelTests.cs b/SoftwareInstallationTests/DataModelsTests/CompanyDataModelTests.cs similarity index 93% rename from SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/CompanyDataModelTests.cs rename to SoftwareInstallationTests/DataModelsTests/CompanyDataModelTests.cs index 18850aa..0f81ed7 100644 --- a/SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/CompanyDataModelTests.cs +++ b/SoftwareInstallationTests/DataModelsTests/CompanyDataModelTests.cs @@ -56,6 +56,6 @@ internal class CompanyDataModelTests }); } - private static CompanyDataModel CreateDataModel(string? id, string? companyName, string? prevcompanyName = null, string? prevPrevcompanyName = null) => - new(id, companyName, prevcompanyName, prevPrevcompanyName); + private static CompanyDataModel CreateDataModel(string? id, string? companyName, string? prevcompanyName = null, + string? prevPrevcompanyName = null) => new(id, companyName, prevcompanyName, prevPrevcompanyName); } diff --git a/SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/InstallationDataModelTests.cs b/SoftwareInstallationTests/DataModelsTests/InstallationDataModelTests.cs similarity index 100% rename from SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/InstallationDataModelTests.cs rename to SoftwareInstallationTests/DataModelsTests/InstallationDataModelTests.cs diff --git a/SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/InstallationSoftwareDataModelTests.cs b/SoftwareInstallationTests/DataModelsTests/InstallationSoftwareDataModelTests.cs similarity index 97% rename from SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/InstallationSoftwareDataModelTests.cs rename to SoftwareInstallationTests/DataModelsTests/InstallationSoftwareDataModelTests.cs index ca9dd3c..a42fbb5 100644 --- a/SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/InstallationSoftwareDataModelTests.cs +++ b/SoftwareInstallationTests/DataModelsTests/InstallationSoftwareDataModelTests.cs @@ -64,7 +64,7 @@ internal class InstallationSoftwareDataModelTests Assert.That(() => installSoftware.Validate(), Throws.Nothing); Assert.Multiple(() => { - Assert.That(installSoftware.SaleId, Is.EqualTo(installId)); + Assert.That(installSoftware.InstallationId, Is.EqualTo(installId)); Assert.That(installSoftware.ProgramId, Is.EqualTo(softwareId)); Assert.That(installSoftware.Count, Is.EqualTo(count)); }); diff --git a/SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/PostDataModelTests.cs b/SoftwareInstallationTests/DataModelsTests/PostDataModelTests.cs similarity index 100% rename from SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/PostDataModelTests.cs rename to SoftwareInstallationTests/DataModelsTests/PostDataModelTests.cs diff --git a/SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/SalaryDataModelTests.cs b/SoftwareInstallationTests/DataModelsTests/SalaryDataModelTests.cs similarity index 95% rename from SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/SalaryDataModelTests.cs rename to SoftwareInstallationTests/DataModelsTests/SalaryDataModelTests.cs index 29b1648..dbdabcc 100644 --- a/SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/SalaryDataModelTests.cs +++ b/SoftwareInstallationTests/DataModelsTests/SalaryDataModelTests.cs @@ -54,5 +54,6 @@ internal class SalaryDataModelTests }); } - private static SalaryDataModel CreateDataModel(string? workerId, DateTime date, double workerSalary) => new(workerId, date, workerSalary); + private static SalaryDataModel CreateDataModel(string? workerId, DateTime date, + double workerSalary) => new(workerId, date, workerSalary); } diff --git a/SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/SoftwareDataModelTests.cs b/SoftwareInstallationTests/DataModelsTests/SoftwareDataModelTests.cs similarity index 100% rename from SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/SoftwareDataModelTests.cs rename to SoftwareInstallationTests/DataModelsTests/SoftwareDataModelTests.cs diff --git a/SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/SoftwareHistoryDataModelTests.cs b/SoftwareInstallationTests/DataModelsTests/SoftwareHistoryDataModelTests.cs similarity index 100% rename from SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/SoftwareHistoryDataModelTests.cs rename to SoftwareInstallationTests/DataModelsTests/SoftwareHistoryDataModelTests.cs diff --git a/SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/SoftwareSupplyDataModelTests.cs b/SoftwareInstallationTests/DataModelsTests/SoftwareSupplyDataModelTests.cs similarity index 100% rename from SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/SoftwareSupplyDataModelTests.cs rename to SoftwareInstallationTests/DataModelsTests/SoftwareSupplyDataModelTests.cs diff --git a/SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/SupplyDataModelTests.cs b/SoftwareInstallationTests/DataModelsTests/SupplyDataModelTests.cs similarity index 100% rename from SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/SupplyDataModelTests.cs rename to SoftwareInstallationTests/DataModelsTests/SupplyDataModelTests.cs diff --git a/SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/WarehouseDataModelTests.cs b/SoftwareInstallationTests/DataModelsTests/WarehouseDataModelTests.cs similarity index 100% rename from SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/WarehouseDataModelTests.cs rename to SoftwareInstallationTests/DataModelsTests/WarehouseDataModelTests.cs diff --git a/SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/WorkerDataModelTests.cs b/SoftwareInstallationTests/DataModelsTests/WorkerDataModelTests.cs similarity index 100% rename from SoftwareInstallationTests/SoftwareInstallationTests/DataModelsTests/WorkerDataModelTests.cs rename to SoftwareInstallationTests/DataModelsTests/WorkerDataModelTests.cs diff --git a/SoftwareInstallationTests/SoftwareInstallationTests/SoftwareInstallationTests.csproj b/SoftwareInstallationTests/SoftwareInstallationTests.csproj similarity index 84% rename from SoftwareInstallationTests/SoftwareInstallationTests/SoftwareInstallationTests.csproj rename to SoftwareInstallationTests/SoftwareInstallationTests.csproj index 561fc18..96c6b73 100644 --- a/SoftwareInstallationTests/SoftwareInstallationTests/SoftwareInstallationTests.csproj +++ b/SoftwareInstallationTests/SoftwareInstallationTests.csproj @@ -17,7 +17,7 @@ - +