From ac296c3b1747b14a2fa0c97278aa9d0e8b74c21a Mon Sep 17 00:00:00 2001 From: Ivan Gutorov Date: Mon, 17 Feb 2025 18:23:10 +0400 Subject: [PATCH] add tests for email case --- .../EmployeeBusinessLogicContractTest.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/TheCyclopsProject/TheCyclopsTests/BusinessLogicsContractsTests/EmployeeBusinessLogicContractTest.cs b/TheCyclopsProject/TheCyclopsTests/BusinessLogicsContractsTests/EmployeeBusinessLogicContractTest.cs index 90bb78b..8de5004 100644 --- a/TheCyclopsProject/TheCyclopsTests/BusinessLogicsContractsTests/EmployeeBusinessLogicContractTest.cs +++ b/TheCyclopsProject/TheCyclopsTests/BusinessLogicsContractsTests/EmployeeBusinessLogicContractTest.cs @@ -352,6 +352,21 @@ internal class EmployeeBusinessLogicContractTest _employeeStorageContract.Verify(x => x.GetElementByFIO(It.IsAny()), Times.Once); } + [Test] + public void GetEmployeeByData_GetByEmail_ReturnRecord_Test() + { + //Arrange + var email = "email@mail.com"; + var record = new EmployeeDataModel(Guid.NewGuid().ToString(), "фио", email, Guid.NewGuid().ToString(), DateTime.Now.AddYears(-16).AddDays(-1), DateTime.Now, false); + _employeeStorageContract.Setup(x => x.GetElementByEmail(email)).Returns(record); + //Act + var element = _employeeBusinessLogicContract.GetEmployeeByData(email); + //Assert + Assert.That(element, Is.Not.Null); + Assert.That(element.Email, Is.EqualTo(email)); + _employeeStorageContract.Verify(x => x.GetElementByEmail(It.IsAny()), Times.Once); + } + [Test] public void GetEmployeeByData_EmptyData_ThrowException_Test() { @@ -380,6 +395,15 @@ internal class EmployeeBusinessLogicContractTest _employeeStorageContract.Verify(x => x.GetElementByFIO(It.IsAny()), Times.Once); } + [Test] + public void GetEmployeeByData_GetByEmail_NotFoundRecord_ThrowException_Test() + { + //Act&Assert + Assert.That(() => _employeeBusinessLogicContract.GetEmployeeByData("email@mail.com"), Throws.TypeOf()); + _employeeStorageContract.Verify(x => x.GetElementById(It.IsAny()), Times.Never); + _employeeStorageContract.Verify(x => x.GetElementByEmail(It.IsAny()), Times.Once); + } + [Test] public void GetEmployeeByData_StorageThrowError_ThrowException_Test() {