add tests for email case
This commit is contained in:
parent
b05f91020b
commit
ac296c3b17
@ -352,6 +352,21 @@ internal class EmployeeBusinessLogicContractTest
|
|||||||
_employeeStorageContract.Verify(x => x.GetElementByFIO(It.IsAny<string>()), Times.Once);
|
_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]
|
[Test]
|
||||||
public void GetEmployeeByData_EmptyData_ThrowException_Test()
|
public void GetEmployeeByData_EmptyData_ThrowException_Test()
|
||||||
{
|
{
|
||||||
@ -380,6 +395,15 @@ internal class EmployeeBusinessLogicContractTest
|
|||||||
_employeeStorageContract.Verify(x => x.GetElementByFIO(It.IsAny<string>()), Times.Once);
|
_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]
|
[Test]
|
||||||
public void GetEmployeeByData_StorageThrowError_ThrowException_Test()
|
public void GetEmployeeByData_StorageThrowError_ThrowException_Test()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user