PIbd-23 Gutorov I.A. Second LabWork #3

Open
vasmaae wants to merge 17 commits from Task_2_BusinessLogic into Task_1_Models
Showing only changes of commit ac296c3b17 - Show all commits

View File

@ -352,6 +352,21 @@ internal class EmployeeBusinessLogicContractTest
_employeeStorageContract.Verify(x => x.GetElementByFIO(It.IsAny<string>()), 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<string>()), Times.Once);
}
[Test]
public void GetEmployeeByData_EmptyData_ThrowException_Test()
{
@ -380,6 +395,15 @@ internal class EmployeeBusinessLogicContractTest
_employeeStorageContract.Verify(x => x.GetElementByFIO(It.IsAny<string>()), Times.Once);
}
[Test]
public void GetEmployeeByData_GetByEmail_NotFoundRecord_ThrowException_Test()
{
//Act&Assert
Assert.That(() => _employeeBusinessLogicContract.GetEmployeeByData("email@mail.com"), Throws.TypeOf<ElementNotFoundException>());
_employeeStorageContract.Verify(x => x.GetElementById(It.IsAny<string>()), Times.Never);
_employeeStorageContract.Verify(x => x.GetElementByEmail(It.IsAny<string>()), Times.Once);
}
[Test]
public void GetEmployeeByData_StorageThrowError_ThrowException_Test()
{