Deleted tests. Start separate development

This commit is contained in:
Lazypr0ger
2025-04-24 12:25:29 +04:00
parent 85c3a97d23
commit 9a6963d2c5
2 changed files with 8 additions and 102 deletions

View File

@@ -7,7 +7,8 @@ using UniversityAllExpelled_Models.Infrostructure;
namespace UniversityAllExpelled_Models.DataModels;
public class UserDataModel(string id, string login, string password, SystemRoleType role, string fio, DateTime birthdate, string email, bool isDeleted) : IValidation
public class UserDataModel(string id, string login, string password, SystemRoleType role,
string fio, DateTime birthdate,string phoneNomber, string email, bool isDeleted) : IValidation
{
public string Id { get; private set; } = id;
@@ -21,6 +22,8 @@ public class UserDataModel(string id, string login, string password, SystemRoleT
public DateTime BirthDate { get; private set; } = birthdate;
public string PhoneNomber { get; private set; } = phoneNomber;
public string Email { get; private set; } = email;
public bool IsDeleted { get; private set; } = isDeleted;
@@ -64,6 +67,10 @@ public class UserDataModel(string id, string login, string password, SystemRoleT
{
throw new ValidationException("The Birthday field was entered incorrectly");
}
if (!Regex.IsMatch(PhoneNomber, @"^(\+7|8)(-?\d{3}-?\d{3}-?\d{2}-?\d{2}|-?\d{10})$"))
{
throw new ValidationException("The PhoneNomber field was entered incorrectly.");
}
if (!Regex.IsMatch(Email, @"^[a-zA-Z0-9._%+-]+@(?:yandex\.[a-z]{2,}|mail\.ru|inbox\.ru|list\.ru|bk\.ru|gmail\.com)$"))
{
throw new ValidationException("The Email field was entered incorrectly.");

View File

@@ -1,101 +0,0 @@
using UniversityAllExpelled_Models.DataModels.Worker;
using UniversityAllExpelled_Models.Exceptions;
namespace UniversityAllExpelledTests.DataModelsTests;
[TestFixture]
internal class EducationDataModelTests
{
[Test]
public void IdIsNullOrEmptyTest()
{
var model = CreateDataModel(null, Guid.NewGuid().ToString(), 100.0f, DateTime.Now, DateTime.Now.AddDays(30), true);
Assert.That(() => model.Validate(), Throws.TypeOf<ValidationException>());
model = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), 100.0f, DateTime.Now, DateTime.Now.AddDays(30), true);
Assert.That(() => model.Validate(), Throws.TypeOf<ValidationException>());
}
[Test]
public void IdIsNotGuidTest()
{
var model = CreateDataModel("not a guid", Guid.NewGuid().ToString(), 100.0f, DateTime.Now, DateTime.Now.AddDays(30), true);
Assert.That(() => model.Validate(), Throws.TypeOf<ValidationException>());
}
[Test]
public void TeacherIdIsNullOrEmptyTest()
{
var model = CreateDataModel(Guid.NewGuid().ToString(), null, 100.0f, DateTime.Now, DateTime.Now.AddDays(30), true);
Assert.That(() => model.Validate(), Throws.TypeOf<ValidationException>());
model = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, 100.0f, DateTime.Now, DateTime.Now.AddDays(30), true);
Assert.That(() => model.Validate(), Throws.TypeOf<ValidationException>());
}
[Test]
public void TeacherIdIsNotGuidTest()
{
var model = CreateDataModel(Guid.NewGuid().ToString(), "not a guid", 100.0f, DateTime.Now, DateTime.Now.AddDays(30), true);
Assert.That(() => model.Validate(), Throws.TypeOf<ValidationException>());
}
[Test]
public void AmountIsZeroOrNegativeTest()
{
var model = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 0, DateTime.Now, DateTime.Now.AddDays(30), true);
Assert.That(() => model.Validate(), Throws.TypeOf<ValidationException>());
model = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), -100.0f, DateTime.Now, DateTime.Now.AddDays(30), true);
Assert.That(() => model.Validate(), Throws.TypeOf<ValidationException>());
}
[Test]
public void StartDateIsDefaultTest()
{
var model = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 100.0f, default, DateTime.Now.AddDays(30), true);
Assert.That(() => model.Validate(), Throws.TypeOf<ValidationException>());
}
[Test]
public void EndDateIsDefaultTest()
{
var model = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 100.0f, DateTime.Now, default, true);
Assert.That(() => model.Validate(), Throws.TypeOf<ValidationException>());
}
[Test]
public void StartDateAfterEndDateTest()
{
var model = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 100.0f, DateTime.Now.AddDays(1), DateTime.Now, true);
Assert.That(() => model.Validate(), Throws.TypeOf<ValidationException>());
}
[Test]
public void AllFieldsIsCorrectTest()
{
var id = Guid.NewGuid().ToString();
var teacherId = Guid.NewGuid().ToString();
var amount = 100.0f;
var startDate = DateTime.Now;
var endDate = DateTime.Now.AddDays(30);
var active = true;
var model = CreateDataModel(id, teacherId, amount, startDate, endDate, active);
Assert.That(() => model.Validate(), Throws.Nothing);
Assert.Multiple(() =>
{
Assert.That(model.Id, Is.EqualTo(id));
Assert.That(model.TeacherId, Is.EqualTo(teacherId));
Assert.That(model.Amount, Is.EqualTo(amount));
Assert.That(model.StartDate, Is.EqualTo(startDate));
Assert.That(model.EndDate, Is.EqualTo(endDate));
Assert.That(model.Active, Is.EqualTo(active));
});
}
private static EducationDataModel CreateDataModel(string? id, string? teacherId, float amount, DateTime startDate, DateTime endDate, bool active)
=> new(id, teacherId, amount, startDate, endDate, active);
}