Я сдаль
This commit is contained in:
parent
5c281157cb
commit
c9359593b5
@ -1,34 +0,0 @@
|
|||||||
using PapaCarloContracts.Extensions;
|
|
||||||
using PapaCarloContracts.infrastructure;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Numerics;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
||||||
using System.Xml;
|
|
||||||
using PapaCarloContracts.Exceptions;
|
|
||||||
|
|
||||||
namespace PapaCarloContracts.DataModels;
|
|
||||||
|
|
||||||
public class BuyerDataModel(string id, string fio, string phoneNumber) : IValidation
|
|
||||||
{
|
|
||||||
public string Id { get; private set; } = id;
|
|
||||||
public string FIO { get; private set; } = fio;
|
|
||||||
public string PhoneNumber { get; private set; } = phoneNumber;
|
|
||||||
public void Validate()
|
|
||||||
{
|
|
||||||
if (Id.IsEmpty())
|
|
||||||
throw new ValidationException("Field Id is empty");
|
|
||||||
if (!Id.IsGuid())
|
|
||||||
throw new ValidationException("The value in the field Id is not a unique identifier");
|
|
||||||
if (FIO.IsEmpty())
|
|
||||||
throw new ValidationException("Field FIO is empty");
|
|
||||||
if (PhoneNumber.IsEmpty())
|
|
||||||
throw new ValidationException("Field PhoneNumber is empty");
|
|
||||||
if (!Regex.IsMatch(PhoneNumber, @"^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\-]?)?[\d\- ]{7,10}$"))
|
|
||||||
throw new ValidationException("Field PhoneNumber is not a phone number");
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,7 +10,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace PapaCarloContracts.DataModels;
|
namespace PapaCarloContracts.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,bool isActual, DateTime changeDate) : IValidation
|
||||||
{
|
{
|
||||||
public string Id { get; private set; } = id;
|
public string Id { get; private set; } = id;
|
||||||
|
|
||||||
@ -20,7 +20,6 @@ public class PostDataModel(string id, string postId, string postName, PostType p
|
|||||||
|
|
||||||
public PostType PostType { get; private set; } = postType;
|
public PostType PostType { get; private set; } = postType;
|
||||||
|
|
||||||
public double Salary { get; private set; } = salary;
|
|
||||||
|
|
||||||
public bool IsActual { get; private set; } = isActual;
|
public bool IsActual { get; private set; } = isActual;
|
||||||
|
|
||||||
@ -46,7 +45,5 @@ public class PostDataModel(string id, string postId, string postName, PostType p
|
|||||||
if (PostType == PostType.None)
|
if (PostType == PostType.None)
|
||||||
throw new ValidationException("Field PostType is empty");
|
throw new ValidationException("Field PostType is empty");
|
||||||
|
|
||||||
if (Salary <= 0)
|
|
||||||
throw new ValidationException("Field Salary is empty");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace PapaCarloContracts.DataModels;
|
namespace PapaCarloContracts.DataModels;
|
||||||
|
|
||||||
public class ProductDataModel(string id, string productName, ProductType productType, string blankId, double price, bool isDeleted) : IValidation
|
public class ProductDataModel(string id, string productName, ProductType productType, double price, bool isDeleted) : IValidation
|
||||||
{
|
{
|
||||||
public string Id { get; private set; } = id;
|
public string Id { get; private set; } = id;
|
||||||
|
|
||||||
@ -18,7 +18,6 @@ public class ProductDataModel(string id, string productName, ProductType product
|
|||||||
|
|
||||||
public ProductType ProductType { get; private set; } = productType;
|
public ProductType ProductType { get; private set; } = productType;
|
||||||
|
|
||||||
public string BlankId { get; private set; } = blankId;
|
|
||||||
|
|
||||||
public double Price { get; private set; } = price;
|
public double Price { get; private set; } = price;
|
||||||
|
|
||||||
@ -38,12 +37,6 @@ public class ProductDataModel(string id, string productName, ProductType product
|
|||||||
if (ProductType == ProductType.None)
|
if (ProductType == ProductType.None)
|
||||||
throw new ValidationException("Field ProductType is empty");
|
throw new ValidationException("Field ProductType is empty");
|
||||||
|
|
||||||
if (BlankId.IsEmpty())
|
|
||||||
throw new ValidationException("Field ManufacturerId is empty");
|
|
||||||
|
|
||||||
if (!BlankId.IsGuid())
|
|
||||||
throw new ValidationException("The value in the field ManufacturerId is not a unique identifier");
|
|
||||||
|
|
||||||
if (Price <= 0)
|
if (Price <= 0)
|
||||||
throw new ValidationException("Field Price is less than or equal to 0");
|
throw new ValidationException("Field Price is less than or equal to 0");
|
||||||
}
|
}
|
||||||
|
@ -1,74 +0,0 @@
|
|||||||
using PapaCarloContracts.DataModels;
|
|
||||||
using PapaCarloContracts.Exceptions;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace PapaCarloTests.DataModelsTests;
|
|
||||||
|
|
||||||
[TestFixture]
|
|
||||||
internal class BuyerDataModelTests
|
|
||||||
{
|
|
||||||
[Test]
|
|
||||||
public void IdIsNullOrEmptyTest()
|
|
||||||
{
|
|
||||||
var buyer = CreateDataModel(null, "fio", "number");
|
|
||||||
Assert.That(() => buyer.Validate(), Throws.TypeOf<ValidationException>());
|
|
||||||
buyer = CreateDataModel(string.Empty, "fio", "number");
|
|
||||||
Assert.That(() => buyer.Validate(), Throws.TypeOf<ValidationException>());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void IdIsNotGuidTest()
|
|
||||||
{
|
|
||||||
var buyer = CreateDataModel("id", "fio", "number");
|
|
||||||
Assert.That(() => buyer.Validate(), Throws.TypeOf<ValidationException>());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void FIOIsNullOrEmptyTest()
|
|
||||||
{
|
|
||||||
var buyer = CreateDataModel(Guid.NewGuid().ToString(), null, "number");
|
|
||||||
Assert.That(() => buyer.Validate(), Throws.TypeOf<ValidationException>());
|
|
||||||
buyer = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, "number");
|
|
||||||
Assert.That(() => buyer.Validate(), Throws.TypeOf<ValidationException>());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void PhoneNumberIsNullOrEmptyTest()
|
|
||||||
{
|
|
||||||
var buyer = CreateDataModel(Guid.NewGuid().ToString(), "fio", null);
|
|
||||||
Assert.That(() => buyer.Validate(), Throws.TypeOf<ValidationException>());
|
|
||||||
buyer = CreateDataModel(Guid.NewGuid().ToString(), "fio", string.Empty);
|
|
||||||
Assert.That(() => buyer.Validate(), Throws.TypeOf<ValidationException>());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void PhoneNumberIsIncorrectTest()
|
|
||||||
{
|
|
||||||
var buyer = CreateDataModel(Guid.NewGuid().ToString(), "fio", "777");
|
|
||||||
Assert.That(() => buyer.Validate(), Throws.TypeOf<ValidationException>());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void AllFieldsIsCorrectTest()
|
|
||||||
{
|
|
||||||
var buyerId = Guid.NewGuid().ToString();
|
|
||||||
var fio = "Fio";
|
|
||||||
var phoneNumber = "+7-777-777-77-77";
|
|
||||||
var buyer = CreateDataModel(buyerId, fio, phoneNumber);
|
|
||||||
Assert.That(() => buyer.Validate(), Throws.Nothing);
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(buyer.Id, Is.EqualTo(buyerId));
|
|
||||||
Assert.That(buyer.FIO, Is.EqualTo(fio));
|
|
||||||
Assert.That(buyer.PhoneNumber, Is.EqualTo(phoneNumber));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static BuyerDataModel CreateDataModel(string? id, string? fio, string? phoneNumber) =>
|
|
||||||
new(id, fio, phoneNumber);
|
|
||||||
|
|
||||||
}
|
|
@ -15,57 +15,48 @@ internal class PostDataModelTests
|
|||||||
[Test]
|
[Test]
|
||||||
public void IdIsNullOrEmptyTest()
|
public void IdIsNullOrEmptyTest()
|
||||||
{
|
{
|
||||||
var post = CreateDataModel(null, Guid.NewGuid().ToString(), "name", PostType.Carpenter, 10, true, DateTime.UtcNow);
|
var post = CreateDataModel(null, Guid.NewGuid().ToString(), "name", PostType.Carpenter, true, DateTime.UtcNow);
|
||||||
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
post = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), "name", PostType.Carpenter, 10, true, DateTime.UtcNow);
|
post = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), "name", PostType.Carpenter, true, DateTime.UtcNow);
|
||||||
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void IdIsNotGuidTest()
|
public void IdIsNotGuidTest()
|
||||||
{
|
{
|
||||||
var post = CreateDataModel("id", Guid.NewGuid().ToString(), "name", PostType.Carpenter, 10, true, DateTime.UtcNow);
|
var post = CreateDataModel("id", Guid.NewGuid().ToString(), "name", PostType.Carpenter, true, DateTime.UtcNow);
|
||||||
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void PostIdIsNullEmptyTest()
|
public void PostIdIsNullEmptyTest()
|
||||||
{
|
{
|
||||||
var post = CreateDataModel(Guid.NewGuid().ToString(), null, "name", PostType.Carpenter, 10, true, DateTime.UtcNow);
|
var post = CreateDataModel(Guid.NewGuid().ToString(), null, "name", PostType.Carpenter, true, DateTime.UtcNow);
|
||||||
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
post = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, "name", PostType.Carpenter, 10, true, DateTime.UtcNow);
|
post = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, "name", PostType.Carpenter, true, DateTime.UtcNow);
|
||||||
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void PostIdIsNotGuidTest()
|
public void PostIdIsNotGuidTest()
|
||||||
{
|
{
|
||||||
var post = CreateDataModel(Guid.NewGuid().ToString(), "postId", "name", PostType.Carpenter, 10, true, DateTime.UtcNow);
|
var post = CreateDataModel(Guid.NewGuid().ToString(), "postId", "name", PostType.Carpenter, true, DateTime.UtcNow);
|
||||||
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void PostNameIsEmptyTest()
|
public void PostNameIsEmptyTest()
|
||||||
{
|
{
|
||||||
var manufacturer = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), null, PostType.Carpenter, 10, true, DateTime.UtcNow);
|
var manufacturer = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), null, PostType.Carpenter, true, DateTime.UtcNow);
|
||||||
Assert.That(() => manufacturer.Validate(), Throws.TypeOf<ValidationException>());
|
Assert.That(() => manufacturer.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
manufacturer = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), string.Empty, PostType.Carpenter, 10, true, DateTime.UtcNow);
|
manufacturer = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), string.Empty, PostType.Carpenter, true, DateTime.UtcNow);
|
||||||
Assert.That(() => manufacturer.Validate(), Throws.TypeOf<ValidationException>());
|
Assert.That(() => manufacturer.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void PostTypeIsNoneTest()
|
public void PostTypeIsNoneTest()
|
||||||
{
|
{
|
||||||
var post = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "name", PostType.None, 10, true, DateTime.UtcNow);
|
var post = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "name", PostType.None, 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.Carpenter, 0, true, DateTime.UtcNow);
|
|
||||||
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
|
||||||
post = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "name", PostType.Carpenter, -10, true, DateTime.UtcNow);
|
|
||||||
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,10 +67,9 @@ internal class PostDataModelTests
|
|||||||
var postPostId = Guid.NewGuid().ToString();
|
var postPostId = Guid.NewGuid().ToString();
|
||||||
var postName = "name";
|
var postName = "name";
|
||||||
var postType = PostType.Carpenter;
|
var postType = PostType.Carpenter;
|
||||||
var salary = 10;
|
|
||||||
var isActual = false;
|
var isActual = false;
|
||||||
var changeDate = DateTime.UtcNow.AddDays(-1);
|
var changeDate = DateTime.UtcNow.AddDays(-1);
|
||||||
var post = CreateDataModel(postId, postPostId, postName, postType, salary, isActual, changeDate);
|
var post = CreateDataModel(postId, postPostId, postName, postType,isActual, changeDate);
|
||||||
Assert.That(() => post.Validate(), Throws.Nothing);
|
Assert.That(() => post.Validate(), Throws.Nothing);
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
@ -87,12 +77,11 @@ internal class PostDataModelTests
|
|||||||
Assert.That(post.PostId, Is.EqualTo(postPostId));
|
Assert.That(post.PostId, Is.EqualTo(postPostId));
|
||||||
Assert.That(post.PostName, Is.EqualTo(postName));
|
Assert.That(post.PostName, Is.EqualTo(postName));
|
||||||
Assert.That(post.PostType, Is.EqualTo(postType));
|
Assert.That(post.PostType, Is.EqualTo(postType));
|
||||||
Assert.That(post.Salary, Is.EqualTo(salary));
|
|
||||||
Assert.That(post.IsActual, Is.EqualTo(isActual));
|
Assert.That(post.IsActual, Is.EqualTo(isActual));
|
||||||
Assert.That(post.ChangeDate, Is.EqualTo(changeDate));
|
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) =>
|
private static PostDataModel CreateDataModel(string? id, string? postId, string? postName, PostType postType, bool isActual, DateTime changeDate) =>
|
||||||
new(id, postId, postName, postType, salary, isActual, changeDate);
|
new(id, postId, postName, postType, isActual, changeDate);
|
||||||
}
|
}
|
||||||
|
@ -15,57 +15,42 @@ internal class ProductDataModelTests
|
|||||||
[Test]
|
[Test]
|
||||||
public void IdIsNullOrEmptyTest()
|
public void IdIsNullOrEmptyTest()
|
||||||
{
|
{
|
||||||
var product = CreateDataModel(null, "name", ProductType.Furniture, Guid.NewGuid().ToString(), 10, false);
|
var product = CreateDataModel(null, "name", ProductType.Furniture, 10, false);
|
||||||
Assert.That(() => product.Validate(), Throws.TypeOf<ValidationException>());
|
Assert.That(() => product.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
product = CreateDataModel(string.Empty, "name", ProductType.Furniture, Guid.NewGuid().ToString(), 10, false);
|
product = CreateDataModel(string.Empty, "name", ProductType.Furniture, 10, false);
|
||||||
Assert.That(() => product.Validate(), Throws.TypeOf<ValidationException>());
|
Assert.That(() => product.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void IdIsNotGuidTest()
|
public void IdIsNotGuidTest()
|
||||||
{
|
{
|
||||||
var product = CreateDataModel("id", "name", ProductType.Furniture, Guid.NewGuid().ToString(), 10, false);
|
var product = CreateDataModel("id", "name", ProductType.Furniture, 10, false);
|
||||||
Assert.That(() => product.Validate(), Throws.TypeOf<ValidationException>());
|
Assert.That(() => product.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void ProductNameIsEmptyTest()
|
public void ProductNameIsEmptyTest()
|
||||||
{
|
{
|
||||||
var product = CreateDataModel(Guid.NewGuid().ToString(), null, ProductType.Furniture, Guid.NewGuid().ToString(), 10, false);
|
var product = CreateDataModel(Guid.NewGuid().ToString(), null, ProductType.Furniture, 10, false);
|
||||||
Assert.That(() => product.Validate(), Throws.TypeOf<ValidationException>());
|
Assert.That(() => product.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
product = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, ProductType.Furniture, Guid.NewGuid().ToString(), 10, false);
|
product = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, ProductType.Furniture, 10, false);
|
||||||
Assert.That(() => product.Validate(), Throws.TypeOf<ValidationException>());
|
Assert.That(() => product.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void ProductTypeIsNoneTest()
|
public void ProductTypeIsNoneTest()
|
||||||
{
|
{
|
||||||
var product = CreateDataModel(Guid.NewGuid().ToString(), null, ProductType.None, Guid.NewGuid().ToString(), 10, false);
|
var product = CreateDataModel(Guid.NewGuid().ToString(), null, ProductType.None, 10, false);
|
||||||
Assert.That(() => product.Validate(), Throws.TypeOf<ValidationException>());
|
Assert.That(() => product.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void BlankIdIsNullOrEmptyTest()
|
|
||||||
{
|
|
||||||
var product = CreateDataModel(Guid.NewGuid().ToString(), "name", ProductType.Furniture, null, 10, false);
|
|
||||||
Assert.That(() => product.Validate(), Throws.TypeOf<ValidationException>());
|
|
||||||
product = CreateDataModel(Guid.NewGuid().ToString(), "name", ProductType.Furniture, string.Empty, 10, false);
|
|
||||||
Assert.That(() => product.Validate(), Throws.TypeOf<ValidationException>());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void BlankIdIsNotGuidTest()
|
|
||||||
{
|
|
||||||
var product = CreateDataModel(Guid.NewGuid().ToString(), "name", ProductType.Furniture, "blankId", 10, false);
|
|
||||||
Assert.That(() => product.Validate(), Throws.TypeOf<ValidationException>());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void PriceIsLessOrZeroTest()
|
public void PriceIsLessOrZeroTest()
|
||||||
{
|
{
|
||||||
var product = CreateDataModel(Guid.NewGuid().ToString(), "name", ProductType.Furniture, Guid.NewGuid().ToString(), 0, false);
|
var product = CreateDataModel(Guid.NewGuid().ToString(), "name", ProductType.Furniture, 0, false);
|
||||||
Assert.That(() => product.Validate(), Throws.TypeOf<ValidationException>());
|
Assert.That(() => product.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
product = CreateDataModel(Guid.NewGuid().ToString(), "name", ProductType.Furniture, Guid.NewGuid().ToString(), -10, false);
|
product = CreateDataModel(Guid.NewGuid().ToString(), "name", ProductType.Furniture, -10, false);
|
||||||
Assert.That(() => product.Validate(), Throws.TypeOf<ValidationException>());
|
Assert.That(() => product.Validate(), Throws.TypeOf<ValidationException>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,22 +60,20 @@ internal class ProductDataModelTests
|
|||||||
var productId = Guid.NewGuid().ToString();
|
var productId = Guid.NewGuid().ToString();
|
||||||
var productName = "name";
|
var productName = "name";
|
||||||
var productType = ProductType.Furniture;
|
var productType = ProductType.Furniture;
|
||||||
var productBlankId = Guid.NewGuid().ToString();
|
|
||||||
var productPrice = 10;
|
var productPrice = 10;
|
||||||
var productIsDelete = false;
|
var productIsDelete = false;
|
||||||
var product = CreateDataModel(productId, productName, productType, productBlankId, productPrice, productIsDelete);
|
var product = CreateDataModel(productId, productName, productType, productPrice, productIsDelete);
|
||||||
Assert.That(() => product.Validate(), Throws.Nothing);
|
Assert.That(() => product.Validate(), Throws.Nothing);
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(product.Id, Is.EqualTo(productId));
|
Assert.That(product.Id, Is.EqualTo(productId));
|
||||||
Assert.That(product.ProductName, Is.EqualTo(productName));
|
Assert.That(product.ProductName, Is.EqualTo(productName));
|
||||||
Assert.That(product.ProductType, Is.EqualTo(productType));
|
Assert.That(product.ProductType, Is.EqualTo(productType));
|
||||||
Assert.That(product.BlankId, Is.EqualTo(productBlankId));
|
|
||||||
Assert.That(product.Price, Is.EqualTo(productPrice));
|
Assert.That(product.Price, Is.EqualTo(productPrice));
|
||||||
Assert.That(product.IsDeleted, Is.EqualTo(productIsDelete));
|
Assert.That(product.IsDeleted, Is.EqualTo(productIsDelete));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ProductDataModel CreateDataModel(string? id, string? productName, ProductType productType, string? blankId, double price, bool isDeleted) =>
|
private static ProductDataModel CreateDataModel(string? id, string? productName, ProductType productType, double price, bool isDeleted) =>
|
||||||
new(id, productName, productType, blankId, price, isDeleted);
|
new(id, productName, productType, price, isDeleted);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user