public async Task EditUser_returns_model_with_availableRoles_when_session_is_empty_correct_modue_code() { //Arrange Guid moduleId = Guid.NewGuid(); Operation operation = new Operation //Creating an object of Operation model { Code = "ADD", Deleted = false, Id = Guid.NewGuid(), ModuleId = moduleId, Name = "Add Operation" }; Module module = new Module //Creating an object of Module model with an invalid ModuleCode { Code = "USERS", Deleted = false, Id = moduleId, Name = "Users", Operations = new List <IA.Client.ClientModels.IOperation> { operation } }; var controller = ConfigureController(true, true, new List <Module> { module }); //Act var result = await controller.EditUser("f4EcNSUeWjAwPTPMefW2659w3FX3EtblPwy0AMKAEFTgXn0o2OPxDjar0+K7zL/P1VIHQbODgHzP1hJpqcbpVQ=="); //Assert var viewResult = Assert.IsType <ViewResult>(result); //Asserting that the return is a View Assert.Equal("EditUser", viewResult.ViewName); //Asserting that the returned Controller is "EditUser" dynamic model = Assert.IsAssignableFrom <ExpandoObject>(viewResult.ViewData.Model); //Asserting values of the returned model Assert.NotNull(model.CurrentModuleId); //CurrentModuleId is NOT empty Assert.True(model.Operations.Length > 0); //Looking for operations Assert.NotNull(model.ModuleOperations); Assert.NotNull(model.Initials); Assert.NotNull(model.Username); Assert.NotNull(model.Roles); Assert.NotNull(model.UserList); Assert.NotNull(model.AvailableRoles); }
public async Task AddNewUser_returns_non_null_model_when_claims_and_sessions_are_not_empty_correct_module_code() { //Arrange Guid moduleId = Guid.NewGuid(); Operation operation = new Operation //Creating an object of Operation model { Code = "ADD", Deleted = false, Id = Guid.NewGuid(), ModuleId = moduleId, Name = "Add Operation" }; Module module = new Module //Creating an object of Module model with an invalid ModuleCode { Code = "USERS", Deleted = false, Id = moduleId, Name = "Users", Operations = new List <IA.Client.ClientModels.IOperation> { operation } }; var controller = ConfigureController(true, true, new List <Module> { module }); //Act var result = await controller.AddNewUser(); //Assert var viewResult = Assert.IsType <ViewResult>(result); //Asserting that the return is a View Assert.Equal("AddUser", viewResult.ViewName); //Asseting that the returned view is "AddUser" dynamic model = Assert.IsAssignableFrom <ExpandoObject>(viewResult.ViewData.Model); //Asserting various values of the returned model Assert.NotEqual(Guid.Empty, model.CurrentModuleId); //Asserting that CurrentModuleId is Empty Guid Assert.NotNull(model.Operations); //Asserting that there are some operations associated Assert.NotNull(model.ModuleOperations); Assert.NotNull(model.Initials); Assert.NotNull(model.Username); Assert.NotNull(model.Roles); Assert.NotNull(model.UserList); Assert.NotNull(model.AvailableRoles); }
public async Task EditRole_returns_index_when_roleid_is_null() { //Arrange Guid moduleId = Guid.NewGuid(); Operation operation = new Operation //Creating an object of Operation model { Code = "ADD", Deleted = false, Id = Guid.NewGuid(), ModuleId = moduleId, Name = "Add Operation" }; Module module = new Module //Creating an object of Module model with an invalid ModuleCode { Code = "ROLES", Deleted = false, Id = moduleId, Name = "Module Name", Operations = new List <IA.Client.ClientModels.IOperation> { operation } }; var controller = ConfigureController(true, true, null, new List <Module> { module }); //Act var result = await controller.EditRole(null); //Assert var viewResult = Assert.IsType <ViewResult>(result); //Asserting that the return is a View Assert.Equal("Index", viewResult.ViewName); //Asserting that that the returned view is "Index" Assert.True(controller.ViewData.ModelState.Count == 1); //Asserts that there is a ModelStateError object dynamic model = Assert.IsAssignableFrom <ExpandoObject>(viewResult.ViewData.Model); Assert.NotNull(model.CurrentModuleId); Assert.True(model.Operations.Length > 0); Assert.NotNull(model.ModuleOperations); Assert.NotNull(model.Initials); Assert.NotNull(model.Username); Assert.NotNull(model.Roles); Assert.NotNull(model.RoleList); }
public async Task ChangePassword_returns_non_null_model_when_claims_and_sessions_are_not_empty_correct_module_code() { //Arrange Guid moduleId = Guid.NewGuid(); Operation operation = new Operation //Creating an object of Operation model { Code = "ADD", Deleted = false, Id = Guid.NewGuid(), ModuleId = moduleId, Name = "Add Operation" }; Module module = new Module //Creating an object of Module model with an invalid ModuleCode { Code = "MYPFL", Deleted = false, Id = moduleId, Name = "Profile", Operations = new List <IA.Client.ClientModels.IOperation> { operation } }; var controller = ConfigureController(true, true, null, new List <Module> { module }); //Act var result = await controller.ChangePassword(); //Assert var viewResult = Assert.IsType <ViewResult>(result); //Asserting that the return is a View Assert.Equal("ChangePassword", viewResult.ViewName); dynamic model = Assert.IsAssignableFrom <ExpandoObject>(viewResult.ViewData.Model); Assert.Null(model.UserInfo); Assert.NotNull(model.CurrentModuleId); Assert.NotNull(model.Operations); Assert.NotNull(model.ModuleOperations); Assert.NotNull(model.Initials); Assert.NotNull(model.Username); Assert.NotNull(model.Roles); }
public async Task Index_returns_non_null_model_when_claims_and_sessions_are_not_empty_incorrect_module_code() { //Arrange Guid moduleId = Guid.NewGuid(); Operation operation = new Operation //Creating an object of Operation model { Code = "ADD", Deleted = false, Id = Guid.NewGuid(), ModuleId = moduleId, Name = "Add Operation" }; Module module = new Module //Creating an object of Module model with an invalid ModuleCode { Code = "SOMEMODULECODE", Deleted = false, Id = moduleId, Name = "Module Name", Operations = new List <IA.Client.ClientModels.IOperation> { operation } }; var controller = ConfigureController(true, true, new List <Module> { module }); //Act var result = await controller.Index(); //Assert var viewResult = Assert.IsType <ViewResult>(result); //Asserting that the return is a View dynamic model = Assert.IsAssignableFrom <ExpandoObject>(viewResult.ViewData.Model); //Asserting various values of the returned model Assert.Equal(Guid.Empty, model.CurrentModuleId); //CurrentModuleId is empty Assert.True(model.Operations.Length == 0); //Asserting that there are no operations Assert.NotNull(model.ModuleOperations); Assert.NotNull(model.Initials); Assert.NotNull(model.Username); Assert.NotNull(model.Roles); Assert.NotNull(model.UserList); }
public async Task EditRole_returns_errorpage_when_claims_and_sessions_are_not_empty() { //Arrange Guid moduleId = Guid.NewGuid(); Operation operation = new Operation //Creating an object of Operation model { Code = "ADD", Deleted = false, Id = Guid.NewGuid(), ModuleId = moduleId, Name = "Add Operation" }; Module module = new Module //Creating an object of Module model with an invalid ModuleCode { Code = "ROLES", Deleted = false, Id = moduleId, Name = "Module Name", Operations = new List <IA.Client.ClientModels.IOperation> { operation } }; var controller = ConfigureController(true, true, null, new List <Module> { module }); //Act var result = await controller.EditRole(Guid.NewGuid().ToString()); //Assert var viewResult = Assert.IsType <ViewResult>(result); //Asserting that the return is a View Assert.Equal("ErrorPage", viewResult.ViewName); //Asserting that the returned view is ErrorPage dynamic model = Assert.IsAssignableFrom <ExpandoObject>(viewResult.ViewData.Model); Assert.NotNull(model.Message); Assert.Contains("No role exists with the provided Id", model.Message); }