public void enable_not_exists_admin() { Init(); // TEST: add new Admins without email to db Assert.ThrowsException <KeyNotFoundException>(() => { Admins.Enable("not_exist_user"); }); }
public void test_update_time_changing_if_enabled() { // TEST: testing update date and time changing, when IsActive has been changed Admins item = new Admins(); DateTime updateDateTime = item.UpdateDate; Thread.Sleep(50); item.Enable(); Assert.AreNotEqual(updateDateTime, item.UpdateDate); }
public void test_enable() { // TEST: testing enabling Admins item = new Admins() { Email = "email1", IsActive = false }; item.Enable(); Assert.IsTrue(item.IsActive.HasValue); Assert.IsTrue(item.IsActive.Value); }
public JsonResult enable([FromBody] string content) { try { Logger.Trace("AdminsController.enable IN"); HttpRequest Request = ControllerContext.HttpContext.Request; if (!Request.ContentType.Contains("application/json")) { return(new JsonResult(ResponseData.CONFLICT_409("Wrong content type. Content type must be 'application/json'")) { StatusCode = (int)System.Net.HttpStatusCode.Conflict }); } if (Request.Body.Length > 1000) { return(new JsonResult(ResponseData.CONFLICT_409("Big content. The data length must be less than 1000")) { StatusCode = (int)System.Net.HttpStatusCode.Conflict }); } RequestData requestData = RequestData.Deserialize(Request.Body); string Email = requestData.GetValue("email") as string; Logger.Debug($"AdminsController.enable Email = {Email}"); Admins.Enable(Email, db); Logger.Debug("AdminsController.enable deleted"); return(new JsonResult(ResponseData.OK_200()) { StatusCode = (int)System.Net.HttpStatusCode.OK }); } catch (ValidationException ex) { Logger.Error(ex, "Error in Admins.enable: ValidateError"); return(new JsonResult(ResponseData.CONFLICT_409(ex.Message)) { StatusCode = (int)System.Net.HttpStatusCode.Conflict }); } catch (Exception ex) { Logger.Error(ex, "Error in Admins.enable"); return(new JsonResult(ResponseData.INTERNAL_SERVER_ERROR_500()) { StatusCode = (int)System.Net.HttpStatusCode.InternalServerError }); } finally { Logger.Trace("AdminsController.enable OUT"); } }
private static void Interpreter_OnEnableUser(string UserName) { try { System.Console.WriteLine(string.Format("User '{0}' will be enabled", UserName)); Admins.Enable(UserName); } catch (KeyNotFoundException ex) { System.Console.WriteLine(" User not found"); } catch (Exception ex) { System.Console.WriteLine($"Enable user error: {ex}"); Logger.Error(ex, "Enable user error"); } }
public void enable_admin() { Init(); try { Admins.Add(item_disabled); Admins.Enable(item_disabled.Email); } catch (Exception ex) { Assert.Fail($"Failed TEST: add_good_item_to_db: {ex}"); } List <Admins> items = Admins.All(); Assert.AreEqual(items.Count, 1); Assert.AreEqual(items[0].IsActive, true); }