Тестики
This commit is contained in:
parent
7fb7fec245
commit
73e0d6ea3c
@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.11.35327.3
|
VisualStudioVersion = 17.11.35327.3
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagicCarpetContracts", "MagicCarpetContracts\MagicCarpetContracts.csproj", "{C1E669BF-22EC-4388-A54E-45160151A92C}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicCarpetContracts", "MagicCarpetContracts\MagicCarpetContracts.csproj", "{C1E669BF-22EC-4388-A54E-45160151A92C}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagicCarpetTests", "MagicCarpetTests\MagicCarpetTests.csproj", "{AD61DB61-6F8B-448F-933E-F9C2C3FA05E4}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -15,6 +17,10 @@ Global
|
|||||||
{C1E669BF-22EC-4388-A54E-45160151A92C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{C1E669BF-22EC-4388-A54E-45160151A92C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{C1E669BF-22EC-4388-A54E-45160151A92C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{C1E669BF-22EC-4388-A54E-45160151A92C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{C1E669BF-22EC-4388-A54E-45160151A92C}.Release|Any CPU.Build.0 = Release|Any CPU
|
{C1E669BF-22EC-4388-A54E-45160151A92C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{AD61DB61-6F8B-448F-933E-F9C2C3FA05E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{AD61DB61-6F8B-448F-933E-F9C2C3FA05E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{AD61DB61-6F8B-448F-933E-F9C2C3FA05E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{AD61DB61-6F8B-448F-933E-F9C2C3FA05E4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using MagicCarpetContracts.Extensions;
|
using MagicCarpetContracts.Extensions;
|
||||||
|
using MagicCarpetContracts.Exceptions;
|
||||||
using MagicCarpetContracts.Infrastructure;
|
using MagicCarpetContracts.Infrastructure;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -7,6 +8,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using ValidationException = MagicCarpetContracts.Exceptions.ValidationException;
|
||||||
|
|
||||||
namespace MagicCarpetContracts.DataModels;
|
namespace MagicCarpetContracts.DataModels;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using MagicCarpetContracts.Exeptions;
|
using MagicCarpetContracts.Exceptions;
|
||||||
using MagicCarpetContracts.Extensions;
|
using MagicCarpetContracts.Extensions;
|
||||||
using MagicCarpetContracts.Infrastructure;
|
using MagicCarpetContracts.Infrastructure;
|
||||||
using System;
|
using System;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using MagicCarpetContracts.Enums;
|
using MagicCarpetContracts.Enums;
|
||||||
using MagicCarpetContracts.Exeptions;
|
using MagicCarpetContracts.Exceptions;
|
||||||
using MagicCarpetContracts.Extensions;
|
using MagicCarpetContracts.Extensions;
|
||||||
using MagicCarpetContracts.Infrastructure;
|
using MagicCarpetContracts.Infrastructure;
|
||||||
using System;
|
using System;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using MagicCarpetContracts.Exeptions;
|
using MagicCarpetContracts.Exceptions;
|
||||||
using MagicCarpetContracts.Extensions;
|
using MagicCarpetContracts.Extensions;
|
||||||
using MagicCarpetContracts.Infrastructure;
|
using MagicCarpetContracts.Infrastructure;
|
||||||
using System;
|
using System;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using MagicCarpetContracts.Enums;
|
using MagicCarpetContracts.Enums;
|
||||||
using MagicCarpetContracts.Exeptions;
|
using MagicCarpetContracts.Exceptions;
|
||||||
using MagicCarpetContracts.Extensions;
|
using MagicCarpetContracts.Extensions;
|
||||||
using MagicCarpetContracts.Infrastructure;
|
using MagicCarpetContracts.Infrastructure;
|
||||||
using System;
|
using System;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using MagicCarpetContracts.Exeptions;
|
using MagicCarpetContracts.Exceptions;
|
||||||
using MagicCarpetContracts.Extensions;
|
using MagicCarpetContracts.Extensions;
|
||||||
using MagicCarpetContracts.Infrastructure;
|
using MagicCarpetContracts.Infrastructure;
|
||||||
using System;
|
using System;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using MagicCarpetContracts.Enums;
|
using MagicCarpetContracts.Enums;
|
||||||
using MagicCarpetContracts.Exeptions;
|
using MagicCarpetContracts.Exceptions;
|
||||||
using MagicCarpetContracts.Extensions;
|
using MagicCarpetContracts.Extensions;
|
||||||
using MagicCarpetContracts.Infrastructure;
|
using MagicCarpetContracts.Infrastructure;
|
||||||
using System;
|
using System;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using MagicCarpetContracts.Exeptions;
|
using MagicCarpetContracts.Exceptions;
|
||||||
using MagicCarpetContracts.Extensions;
|
using MagicCarpetContracts.Extensions;
|
||||||
using MagicCarpetContracts.Infrastructure;
|
using MagicCarpetContracts.Infrastructure;
|
||||||
using System;
|
using System;
|
||||||
@ -9,9 +9,9 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace MagicCarpetContracts.DataModels;
|
namespace MagicCarpetContracts.DataModels;
|
||||||
|
|
||||||
public class TourHistoryDataModel(string cocktailId, double oldPrice) : IValidation
|
public class TourHistoryDataModel(string tourId, double oldPrice) : IValidation
|
||||||
{
|
{
|
||||||
public string TourId { get; private set; } = cocktailId;
|
public string TourId { get; private set; } = tourId;
|
||||||
|
|
||||||
public double OldPrice { get; private set; } = oldPrice;
|
public double OldPrice { get; private set; } = oldPrice;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MagicCarpetContracts.Exeptions;
|
namespace MagicCarpetContracts.Exceptions;
|
||||||
|
|
||||||
public class ValidationException(string message) : Exception(message)
|
public class ValidationException(string message) : Exception(message)
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,74 @@
|
|||||||
|
using MagicCarpetContracts.DataModels;
|
||||||
|
using MagicCarpetContracts.Exceptions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MagicCarpetTests.DataModelTests;
|
||||||
|
[TestFixture]
|
||||||
|
internal class ClientDataModelTests
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void IdIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var client = CreateDataModel(null, "fio", "number", 10);
|
||||||
|
Assert.That(() => client.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
client = CreateDataModel(string.Empty, "fio", "number", 10);
|
||||||
|
Assert.That(() => client.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IdIsNotGuidTest()
|
||||||
|
{
|
||||||
|
var client = CreateDataModel("id", "fio", "number", 10);
|
||||||
|
Assert.That(() => client.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void FIOIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var client = CreateDataModel(Guid.NewGuid().ToString(), null, "number", 10);
|
||||||
|
Assert.That(() => client.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
client = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, "number", 10);
|
||||||
|
Assert.That(() => client.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void PhoneNumberIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var client = CreateDataModel(Guid.NewGuid().ToString(), "fio", null, 10);
|
||||||
|
Assert.That(() => client.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
client = CreateDataModel(Guid.NewGuid().ToString(), "fio", string.Empty, 10);
|
||||||
|
Assert.That(() => client.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void PhoneNumberIsIncorrectTest()
|
||||||
|
{
|
||||||
|
var client = CreateDataModel(Guid.NewGuid().ToString(), "fio", "777", 10);
|
||||||
|
Assert.That(() => client.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AllFieldsIsCorrectTest()
|
||||||
|
{
|
||||||
|
var clientId = Guid.NewGuid().ToString();
|
||||||
|
var fio = "Fio";
|
||||||
|
var phoneNumber = "+7-777-777-77-77";
|
||||||
|
var discountSize = 11;
|
||||||
|
var buyer = CreateDataModel(clientId, fio, phoneNumber, discountSize);
|
||||||
|
Assert.That(() => buyer.Validate(), Throws.Nothing);
|
||||||
|
Assert.Multiple(() =>
|
||||||
|
{
|
||||||
|
Assert.That(buyer.Id, Is.EqualTo(clientId));
|
||||||
|
Assert.That(buyer.FIO, Is.EqualTo(fio));
|
||||||
|
Assert.That(buyer.PhoneNumber, Is.EqualTo(phoneNumber));
|
||||||
|
Assert.That(buyer.DiscountSize, Is.EqualTo(discountSize));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ClientDataModel CreateDataModel(string? id, string? fio, string? phoneNumber, double discountSize) =>
|
||||||
|
new(id, fio, phoneNumber, discountSize);
|
||||||
|
}
|
@ -0,0 +1,113 @@
|
|||||||
|
using MagicCarpetContracts.DataModels;
|
||||||
|
using MagicCarpetContracts.Exceptions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MagicCarpetTests.DataModelTests;
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
internal class EmployeeDataModelTests
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void IdIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var employee = CreateDataModel(null, "fio", "abc@gmail.com", Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||||
|
Assert.That(() => employee.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
employee = CreateDataModel(string.Empty, "fio", "abc@gmail.com", Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||||
|
Assert.That(() => employee.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IdIsNotGuidTest()
|
||||||
|
{
|
||||||
|
var employee = CreateDataModel("id", "fio", "abc@gmail.com", Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||||
|
Assert.That(() => employee.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void FIOIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var employee = CreateDataModel(Guid.NewGuid().ToString(), null, "abc@gmail.com", Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||||
|
Assert.That(() => employee.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
employee = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, "abc@gmail.com", Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||||
|
Assert.That(() => employee.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void EmailIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var employee = CreateDataModel(Guid.NewGuid().ToString(), "fio", null, Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||||
|
Assert.That(() => employee.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
employee = CreateDataModel(Guid.NewGuid().ToString(), "fio", string.Empty, Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||||
|
Assert.That(() => employee.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void EmailIsIncorrectTest()
|
||||||
|
{
|
||||||
|
var employee = CreateDataModel(Guid.NewGuid().ToString(), "fio", "abc@gmail", Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||||
|
Assert.That(() => employee.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void PostIdIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var employee = CreateDataModel(Guid.NewGuid().ToString(), "fio", "abc@gmail.com", null, DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||||
|
Assert.That(() => employee.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
employee = CreateDataModel(Guid.NewGuid().ToString(), "fio", "abc@gmail.com", string.Empty, DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||||
|
Assert.That(() => employee.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void PostIdIsNotGuidTest()
|
||||||
|
{
|
||||||
|
var employee = CreateDataModel(Guid.NewGuid().ToString(), "fio", "abc@gmail.com", "postId", DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||||
|
Assert.That(() => employee.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void BirthDateIsNotCorrectTest()
|
||||||
|
{
|
||||||
|
var employee = CreateDataModel(Guid.NewGuid().ToString(), "fio", "abc@gmail.com", Guid.NewGuid().ToString(), DateTime.Now.AddYears(-16).AddDays(1), DateTime.Now, false);
|
||||||
|
Assert.That(() => employee.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void BirthDateAndEmploymentDateIsNotCorrectTest()
|
||||||
|
{
|
||||||
|
var employee = CreateDataModel(Guid.NewGuid().ToString(), "fio", "abc@gmail.com", Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18), DateTime.Now.AddYears(-18).AddDays(-1), false);
|
||||||
|
Assert.That(() => employee.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
employee = CreateDataModel(Guid.NewGuid().ToString(), "fio", "abc@gmail.com", Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18), DateTime.Now.AddYears(-16), false);
|
||||||
|
Assert.That(() => employee.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AllFieldsIsCorrectTest()
|
||||||
|
{
|
||||||
|
var employeeId = Guid.NewGuid().ToString();
|
||||||
|
var fio = "fio";
|
||||||
|
var employeeEmail = "abc@gmail.com";
|
||||||
|
var postId = Guid.NewGuid().ToString();
|
||||||
|
var birthDate = DateTime.Now.AddYears(-18).AddDays(-1);
|
||||||
|
var employmentDate = DateTime.Now;
|
||||||
|
var isDelete = false;
|
||||||
|
var employee = CreateDataModel(employeeId, fio, employeeEmail, postId, birthDate, employmentDate, isDelete);
|
||||||
|
Assert.That(() => employee.Validate(), Throws.Nothing);
|
||||||
|
Assert.Multiple(() =>
|
||||||
|
{
|
||||||
|
Assert.That(employee.Id, Is.EqualTo(employeeId));
|
||||||
|
Assert.That(employee.FIO, Is.EqualTo(fio));
|
||||||
|
Assert.That(employee.Email, Is.EqualTo(employeeEmail));
|
||||||
|
Assert.That(employee.PostId, Is.EqualTo(postId));
|
||||||
|
Assert.That(employee.BirthDate, Is.EqualTo(birthDate));
|
||||||
|
Assert.That(employee.EmploymentDate, Is.EqualTo(employmentDate));
|
||||||
|
Assert.That(employee.IsDeleted, Is.EqualTo(isDelete));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static EmployeeDataModel CreateDataModel(string? id, string? fio, string? email, string? postId, DateTime birthDate, DateTime employmentDate, bool isDeleted) =>
|
||||||
|
new(id, fio, email, postId, birthDate, employmentDate, isDeleted);
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
using MagicCarpetContracts.DataModels;
|
||||||
|
using MagicCarpetContracts.Enums;
|
||||||
|
using MagicCarpetContracts.Exceptions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MagicCarpetTests.DataModelTests;
|
||||||
|
[TestFixture]
|
||||||
|
internal class PostDataModelTests
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void IdIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var post = CreateDataModel(null, Guid.NewGuid().ToString(), "name", PostType.Manager, 10, true, DateTime.UtcNow);
|
||||||
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
post = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), "name", PostType.Manager, 10, true, DateTime.UtcNow);
|
||||||
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IdIsNotGuidTest()
|
||||||
|
{
|
||||||
|
var post = CreateDataModel("id", Guid.NewGuid().ToString(), "name", PostType.Manager, 10, true, DateTime.UtcNow);
|
||||||
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void PostIdIsNullEmptyTest()
|
||||||
|
{
|
||||||
|
var post = CreateDataModel(Guid.NewGuid().ToString(), null, "name", PostType.Manager, 10, true, DateTime.UtcNow);
|
||||||
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
post = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, "name", PostType.Manager, 10, true, DateTime.UtcNow);
|
||||||
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void PostIdIsNotGuidTest()
|
||||||
|
{
|
||||||
|
var post = CreateDataModel(Guid.NewGuid().ToString(), "postId", "name", PostType.Manager, 10, true, DateTime.UtcNow);
|
||||||
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void PostNameIsEmptyTest()
|
||||||
|
{
|
||||||
|
var manufacturer = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), null, PostType.Manager, 10, true, DateTime.UtcNow);
|
||||||
|
Assert.That(() => manufacturer.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
manufacturer = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), string.Empty, PostType.Manager, 10, true, DateTime.UtcNow);
|
||||||
|
Assert.That(() => manufacturer.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void PostTypeIsNoneTest()
|
||||||
|
{
|
||||||
|
var post = CreateDataModel(Guid.NewGuid().ToString(), 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(), Guid.NewGuid().ToString(), "name", PostType.Manager, 0, true, DateTime.UtcNow);
|
||||||
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
post = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "name", PostType.Manager, -10, true, DateTime.UtcNow);
|
||||||
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AllFieldsIsCorrectTest()
|
||||||
|
{
|
||||||
|
var postId = Guid.NewGuid().ToString();
|
||||||
|
var postPostId = Guid.NewGuid().ToString();
|
||||||
|
var postName = "name";
|
||||||
|
var postType = PostType.Manager;
|
||||||
|
var salary = 10;
|
||||||
|
var isActual = false;
|
||||||
|
var changeDate = DateTime.UtcNow.AddDays(-1);
|
||||||
|
var post = CreateDataModel(postId, postPostId, postName, postType, salary, isActual, changeDate);
|
||||||
|
Assert.That(() => post.Validate(), Throws.Nothing);
|
||||||
|
Assert.Multiple(() =>
|
||||||
|
{
|
||||||
|
Assert.That(post.Id, Is.EqualTo(postId));
|
||||||
|
Assert.That(post.PostId, Is.EqualTo(postPostId));
|
||||||
|
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? id, string? postId, string? postName, PostType postType, double salary, bool isActual, DateTime changeDate) =>
|
||||||
|
new(id, postId, postName, postType, salary, isActual, changeDate);
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
using MagicCarpetContracts.DataModels;
|
||||||
|
using MagicCarpetContracts.Exceptions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MagicCarpetTests.DataModelTests;
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
internal class SalaryDataModelTests
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void EmployeeIdIsEmptyTest()
|
||||||
|
{
|
||||||
|
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 EmployeeIdIsNotGuidTest()
|
||||||
|
{
|
||||||
|
var salary = CreateDataModel("employeeId", 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 employeeId = Guid.NewGuid().ToString();
|
||||||
|
var salaryDate = DateTime.Now.AddDays(-3).AddMinutes(-5);
|
||||||
|
var enployeeSalary = 10;
|
||||||
|
var salary = CreateDataModel(employeeId, salaryDate, enployeeSalary);
|
||||||
|
Assert.That(() => salary.Validate(), Throws.Nothing);
|
||||||
|
Assert.Multiple(() =>
|
||||||
|
{
|
||||||
|
Assert.That(salary.EmployeeId, Is.EqualTo(employeeId));
|
||||||
|
Assert.That(salary.SalaryDate, Is.EqualTo(salaryDate));
|
||||||
|
Assert.That(salary.Salary, Is.EqualTo(enployeeSalary));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SalaryDataModel CreateDataModel(string? employeeId, DateTime salaryDate, double employeeSalary) =>
|
||||||
|
new(employeeId, salaryDate, employeeSalary);
|
||||||
|
}
|
@ -0,0 +1,103 @@
|
|||||||
|
using MagicCarpetContracts.DataModels;
|
||||||
|
using MagicCarpetContracts.Enums;
|
||||||
|
using MagicCarpetContracts.Exceptions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MagicCarpetTests.DataModelTests;
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
internal class SaleDataModelTests
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void IdIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var sale = CreateDataModel(null, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 10, DiscountType.OnSale, 10, false, CreateSubDataModel());
|
||||||
|
Assert.That(() => sale.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
sale = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 10, DiscountType.OnSale, 10, false, CreateSubDataModel());
|
||||||
|
Assert.That(() => sale.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IdIsNotGuidTest()
|
||||||
|
{
|
||||||
|
var sale = CreateDataModel("id", Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 10, DiscountType.OnSale, 10, false, CreateSubDataModel());
|
||||||
|
Assert.That(() => sale.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
[Test]
|
||||||
|
public void EmployeeIdIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var sale = CreateDataModel(Guid.NewGuid().ToString(), null, Guid.NewGuid().ToString(), 10, DiscountType.OnSale, 10, false, CreateSubDataModel());
|
||||||
|
Assert.That(() => sale.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
sale = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, Guid.NewGuid().ToString(), 10, DiscountType.OnSale, 10, false, CreateSubDataModel());
|
||||||
|
Assert.That(() => sale.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void EmployeeIdIsNotGuidTest()
|
||||||
|
{
|
||||||
|
var sale = CreateDataModel(Guid.NewGuid().ToString(), "employeeId", Guid.NewGuid().ToString(), 10, DiscountType.OnSale, 10, false, CreateSubDataModel());
|
||||||
|
Assert.That(() => sale.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ClientIdIsNotGuidTest()
|
||||||
|
{
|
||||||
|
var sale = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "clientId", 10, DiscountType.OnSale, 10, false, CreateSubDataModel());
|
||||||
|
Assert.That(() => sale.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SumIsLessOrZeroTest()
|
||||||
|
{
|
||||||
|
var sale = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 0, DiscountType.OnSale, 10, false, CreateSubDataModel());
|
||||||
|
Assert.That(() => sale.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
sale = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), -10, DiscountType.OnSale, 10, false, CreateSubDataModel());
|
||||||
|
Assert.That(() => sale.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ToursIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var sale = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 10, DiscountType.OnSale, 10, false, null);
|
||||||
|
Assert.That(() => sale.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
sale = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 10, DiscountType.OnSale, 10, false, []);
|
||||||
|
Assert.That(() => sale.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AllFieldsIsCorrectTest()
|
||||||
|
{
|
||||||
|
var saleId = Guid.NewGuid().ToString();
|
||||||
|
var employeeId = Guid.NewGuid().ToString();
|
||||||
|
var clientId = Guid.NewGuid().ToString();
|
||||||
|
var sum = 10;
|
||||||
|
var discountType = DiscountType.Certificate;
|
||||||
|
var discount = 1;
|
||||||
|
var isCancel = true;
|
||||||
|
var tours = CreateSubDataModel();
|
||||||
|
var sale = CreateDataModel(saleId, employeeId, clientId, sum, discountType, discount, isCancel, tours);
|
||||||
|
Assert.That(() => sale.Validate(), Throws.Nothing);
|
||||||
|
Assert.Multiple(() =>
|
||||||
|
{
|
||||||
|
Assert.That(sale.Id, Is.EqualTo(saleId));
|
||||||
|
Assert.That(sale.EmployeeId, Is.EqualTo(employeeId));
|
||||||
|
Assert.That(sale.ClientId, Is.EqualTo(clientId));
|
||||||
|
Assert.That(sale.Sum, Is.EqualTo(sum));
|
||||||
|
Assert.That(sale.DiscountType, Is.EqualTo(discountType));
|
||||||
|
Assert.That(sale.Discount, Is.EqualTo(discount));
|
||||||
|
Assert.That(sale.IsCancel, Is.EqualTo(isCancel));
|
||||||
|
Assert.That(sale.Tours, Is.EquivalentTo(tours));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SaleDataModel CreateDataModel(string? id, string? employeeId, string? clientId, double sum, DiscountType discountType,
|
||||||
|
double discount, bool isCancel, List<SaleTourDataModel>? tours) =>
|
||||||
|
new(id, employeeId, clientId, sum, discountType, discount, isCancel, tours);
|
||||||
|
|
||||||
|
private static List<SaleTourDataModel> CreateSubDataModel()
|
||||||
|
=> [new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 1)];
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
using MagicCarpetContracts.DataModels;
|
||||||
|
using MagicCarpetContracts.Exceptions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MagicCarpetTests.DataModelTests;
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
internal class SaleTourDataModelTests
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void SaleIdIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var saleTour = CreateDataModel(null, Guid.NewGuid().ToString(), 10);
|
||||||
|
Assert.That(() => saleTour.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
saleTour = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), 10);
|
||||||
|
Assert.That(() => saleTour.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SaleIdIsNotGuidTest()
|
||||||
|
{
|
||||||
|
var saleTour = CreateDataModel("saleId", Guid.NewGuid().ToString(), 10);
|
||||||
|
Assert.That(() => saleTour.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CocktailIdIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var saleTour = CreateDataModel(Guid.NewGuid().ToString(), null, 10);
|
||||||
|
Assert.That(() => saleTour.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
saleTour = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), 10);
|
||||||
|
Assert.That(() => saleTour.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ProductIdIsNotGuidTest()
|
||||||
|
{
|
||||||
|
var saleTour = CreateDataModel(Guid.NewGuid().ToString(), "productId", 10);
|
||||||
|
Assert.That(() => saleTour.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CountIsLessOrZeroTest()
|
||||||
|
{
|
||||||
|
var saleTour = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 0);
|
||||||
|
Assert.That(() => saleTour.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
saleTour = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), -10);
|
||||||
|
Assert.That(() => saleTour.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AllFieldsIsCorrectTest()
|
||||||
|
{
|
||||||
|
var saleId = Guid.NewGuid().ToString();
|
||||||
|
var tourId = Guid.NewGuid().ToString();
|
||||||
|
var count = 10;
|
||||||
|
var saleCocktail = CreateDataModel(saleId, tourId, count);
|
||||||
|
Assert.That(() => saleCocktail.Validate(), Throws.Nothing);
|
||||||
|
Assert.Multiple(() =>
|
||||||
|
{
|
||||||
|
Assert.That(saleCocktail.SaleId, Is.EqualTo(saleId));
|
||||||
|
Assert.That(saleCocktail.TourId, Is.EqualTo(tourId));
|
||||||
|
Assert.That(saleCocktail.Count, Is.EqualTo(count));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SaleTourDataModel CreateDataModel(string? saleId, string? tourId, int count) =>
|
||||||
|
new(saleId, tourId, count);
|
||||||
|
}
|
@ -0,0 +1,84 @@
|
|||||||
|
using MagicCarpetContracts.DataModels;
|
||||||
|
using MagicCarpetContracts.Enums;
|
||||||
|
using MagicCarpetContracts.Exceptions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MagicCarpetTests.DataModelTests;
|
||||||
|
|
||||||
|
internal class TourDataModelTests
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void IdIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var cocktail = CreateDataModel(null, "name", "country", 10.5, TourType.Beach);
|
||||||
|
Assert.That(() => cocktail.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
cocktail = CreateDataModel(string.Empty, "name", "country", 10.5, TourType.Beach);
|
||||||
|
Assert.That(() => cocktail.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IdIsNotGuidTest()
|
||||||
|
{
|
||||||
|
var cocktail = CreateDataModel("id", "name", "country", 10.5, TourType.Beach);
|
||||||
|
Assert.That(() => cocktail.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TourNameIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var cocktail = CreateDataModel(Guid.NewGuid().ToString(), null, "country", 10.5, TourType.Beach);
|
||||||
|
Assert.That(() => cocktail.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
cocktail = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, "country", 10.5, TourType.Beach);
|
||||||
|
Assert.That(() => cocktail.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
public void TourCountryIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var cocktail = CreateDataModel(Guid.NewGuid().ToString(), "name", null, 10.5, TourType.Beach);
|
||||||
|
Assert.That(() => cocktail.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
cocktail = CreateDataModel(Guid.NewGuid().ToString(), "name", string.Empty, 10.5, TourType.Beach);
|
||||||
|
Assert.That(() => cocktail.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void PriceIsLessOrZeroTest()
|
||||||
|
{
|
||||||
|
var cocktail = CreateDataModel(Guid.NewGuid().ToString(), null, null, 0, TourType.Beach);
|
||||||
|
Assert.That(() => cocktail.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
cocktail = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, string.Empty, -10.5, TourType.Beach);
|
||||||
|
Assert.That(() => cocktail.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TourTypeIsNoneTest()
|
||||||
|
{
|
||||||
|
var cocktail = CreateDataModel(Guid.NewGuid().ToString(), null, null, 0, TourType.Beach);
|
||||||
|
Assert.That(() => cocktail.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AllFieldsIsCorrectTest()
|
||||||
|
{
|
||||||
|
var tourId = Guid.NewGuid().ToString();
|
||||||
|
var tourName = "name";
|
||||||
|
var tourCountry = "country";
|
||||||
|
var price = 10.5;
|
||||||
|
var tourType = TourType.Ski;
|
||||||
|
var tour = CreateDataModel(tourId, tourName, tourCountry, price, tourType);
|
||||||
|
Assert.That(() => tour.Validate(), Throws.Nothing);
|
||||||
|
Assert.Multiple(() =>
|
||||||
|
{
|
||||||
|
Assert.That(tour.Id, Is.EqualTo(tourId));
|
||||||
|
Assert.That(tour.TourName, Is.EqualTo(tourName));
|
||||||
|
Assert.That(tour.TourCountry, Is.EqualTo(tourCountry));
|
||||||
|
Assert.That(tour.Price, Is.EqualTo(price));
|
||||||
|
Assert.That(tour.Type, Is.EqualTo(tourType));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TourDataModel CreateDataModel(string? id, string? tourName, string? countryName,double price, TourType tourType) =>
|
||||||
|
new(id, tourName, countryName,price, tourType);
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
using MagicCarpetContracts.DataModels;
|
||||||
|
using MagicCarpetContracts.Exceptions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MagicCarpetTests.DataModelTests;
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
internal class TourHistoryDataModelTests
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void CocktailIdIsNullOrEmptyTest()
|
||||||
|
{
|
||||||
|
var tour = CreateDataModel(null, 10);
|
||||||
|
Assert.That(() => tour.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
tour = CreateDataModel(string.Empty, 10);
|
||||||
|
Assert.That(() => tour.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ProductIdIsNotGuidTest()
|
||||||
|
{
|
||||||
|
var tour = CreateDataModel("id", 10);
|
||||||
|
Assert.That(() => tour.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void OldPriceIsLessOrZeroTest()
|
||||||
|
{
|
||||||
|
var tour = CreateDataModel(Guid.NewGuid().ToString(), 0);
|
||||||
|
Assert.That(() => tour.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
tour = CreateDataModel(Guid.NewGuid().ToString(), -10);
|
||||||
|
Assert.That(() => tour.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AllFieldsIsCorrectTest()
|
||||||
|
{
|
||||||
|
var tourId = Guid.NewGuid().ToString();
|
||||||
|
var oldPrice = 10;
|
||||||
|
var tourHistory = CreateDataModel(tourId, oldPrice);
|
||||||
|
Assert.That(() => tourHistory.Validate(), Throws.Nothing);
|
||||||
|
Assert.Multiple(() =>
|
||||||
|
{
|
||||||
|
Assert.That(tourHistory.TourId, Is.EqualTo(tourId));
|
||||||
|
Assert.That(tourHistory.OldPrice, Is.EqualTo(oldPrice));
|
||||||
|
Assert.That(tourHistory.ChangeDate, Is.LessThan(DateTime.UtcNow));
|
||||||
|
Assert.That(tourHistory.ChangeDate, Is.GreaterThan(DateTime.UtcNow.AddMinutes(-1)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TourHistoryDataModel CreateDataModel(string? tourId, double oldPrice) =>
|
||||||
|
new(tourId, oldPrice);
|
||||||
|
}
|
@ -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="3.14.0" />
|
||||||
|
<PackageReference Include="NUnit.Analyzers" Version="3.9.0" />
|
||||||
|
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\MagicCarpetContracts\MagicCarpetContracts.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Using Include="NUnit.Framework" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
Loading…
x
Reference in New Issue
Block a user