Compare commits
4 Commits
main
...
Task_1_Mod
Author | SHA1 | Date | |
---|---|---|---|
ffb5ac4e3c | |||
fa7a9e990e | |||
34d784392f | |||
bf8eece4e6 |
@ -0,0 +1,35 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using PimpMyRideContracts.Exceptions;
|
||||
using PimpMyRideContracts.Extensions;
|
||||
using PimpMyRideContracts.Infrastructure;
|
||||
|
||||
namespace PimpMyRideContracts.DataModels;
|
||||
|
||||
public class CarDataModel(string carId, string carMark, string carModel, string carNumber) : IValidation
|
||||
{
|
||||
public string CarId { get; private set; } = carId;
|
||||
public string CarMark { get; private set; } = carMark;
|
||||
public string CarModel { get; private set; } = carModel;
|
||||
public string CarNumber { get; private set; } = carNumber;
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (CarId.IsEmpty())
|
||||
throw new ValidationException("Field CarId is empty");
|
||||
|
||||
if (!CarId.IsGuid())
|
||||
throw new ValidationException("The value in the field CarId is not a unique identifier");
|
||||
|
||||
if (CarMark.IsEmpty())
|
||||
throw new ValidationException("Field CarMark is empty");
|
||||
|
||||
if (CarModel.IsEmpty())
|
||||
throw new ValidationException("Field CarModel is empty");
|
||||
|
||||
if (CarNumber.IsEmpty())
|
||||
throw new ValidationException("Field CarNumber is empty");
|
||||
|
||||
if (!Regex.IsMatch(CarNumber, @"^[АВЕКМНОРСТУХ]\d{3}(?<!000)[АВЕКМНОРСТУХ]{2}\d{2,3}$"))
|
||||
throw new ValidationException("Field CarNumber is not a car number");
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
using PimpMyRideContracts.Enums;
|
||||
using PimpMyRideContracts.Exceptions;
|
||||
using PimpMyRideContracts.Extensions;
|
||||
using PimpMyRideContracts.Infrastructure;
|
||||
|
||||
namespace PimpMyRideContracts.DataModels;
|
||||
|
||||
public class OperationDataModel(string operationId, OperationType operationType, List<OperationSupplieDataModel> supplies) : IValidation
|
||||
{
|
||||
public string OperationId { get; private set; } = operationId;
|
||||
public OperationType OperationType { get; private set; } = operationType;
|
||||
public List<OperationSupplieDataModel> Supplies { get; private set; } = supplies;
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (OperationId.IsEmpty())
|
||||
throw new ValidationException("Field OperationId is empty");
|
||||
|
||||
if (!OperationId.IsGuid())
|
||||
throw new ValidationException("The value in the field OperationId is not a unique identifier");
|
||||
|
||||
if (OperationType == OperationType.None)
|
||||
throw new ValidationException("Field OperationType is empty");
|
||||
|
||||
if ((Supplies?.Count ?? 0) == 0)
|
||||
throw new ValidationException("The operation must include supplies");
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
using PimpMyRideContracts.Exceptions;
|
||||
using PimpMyRideContracts.Extensions;
|
||||
using PimpMyRideContracts.Infrastructure;
|
||||
|
||||
namespace PimpMyRideContracts.DataModels;
|
||||
|
||||
public class OperationSupplieDataModel(string operationId, string supplieId, int supplieCount) : IValidation
|
||||
{
|
||||
public string OperationId { get; private set; } = operationId;
|
||||
public string SupplieId { get; private set; } = supplieId;
|
||||
public int SupplieCount { get; private set; } = supplieCount;
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (OperationId.IsEmpty())
|
||||
throw new ValidationException("Field OperationId is empty");
|
||||
|
||||
if (!OperationId.IsGuid())
|
||||
throw new ValidationException("The value in the field OperationId is not a unique identifier");
|
||||
|
||||
if (SupplieId.IsEmpty())
|
||||
throw new ValidationException("Field SupplieId is empty");
|
||||
|
||||
if (!SupplieId.IsGuid())
|
||||
throw new ValidationException("The value in the field SupplieId is not a unique identifier");
|
||||
|
||||
if (SupplieCount <= 0)
|
||||
throw new ValidationException("The value in field SupplieCount less ot equal 0");
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
using PimpMyRideContracts.Enums;
|
||||
using PimpMyRideContracts.Extensions;
|
||||
using PimpMyRideContracts.Infrastructure;
|
||||
using PimpMyRideContracts.Exceptions;
|
||||
|
||||
namespace PimpMyRideContracts.DataModels;
|
||||
|
||||
public class PostDataModel(string postId, string postName, PostType postType, double salary, bool isActual, DateTime changeDate) : IValidation
|
||||
{
|
||||
public string PostId { get; private set; } = postId;
|
||||
public string PostName { get; private set; } = postName;
|
||||
public PostType PostType { get; private set; } = postType;
|
||||
public double Salary { get; private set; } = salary;
|
||||
public bool IsActual { get; private set; } = isActual;
|
||||
public DateTime ChangeDate { get; private set; } = changeDate;
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (PostId.IsEmpty())
|
||||
throw new ValidationException("Field Id is empty");
|
||||
|
||||
if (!PostId.IsGuid())
|
||||
throw new ValidationException("The value in the field Id is not a unique identifier");
|
||||
|
||||
if (PostName.IsEmpty())
|
||||
throw new ValidationException("Field PostName is empty");
|
||||
|
||||
if (PostType == PostType.None)
|
||||
throw new ValidationException("Field PostType is empty");
|
||||
|
||||
if (Salary <= 0)
|
||||
throw new ValidationException("Field Salary is empty");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
using PimpMyRideContracts.Exceptions;
|
||||
using PimpMyRideContracts.Extensions;
|
||||
using PimpMyRideContracts.Infrastructure;
|
||||
|
||||
namespace PimpMyRideContracts.DataModels;
|
||||
|
||||
public class SalaryDataModell(string workerId, DateTime salaryDate, double workerSalary) : IValidation
|
||||
|
||||
{
|
||||
public string WorkerId { get; private set; } = workerId;
|
||||
public DateTime SalaryDate { get; private set; } = salaryDate;
|
||||
public double Salary { get; private set; } = workerSalary;
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (WorkerId.IsEmpty())
|
||||
throw new ValidationException("Field WorkerId is empty");
|
||||
|
||||
if (!WorkerId.IsGuid())
|
||||
throw new ValidationException("The value in the field WorkerId is not a unique identifier");
|
||||
|
||||
if (Salary <= 0)
|
||||
throw new ValidationException("Field Salary is less than or equal to 0");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
using PimpMyRideContracts.Exceptions;
|
||||
using PimpMyRideContracts.Extensions;
|
||||
using PimpMyRideContracts.Infrastructure;
|
||||
|
||||
namespace PimpMyRideContracts.DataModels;
|
||||
|
||||
public class ServiceDataModel(string serviceId, string workerId, string carId, string operationId) : IValidation
|
||||
{
|
||||
public string ServiceId { get; private set; } = serviceId;
|
||||
public string WorkerId { get; private set; } = workerId;
|
||||
public string CarId { get; private set; } = carId;
|
||||
public string OperationId { get; private set; } = operationId;
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (ServiceId.IsEmpty())
|
||||
throw new ValidationException("Field ServiceId is empty");
|
||||
|
||||
if (!ServiceId.IsGuid())
|
||||
throw new ValidationException("The value in the field ServiceId is not a unique identifier");
|
||||
|
||||
if (WorkerId.IsEmpty())
|
||||
throw new ValidationException("Field WorkerId is empty");
|
||||
|
||||
if (!WorkerId.IsGuid())
|
||||
throw new ValidationException("The value in the field WorkerId is not a unique identifier");
|
||||
|
||||
if (CarId.IsEmpty())
|
||||
throw new ValidationException("Field CarId is empty");
|
||||
|
||||
if (!CarId.IsGuid())
|
||||
throw new ValidationException("The value in the field CarId is not a unique identifier");
|
||||
|
||||
if (OperationId.IsEmpty())
|
||||
throw new ValidationException("Field OperationId is empty");
|
||||
|
||||
if (!OperationId.IsGuid())
|
||||
throw new ValidationException("The value in the field OperationId is not a unique identifier");
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
using PimpMyRideContracts.Enums;
|
||||
using PimpMyRideContracts.Exceptions;
|
||||
using PimpMyRideContracts.Extensions;
|
||||
using PimpMyRideContracts.Infrastructure;
|
||||
|
||||
namespace PimpMyRideContracts.DataModels;
|
||||
|
||||
public class SuppliesDataModel(string supplieId, string supplieName, SuppliesType supplieType) : IValidation
|
||||
{
|
||||
public string SupplieId { get; private set; } = supplieId;
|
||||
public string SupplieName { get; private set; } = supplieName;
|
||||
public SuppliesType SupplieType { get; private set; } = supplieType;
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (SupplieId.IsEmpty())
|
||||
throw new ValidationException("Field SupplieId is empty");
|
||||
|
||||
if (!SupplieId.IsGuid())
|
||||
throw new ValidationException("The value in the field SupplieId is not a unique identifier");
|
||||
|
||||
if (SupplieName.IsEmpty())
|
||||
throw new ValidationException("Field SupplieName is empty");
|
||||
|
||||
if (SupplieType == SuppliesType.None)
|
||||
throw new ValidationException("Field SupplieType is empty");
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
using PimpMyRideContracts.Exceptions;
|
||||
using PimpMyRideContracts.Extensions;
|
||||
using PimpMyRideContracts.Infrastructure;
|
||||
|
||||
namespace PimpMyRideContracts.DataModels;
|
||||
|
||||
public class WorkerDataModel(string workerId, string postId, string workerFIO, DateTime birthDate, DateTime employmentDate, bool isDeleted) : IValidation
|
||||
{
|
||||
public string WorkerId { get; private set; } = workerId;
|
||||
public string PostId { get; private set; } = postId;
|
||||
public string WorkerFIO { get; private set; } = workerFIO;
|
||||
public DateTime BirthDate { get; private set; } = birthDate;
|
||||
public DateTime EmploymentDate { get; private set; } = employmentDate;
|
||||
public bool IsDeleted { get; private set; } = isDeleted;
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (WorkerId.IsEmpty())
|
||||
throw new ValidationException("Field WorkerId is empty");
|
||||
|
||||
if (!WorkerId.IsGuid())
|
||||
throw new ValidationException("The value in the field WorkerId is not a unique identifier");
|
||||
|
||||
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 (WorkerFIO.IsEmpty())
|
||||
throw new ValidationException("Field WorkerFIO is empty");
|
||||
|
||||
if (BirthDate.Date > DateTime.Now.AddYears(-16).Date)
|
||||
throw new ValidationException("The date of employment cannot be less than the date of birth");
|
||||
|
||||
if ((EmploymentDate - BirthDate).TotalDays / 365 < 16)
|
||||
throw new ValidationException($"Minors cannot be hired (EmploymentDate - {EmploymentDate.ToShortDateString()}, BirthDate - {BirthDate.ToShortDateString()})");
|
||||
}
|
||||
}
|
11
PimpMyRideProject/PimpMyRideContracts/Enums/OperationType.cs
Normal file
11
PimpMyRideProject/PimpMyRideContracts/Enums/OperationType.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace PimpMyRideContracts.Enums;
|
||||
|
||||
public enum OperationType
|
||||
{
|
||||
None = 0,
|
||||
TireReplacement = 1,
|
||||
PistonReplacement = 2,
|
||||
TimingBeltReplacing = 3,
|
||||
OilChange = 4,
|
||||
BodyPainting = 5
|
||||
}
|
13
PimpMyRideProject/PimpMyRideContracts/Enums/PostType.cs
Normal file
13
PimpMyRideProject/PimpMyRideContracts/Enums/PostType.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace PimpMyRideContracts.Enums;
|
||||
|
||||
public enum PostType
|
||||
{
|
||||
None = 0,
|
||||
CarMechanic = 1,
|
||||
CarElectrician = 2,
|
||||
Straightener = 3,
|
||||
BodyRepairSpecialist = 4,
|
||||
TireFitter = 5,
|
||||
CarDiagnosticTechnician = 6,
|
||||
CarAirConditioningSpecialist = 7
|
||||
}
|
13
PimpMyRideProject/PimpMyRideContracts/Enums/SuppliesType.cs
Normal file
13
PimpMyRideProject/PimpMyRideContracts/Enums/SuppliesType.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace PimpMyRideContracts.Enums;
|
||||
|
||||
public enum SuppliesType
|
||||
{
|
||||
None = 0,
|
||||
Suspension = 1,
|
||||
Engine = 2,
|
||||
Gearbox = 3,
|
||||
Tires = 4,
|
||||
Rims = 5,
|
||||
Electronics = 6,
|
||||
Body = 7
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
namespace PimpMyRideContracts.Exceptions;
|
||||
|
||||
public class ValidationException(string message) : Exception(message)
|
||||
{
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
namespace PimpMyRideContracts.Extensions;
|
||||
|
||||
public static class StringExtensions
|
||||
{
|
||||
public static bool IsEmpty(this string str)
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(str);
|
||||
}
|
||||
|
||||
public static bool IsGuid(this string str)
|
||||
{
|
||||
return Guid.TryParse(str, out _);
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
namespace PimpMyRideContracts.Infrastructure;
|
||||
|
||||
public interface IValidation
|
||||
{
|
||||
void Validate();
|
||||
}
|
@ -6,4 +6,8 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NUnit" Version="4.3.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.10.35013.160
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PimpMyRideContracts", "PimpMyRideContracts\PimpMyRideContracts.csproj", "{DEFE53D7-DCB1-482C-8881-180886CEE5DB}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PimpMyRideContracts", "PimpMyRideContracts\PimpMyRideContracts.csproj", "{DEFE53D7-DCB1-482C-8881-180886CEE5DB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PimpMyRideTests", "PimpMyRideTests\PimpMyRideTests.csproj", "{4ECD058E-8F44-452B-B9E0-7536CB42C98F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -15,6 +17,10 @@ Global
|
||||
{DEFE53D7-DCB1-482C-8881-180886CEE5DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DEFE53D7-DCB1-482C-8881-180886CEE5DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DEFE53D7-DCB1-482C-8881-180886CEE5DB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4ECD058E-8F44-452B-B9E0-7536CB42C98F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4ECD058E-8F44-452B-B9E0-7536CB42C98F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4ECD058E-8F44-452B-B9E0-7536CB42C98F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4ECD058E-8F44-452B-B9E0-7536CB42C98F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -0,0 +1,89 @@
|
||||
using PimpMyRideContracts.Exceptions;
|
||||
using PimpMyRideContracts.DataModels;
|
||||
|
||||
namespace PimpMyRideTests.DataModelsTests;
|
||||
|
||||
[TestFixture]
|
||||
internal class CarDataModelTest
|
||||
{
|
||||
[Test]
|
||||
public void CarIdIsNullOrEmptyTest()
|
||||
{
|
||||
var car = CreateDataModel(null, "Toyota", "Supra", "Р243ПТ73");
|
||||
Assert.That(() => car.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
car = CreateDataModel(string.Empty, "Toyota", "Supra", "Р243ПТ73");
|
||||
Assert.That(() => car.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CarIdIsNotGuidTest()
|
||||
{
|
||||
var car = CreateDataModel("id", "Toyota", "Supra", "Р243ПТ73");
|
||||
Assert.That(() => car.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void CarMarkIsNullOrEmptyTest()
|
||||
{
|
||||
var car = CreateDataModel(Guid.NewGuid().ToString(), null, "Supra", "Р243ПТ73");
|
||||
Assert.That(() => car.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
car = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, "Supra", "Р243ПТ73");
|
||||
Assert.That(() => car.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CarModelIsNullOrEmptyTest()
|
||||
{
|
||||
var car = CreateDataModel(Guid.NewGuid().ToString(), "Toyota", null, "Р243ПТ73");
|
||||
Assert.That(() => car.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
car = CreateDataModel(Guid.NewGuid().ToString(), "Toyota", string.Empty, "Р243ПТ73");
|
||||
Assert.That(() => car.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CarNumberIsNullOrEmptyTest()
|
||||
{
|
||||
var car = CreateDataModel(Guid.NewGuid().ToString(), "Toyota", "Supra", null);
|
||||
Assert.That(() => car.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
car = CreateDataModel(Guid.NewGuid().ToString(), "Toyota", "Supra", string.Empty);
|
||||
Assert.That(() => car.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CarNumberIsIncorrectTest()
|
||||
{
|
||||
var car = CreateDataModel(Guid.NewGuid().ToString(), "Toyota", "Supra", "Р24373");
|
||||
Assert.That(() => car.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
car = CreateDataModel(Guid.NewGuid().ToString(), "Toyota", "Supra", "Р243РХ1173");
|
||||
Assert.That(() => car.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AllFieldsIsCorrectTest()
|
||||
{
|
||||
var carId = Guid.NewGuid().ToString();
|
||||
var carMark = "Toyota";
|
||||
var carModel = "Supra";
|
||||
var carNumber = "М243РХ73";
|
||||
|
||||
var car = CreateDataModel(carId, carMark, carModel, carNumber);
|
||||
Assert.That(() => car.Validate(), Throws.Nothing);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(car.CarId, Is.EqualTo(carId));
|
||||
Assert.That(car.CarMark, Is.EqualTo(carMark));
|
||||
Assert.That(car.CarModel, Is.EqualTo(carModel));
|
||||
Assert.That(car.CarNumber, Is.EqualTo(carNumber));
|
||||
});
|
||||
}
|
||||
|
||||
private static CarDataModel CreateDataModel(string? carId, string? carMark, string? carModel, string? carNumber) =>
|
||||
new (carId, carMark, carModel, carNumber);
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
using PimpMyRideContracts.Exceptions;
|
||||
using PimpMyRideContracts.DataModels;
|
||||
using PimpMyRideContracts.Enums;
|
||||
|
||||
namespace PimpMyRideTests.DataModelsTests;
|
||||
|
||||
[TestFixture]
|
||||
internal class OperationDataModelTest
|
||||
{
|
||||
[Test]
|
||||
public void OperationIdIsNullOrEmptyTest()
|
||||
{
|
||||
var operation = CreateDataModel(null, OperationType.TireReplacement, CreateSubDataModel());
|
||||
Assert.That(() => operation.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
operation = CreateDataModel(string.Empty, OperationType.TireReplacement, CreateSubDataModel());
|
||||
Assert.That(() => operation.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OperationIdIsNotGuidTest()
|
||||
{
|
||||
var operation = CreateDataModel("id", OperationType.TireReplacement, CreateSubDataModel());
|
||||
Assert.That(() => operation.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OperationTypeIsNoneTest()
|
||||
{
|
||||
var operation = CreateDataModel(Guid.NewGuid().ToString(), OperationType.None, CreateSubDataModel());
|
||||
Assert.That(() => operation.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SuppliesAreNullOrEmpty()
|
||||
{
|
||||
var operation = CreateDataModel(Guid.NewGuid().ToString(), OperationType.TireReplacement, null);
|
||||
Assert.That(() => operation.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
operation = CreateDataModel(Guid.NewGuid().ToString(), OperationType.BodyPainting, []);
|
||||
Assert.That(() => operation.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AllFieldsIsCorrectTest()
|
||||
{
|
||||
var operationId = Guid.NewGuid().ToString();
|
||||
var operationType = OperationType.BodyPainting;
|
||||
var supplies = CreateSubDataModel();
|
||||
|
||||
var operation = CreateDataModel(operationId, operationType, supplies);
|
||||
Assert.That(() => operation.Validate(), Throws.Nothing);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(operation.OperationId, Is.EqualTo(operationId));
|
||||
Assert.That(operation.OperationType, Is.EqualTo(operationType));
|
||||
Assert.That(operation.Supplies, Is.EqualTo(supplies));
|
||||
});
|
||||
}
|
||||
|
||||
private static OperationDataModel CreateDataModel(string? operationId, OperationType operationType, List<OperationSupplieDataModel>? supplies) =>
|
||||
new(operationId, operationType, supplies);
|
||||
|
||||
private static List<OperationSupplieDataModel> CreateSubDataModel() =>
|
||||
[new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 1)];
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
using PimpMyRideContracts.Exceptions;
|
||||
using PimpMyRideContracts.DataModels;
|
||||
|
||||
namespace PimpMyRideTests.DataModelsTests;
|
||||
|
||||
[TestFixture]
|
||||
internal class OperationSuppliesDataModelTest
|
||||
{
|
||||
[Test]
|
||||
public void OperationIdIsNullOrEmptyTest()
|
||||
{
|
||||
var operation = CreateDataModel(null, Guid.NewGuid().ToString(), 1);
|
||||
Assert.That(() => operation.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
operation = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), 1);
|
||||
Assert.That(() => operation.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OperationIdIsNotGuidTest()
|
||||
{
|
||||
var operation = CreateDataModel("id", Guid.NewGuid().ToString(), 1);
|
||||
Assert.That(() => operation.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SupplieIdIsNullOrEmptyTest()
|
||||
{
|
||||
var operation = CreateDataModel(Guid.NewGuid().ToString(), null, 1);
|
||||
Assert.That(() => operation.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
operation = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, 1);
|
||||
Assert.That(() => operation.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SupplieIdIsNotGuidTest()
|
||||
{
|
||||
var operation = CreateDataModel(Guid.NewGuid().ToString(), "id", 1);
|
||||
Assert.That(() => operation.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SupplieCountIsNotCorrect()
|
||||
{
|
||||
var operation = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 0);
|
||||
Assert.That(() => operation.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
operation = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), -5);
|
||||
Assert.That(() => operation.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AllFieldsIsCorrectTest()
|
||||
{
|
||||
var operationId = Guid.NewGuid().ToString();
|
||||
var supplieId = Guid.NewGuid().ToString();
|
||||
var supplieCount = 1;
|
||||
|
||||
var operation = CreateDataModel(operationId, supplieId, supplieCount);
|
||||
Assert.That(() => operation.Validate(), Throws.Nothing);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(operation.OperationId, Is.EqualTo(operationId));
|
||||
Assert.That(operation.SupplieId, Is.EqualTo(supplieId));
|
||||
Assert.That(operation.SupplieCount, Is.EqualTo(supplieCount));
|
||||
});
|
||||
}
|
||||
|
||||
private static OperationSupplieDataModel CreateDataModel(string? operationId, string? supplieId, int supplieCount) =>
|
||||
new(operationId, supplieId, supplieCount);
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
using PimpMyRideContracts.DataModels;
|
||||
using PimpMyRideContracts.Enums;
|
||||
using PimpMyRideContracts.Exceptions;
|
||||
|
||||
namespace PimpMyRideTests.DataModelsTests;
|
||||
|
||||
[TestFixture]
|
||||
internal class PostDataModelTest
|
||||
{
|
||||
[Test]
|
||||
public void PostIdIsNullOrEmptyTest()
|
||||
{
|
||||
var post = CreateDataModel(null, "name", PostType.CarElectrician, 10, true, DateTime.UtcNow);
|
||||
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
post = CreateDataModel(string.Empty, "name", PostType.CarElectrician, 10, true, DateTime.UtcNow);
|
||||
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PostIdIsNotGuidTest()
|
||||
{
|
||||
var post = CreateDataModel("id", "name", PostType.CarElectrician, 10, true, DateTime.UtcNow);
|
||||
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PostNameIsEmptyTest()
|
||||
{
|
||||
var post = CreateDataModel(Guid.NewGuid().ToString(), null, PostType.CarElectrician, 10, true, DateTime.UtcNow);
|
||||
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
post = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, PostType.CarElectrician, 10, true, DateTime.UtcNow);
|
||||
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PostTypeIsNoneTest()
|
||||
{
|
||||
var post = CreateDataModel(Guid.NewGuid().ToString(), "name", PostType.None, 10, true, DateTime.UtcNow);
|
||||
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SalaryIsLessOrZeroTest()
|
||||
{
|
||||
var post = CreateDataModel(Guid.NewGuid().ToString(), "name", PostType.CarElectrician, 0, true, DateTime.UtcNow);
|
||||
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
post = CreateDataModel(Guid.NewGuid().ToString(), "name", PostType.CarElectrician, -10, true, DateTime.UtcNow);
|
||||
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AllFieldsIsCorrectTest()
|
||||
{
|
||||
var postId = Guid.NewGuid().ToString();
|
||||
var postName = "name";
|
||||
var postType = PostType.CarElectrician;
|
||||
var salary = 10;
|
||||
var isActual = false;
|
||||
var changeDate = DateTime.UtcNow.AddDays(-1);
|
||||
var post = CreateDataModel(postId, postName, postType, salary, isActual, changeDate);
|
||||
Assert.That(() => post.Validate(), Throws.Nothing);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(post.PostId, Is.EqualTo(postId));
|
||||
Assert.That(post.PostName, Is.EqualTo(postName));
|
||||
Assert.That(post.PostType, Is.EqualTo(postType));
|
||||
Assert.That(post.Salary, Is.EqualTo(salary));
|
||||
Assert.That(post.IsActual, Is.EqualTo(isActual));
|
||||
Assert.That(post.ChangeDate, Is.EqualTo(changeDate));
|
||||
});
|
||||
}
|
||||
|
||||
private static PostDataModel CreateDataModel(string? postId, string? postName, PostType postType, double salary, bool isActual, DateTime changeDate) =>
|
||||
new(postId, postName, postType, salary, isActual, changeDate);
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
using PimpMyRideContracts.DataModels;
|
||||
using PimpMyRideContracts.Exceptions;
|
||||
|
||||
namespace PimpMyRideTests.DataModelsTests;
|
||||
|
||||
[TestFixture]
|
||||
internal class SalaryDataModelTest
|
||||
{
|
||||
[Test]
|
||||
public void WorkerIdIsEmptyTest()
|
||||
{
|
||||
var salary = CreateDataModel(null, DateTime.Now, 10);
|
||||
Assert.That(() => salary.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
salary = CreateDataModel(string.Empty, DateTime.Now, 10);
|
||||
Assert.That(() => salary.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WorkerIdIsNotGuidTest()
|
||||
{
|
||||
var salary = CreateDataModel("workerId", DateTime.Now, 10);
|
||||
Assert.That(() => salary.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SalaryIsLessOrZeroTest()
|
||||
{
|
||||
var salary = CreateDataModel(Guid.NewGuid().ToString(), DateTime.Now, 0);
|
||||
Assert.That(() => salary.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
salary = CreateDataModel(Guid.NewGuid().ToString(), DateTime.Now, -10);
|
||||
Assert.That(() => salary.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AllFieldsIsCorrectTest()
|
||||
{
|
||||
var workerId = Guid.NewGuid().ToString();
|
||||
var salaryDate = DateTime.Now.AddDays(-3).AddMinutes(-5);
|
||||
var salary = 10;
|
||||
var workerSalary = CreateDataModel(workerId, salaryDate, salary);
|
||||
Assert.That(() => workerSalary.Validate(), Throws.Nothing);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(workerSalary.WorkerId, Is.EqualTo(workerId));
|
||||
Assert.That(workerSalary.SalaryDate, Is.EqualTo(salaryDate));
|
||||
Assert.That(workerSalary.Salary, Is.EqualTo(salary));
|
||||
});
|
||||
}
|
||||
|
||||
private static SalaryDataModell CreateDataModel(string? workerId, DateTime salaryDate, double salary) =>
|
||||
new(workerId, salaryDate, salary);
|
||||
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
using PimpMyRideContracts.Exceptions;
|
||||
using PimpMyRideContracts.DataModels;
|
||||
using PimpMyRideContracts.Enums;
|
||||
|
||||
namespace PimpMyRideTests.DataModelsTests;
|
||||
|
||||
[TestFixture]
|
||||
internal class ServiceDataModelTest
|
||||
{
|
||||
[Test]
|
||||
public void ServiceIdIsNullOrEmptyTest()
|
||||
{
|
||||
var service = CreateDataModel(null, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
|
||||
Assert.That(() => service.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
service = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
|
||||
Assert.That(() => service.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ServiceIdIsNotGuidTest()
|
||||
{
|
||||
var service = CreateDataModel("id", Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
|
||||
Assert.That(() => service.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WorkerIdIsNullOrEmptyTest()
|
||||
{
|
||||
var service = CreateDataModel(Guid.NewGuid().ToString(), null, Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
|
||||
Assert.That(() => service.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
service = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
|
||||
Assert.That(() => service.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WorkerIdIsNotGuidTest()
|
||||
{
|
||||
var service = CreateDataModel(Guid.NewGuid().ToString(), "id", Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
|
||||
Assert.That(() => service.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CarIdIsNullOrEmptyTest()
|
||||
{
|
||||
var service = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), null, Guid.NewGuid().ToString());
|
||||
Assert.That(() => service.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
service = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), string.Empty, Guid.NewGuid().ToString());
|
||||
Assert.That(() => service.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CarIdIsNotGuidTest()
|
||||
{
|
||||
var service = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "id", Guid.NewGuid().ToString());
|
||||
Assert.That(() => service.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OperationIdIsNullOrEmptyTest()
|
||||
{
|
||||
var service = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), null);
|
||||
Assert.That(() => service.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
service = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), string.Empty);
|
||||
Assert.That(() => service.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OperationIdIsNotGuidTest()
|
||||
{
|
||||
var service = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "operationId");
|
||||
Assert.That(() => service.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AllFieldsIsCorrectTest()
|
||||
{
|
||||
var serviceId = Guid.NewGuid().ToString();
|
||||
var workerId = Guid.NewGuid().ToString();
|
||||
var carId = Guid.NewGuid().ToString();
|
||||
var operationId = Guid.NewGuid().ToString();
|
||||
|
||||
var service = CreateDataModel(serviceId, workerId, carId, operationId);
|
||||
Assert.That(() => service.Validate(), Throws.Nothing);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(service.ServiceId, Is.EqualTo(serviceId));
|
||||
Assert.That(service.WorkerId, Is.EqualTo(workerId));
|
||||
Assert.That(service.CarId, Is.EqualTo(carId));
|
||||
Assert.That(service.OperationId, Is.EqualTo(operationId));
|
||||
});
|
||||
}
|
||||
|
||||
private static ServiceDataModel CreateDataModel(string? serviceId, string? workerId, string? carId, string? operationId) =>
|
||||
new(serviceId, workerId, carId, operationId);
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
using PimpMyRideContracts.Exceptions;
|
||||
using PimpMyRideContracts.DataModels;
|
||||
using PimpMyRideContracts.Enums;
|
||||
|
||||
namespace PimpMyRideTests.DataModelsTests;
|
||||
|
||||
[TestFixture]
|
||||
internal class SuppliesDataModelTest
|
||||
{
|
||||
[Test]
|
||||
public void SupplieIdIsNullOrEmptyTest()
|
||||
{
|
||||
var supplie = CreateDataModel(null, "Sport rim", SuppliesType.Rims);
|
||||
Assert.That(() => supplie.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
supplie = CreateDataModel(string.Empty, "Sport rim", SuppliesType.Rims);
|
||||
Assert.That(() => supplie.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SupplieIdIsNotGuidTest()
|
||||
{
|
||||
var supplie = CreateDataModel("id", "Sport rim", SuppliesType.Rims);
|
||||
Assert.That(() => supplie.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SupplieNameIsNullOrEmptyTest()
|
||||
{
|
||||
var supplie = CreateDataModel(Guid.NewGuid().ToString(), null, SuppliesType.Rims);
|
||||
Assert.That(() => supplie.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
supplie = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, SuppliesType.Rims);
|
||||
Assert.That(() => supplie.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SupplieTypeIsNoneTest()
|
||||
{
|
||||
var supplie = CreateDataModel(Guid.NewGuid().ToString(), "Sport rim", SuppliesType.None);
|
||||
Assert.That(() => supplie.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AllFieldsIsCorrectTest()
|
||||
{
|
||||
var supplieId = Guid.NewGuid().ToString();
|
||||
var supplieName = "Sport rim";
|
||||
var supplieType = SuppliesType.Rims;
|
||||
|
||||
var supplie = CreateDataModel(supplieId, supplieName, supplieType);
|
||||
Assert.That(() => supplie.Validate(), Throws.Nothing);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(supplie.SupplieId, Is.EqualTo(supplieId));
|
||||
Assert.That(supplie.SupplieName, Is.EqualTo(supplieName));
|
||||
Assert.That(supplie.SupplieType, Is.EqualTo(supplieType));
|
||||
});
|
||||
}
|
||||
|
||||
private static SuppliesDataModel CreateDataModel(string? supplieId, string? supplieName, SuppliesType supplieType) =>
|
||||
new(supplieId, supplieName, supplieType);
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
using PimpMyRideContracts.Exceptions;
|
||||
using PimpMyRideContracts.DataModels;
|
||||
|
||||
namespace PimpMyRideTests.DataModelsTests;
|
||||
|
||||
[TestFixture]
|
||||
internal class WorkerDataModelTest
|
||||
{
|
||||
[Test]
|
||||
public void WorkerIdIsNullOrEmptyTest()
|
||||
{
|
||||
var worker = CreateDataModel(null, Guid.NewGuid().ToString(), "FIO", DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||
Assert.That(() => worker.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
worker = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), "FIO", DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||
Assert.That(() => worker.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WorkerIdIsNotGuidTest()
|
||||
{
|
||||
var worker = CreateDataModel("id", Guid.NewGuid().ToString(), "FIO", DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||
Assert.That(() => worker.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PostIdIsNullOrEmptyTest()
|
||||
{
|
||||
var worker = CreateDataModel(Guid.NewGuid().ToString(), null, "FIO", DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||
Assert.That(() => worker.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
worker = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, "FIO", DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||
Assert.That(() => worker.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PostIdIsNotGuidTest()
|
||||
{
|
||||
var worker = CreateDataModel(Guid.NewGuid().ToString(), "postId", "FIO", DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||
Assert.That(() => worker.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WorkerFIOIsNullOrEmptyTest()
|
||||
{
|
||||
var worker = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), null, DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||
Assert.That(() => worker.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
worker = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), string.Empty, DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||
Assert.That(() => worker.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BirthDateIsNotCorrectTest()
|
||||
{
|
||||
var worker = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "FIO", DateTime.Now.AddYears(-16).AddDays(1), DateTime.Now, false);
|
||||
Assert.That(() => worker.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BirthDateAndEmployementDateAreNotCorrectTest()
|
||||
{
|
||||
var worker = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "FIO", DateTime.Now.AddYears(-18), DateTime.Now.AddYears(-18).AddDays(-1), false);
|
||||
Assert.That(() => worker.Validate(), Throws.TypeOf<ValidationException>());
|
||||
|
||||
worker = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "FIO", DateTime.Now.AddYears(-18), DateTime.Now.AddYears(-16), false);
|
||||
Assert.That(() => worker.Validate(), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AllFieldsIsCorrectTest()
|
||||
{
|
||||
var workerId = Guid.NewGuid().ToString();
|
||||
var postId = Guid.NewGuid().ToString();
|
||||
var workerFIO = "FIO";
|
||||
var birthDate = DateTime.Now.AddYears(-16).AddDays(-1);
|
||||
var employementDate = DateTime.Now;
|
||||
var isDeleted = false;
|
||||
|
||||
var worker = CreateDataModel(workerId, postId, workerFIO, birthDate, employementDate, isDeleted);
|
||||
Assert.That(() => worker.Validate(), Throws.Nothing);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(worker.WorkerId, Is.EqualTo(workerId));
|
||||
Assert.That(worker.PostId, Is.EqualTo(postId));
|
||||
Assert.That(worker.WorkerFIO, Is.EqualTo(workerFIO));
|
||||
Assert.That(worker.BirthDate, Is.EqualTo(birthDate));
|
||||
Assert.That(worker.EmploymentDate, Is.EqualTo(employementDate));
|
||||
Assert.That(worker.IsDeleted, Is.EqualTo(isDeleted));
|
||||
});
|
||||
}
|
||||
|
||||
private static WorkerDataModel CreateDataModel(string? workerId, string? postId, string? workerFIO, DateTime birthDate, DateTime employmentDate, bool isDeleted) =>
|
||||
new(workerId, postId, workerFIO, birthDate, employmentDate, isDeleted);
|
||||
}
|
28
PimpMyRideProject/PimpMyRideTests/PimpMyRideTests.csproj
Normal file
28
PimpMyRideProject/PimpMyRideTests/PimpMyRideTests.csproj
Normal file
@ -0,0 +1,28 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="NUnit" Version="4.3.2" />
|
||||
<PackageReference Include="NUnit.Analyzers" Version="3.9.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PimpMyRideContracts\PimpMyRideContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="NUnit.Framework" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
x
Reference in New Issue
Block a user