public IActionResult CreateAdmin(AdministratorModelIn newAdministrator) { var administrator = newAdministrator.FromModelInToAdministrator(); this.administratorLogic.AddAdministrator(administrator); return(Ok("Administrator Created Successfully")); }
public void CreateAdminTest() { Administrator administrator = new Administrator() { Email = "*****@*****.**", Password = "******" }; AdministratorModelIn administratorModelIn = new AdministratorModelIn() { Email = administrator.Email, Password = administrator.Password }; string token = "token"; var mockAdministrator = new Mock <IAdministratorLogic>(MockBehavior.Strict); mockAdministrator.Setup(p => p.AddAdministrator(It.IsAny <Administrator>())).Returns(administrator); var mockSession = new Mock <ISessionLogic>(MockBehavior.Strict); var controller = new AdministratorController(mockAdministrator.Object, mockSession.Object); var result = controller.CreateAdmin(administratorModelIn) as OkObjectResult; mockAdministrator.VerifyAll(); Assert.AreEqual(200, result.StatusCode); }