public void GetOneAdministratorById() { var mockAdministrator = new Mock <IAdministratorLogic>(MockBehavior.Strict); mockAdministrator.Setup(res => res.Get(adminList[0].Id)).Returns(adminList[0]); var controller = new AdministratorController(mockAdministrator.Object); var result = controller.Get(adminList[0].Id); mockAdministrator.VerifyAll(); Assert.AreEqual(result.ToString(), new OkObjectResult("").ToString()); }
public void GetAllAdministratorReturnsAdminsInLogic() { var administrators = new List <Administrator> { AdministratorModel.ToEntity() }; var administratorsModel = administrators.Select(adm => new AdministratorBasicInfoModel(adm)); var administratorLogicMock = new Mock <IAdministratorLogic>(MockBehavior.Strict); administratorLogicMock.Setup(m => m.GetAll()).Returns(administrators); var administratorController = new AdministratorController(administratorLogicMock.Object); var result = administratorController.Get() as OkObjectResult; var content = result.Value as List <AdministratorBasicInfoModel>; Assert.IsTrue(content.SequenceEqual(administratorsModel)); administratorLogicMock.VerifyAll(); }
public void GetAllTest() { Administrator admin = new Administrator() { Email = "*****@*****.**", Password = "******" }; List <Administrator> expected = new List <Administrator>() { admin }; var mockAdministrator = new Mock <IAdministratorLogic>(MockBehavior.Strict); mockAdministrator.Setup(p => p.GetAll()).Returns(expected); var mockSession = new Mock <ISessionLogic>(MockBehavior.Strict); var controller = new AdministratorController(mockAdministrator.Object, mockSession.Object); var result = controller.Get() as OkObjectResult; mockAdministrator.VerifyAll(); Assert.AreEqual(200, result.StatusCode); }