protected void Page_Load(object sender, EventArgs e) { notebookID = Request.QueryString["notebookID"]; if (notebookID == null || notebookID == "") { Response.Redirect("./Notebooks.aspx"); } try { Notebook notebook = GoogleFirestoreConnectionManager.GetNotebook(notebookID); NotebookTitle.InnerText = HttpUtility.UrlDecode(notebook.Title); if (notebook.Title != "Unfiled Notes") { DeleteNotebookButton.Visible = true; } if (IsPostBack) { GenerateNoteRows(GoogleFirestoreConnectionManager.GetNotebookNotes(notebookID)); } } catch (NotFoundException) { Response.Redirect("./Notebooks.aspx"); } }
private bool DeleteUserValidRequest(StreamWriter sw) { try { GoogleFirestoreConnectionManager.HandleLogin(userID1, displayName1, email1); if (!GoogleFirestoreConnectionManager.DeleteUser(userID1)) { sw.WriteLine("FAILED: DeleteUser(string userID): Normal test case."); return(false); } else { try { GoogleFirestoreConnectionManager.GetUser(userID1); sw.WriteLine("FAILED: DeleteUser(string userID): Normal test case - User still exists."); return(false); } catch { return(true); } } } catch { sw.WriteLine("FAILED: DeleteUser(string userID): Normal test case - unexpected exception."); return(false); } }
private bool NormalAccountCreation(StreamWriter sw) { bool passed = true; Models.User expected = new Models.User(userID1, displayName1, email1, DateTime.Now, DateTime.Now); Models.User result = null; GoogleFirestoreConnectionManager.DeleteUser(userID1); try { result = GoogleFirestoreConnectionManager.HandleLogin(userID1, displayName1, email1); } catch { sw.WriteLine("FAILED: Normal Account Creation; unexpected exception thrown."); return(false); } if (result == null) { sw.WriteLine("FAILED: Normal Account Creation; could not create user."); return(false); } if (expected.DisplayName != result.DisplayName || expected.ID != result.ID) { sw.WriteLine("FAILED: Normal Account Creation; user not created as expected."); passed = false; } GoogleFirestoreConnectionManager.DeleteUser(userID1); return(passed); }
protected List <HtmlGenericControl> GenerateNotebookDivs() { List <HtmlGenericControl> notebookDivs = new List <HtmlGenericControl>(); foreach (Notebook notebook in Notebooks) { HtmlGenericControl notebookDiv = new HtmlGenericControl("div"); notebookDiv.Attributes["class"] = "mainNotebooksDiv notebookColor"; notebookDiv.Attributes["onclick"] = "click_openNotebook(\"" + notebook.ID + "\")"; HtmlGenericControl titleDiv = new HtmlGenericControl("div"); titleDiv.Attributes["class"] = "mainNotebookInnerDiv mainNotebookTitleDiv"; titleDiv.InnerText = HttpUtility.UrlDecode(notebook.Title); notebookDiv.Controls.Add(titleDiv); HtmlGenericControl imageDiv = new HtmlGenericControl("div"); imageDiv.Attributes["class"] = "mainNotebookInnerDiv mainNotebookImageDiv"; HtmlGenericControl image = new HtmlGenericControl("img"); image.Attributes["src"] = HttpUtility.UrlDecode(notebook.CoverURL); image.Attributes["alt"] = HttpUtility.UrlDecode(notebook.Title) + " Cover Art"; image.Attributes["class"] = "mainNotebookImage"; imageDiv.Controls.Add(image); notebookDiv.Controls.Add(imageDiv); HtmlGenericControl numNotesDiv = new HtmlGenericControl("div"); numNotesDiv.Attributes["class"] = "mainNotebookInnerDiv mainNotebookNumNotesDiv"; numNotesDiv.InnerHtml = GoogleFirestoreConnectionManager.GetNotebookNotes(notebook.ID).Count.ToString() + (GoogleFirestoreConnectionManager.GetNotebookNotes(notebook.ID).Count == 1 ? " Note" : " Notes"); notebookDiv.Controls.Add(numNotesDiv); notebookDivs.Add(notebookDiv); } return(notebookDivs); }
public static void DeleteNote(string noteID) { if (noteID != null && noteID != "") { GoogleFirestoreConnectionManager.DeleteNote(noteID); } }
private bool DeleteNoteValidRequest(StreamWriter sw) { try { GoogleFirestoreConnectionManager.HandleLogin(userID1, displayName1, email1); Models.Notebook createdNotebook = GoogleFirestoreConnectionManager.CreateNotebook(userID1, notebook1.Title, notebook1.Author, notebook1.Isbn, notebook1.Publisher, notebook1.PublishDate, notebook1.CoverURL); Models.Note createdNote = GoogleFirestoreConnectionManager.CreateNote(userID1, createdNotebook.ID, text1); if (!GoogleFirestoreConnectionManager.DeleteNote(createdNote.ID)) { sw.WriteLine("FAILED: DeleteNote(string noteID): Normal test case 1."); GoogleFirestoreConnectionManager.DeleteUser(userID1); return(false); } else { try { GoogleFirestoreConnectionManager.GetNote(createdNote.ID); } catch (NotFoundException) { GoogleFirestoreConnectionManager.DeleteUser(userID1); return(true); } GoogleFirestoreConnectionManager.DeleteUser(userID1); return(false); } } catch { sw.WriteLine("FAILED: DeleteNote(string noteID): Normal test case 1 - unexpected exception."); return(false); } }
private bool NormalCreateNoteRequest(StreamWriter sw) { try { GoogleFirestoreConnectionManager.HandleLogin(userID1, displayName1, email1); Notebook createdNotebook = GoogleFirestoreConnectionManager.CreateNotebook(userID1, title1, author1, isbn1, publisher1, publishDate1, coverURL1); Note actual = GoogleFirestoreConnectionManager.CreateNote(userID1, createdNotebook.ID, text1); Note expected = new Note(actual.ID, userID1, createdNotebook.ID, text1, DateTime.Now, DateTime.Now); if (!expected.Equals(actual)) { sw.WriteLine("FAILED: CreateNote(string userID, string notebookID, string noteText): CreateNote normal test case."); GoogleFirestoreConnectionManager.DeleteUser(userID1); return(false); } else { GoogleFirestoreConnectionManager.DeleteUser(userID1); } } catch { sw.WriteLine("FAILED: CreateNote(string userID, string notebookID, string noteText): CreateNote normal test case - unexpected exception."); return(false); } return(true); }
private bool CreateNotebookByDetails(StreamWriter sw) { Setup(); try { GoogleFirestoreConnectionManager.HandleLogin(userID1, displayName1, email1); Notebook createdNotebook = CreateNotebook(userID1, notebook1.Title, notebook1.Author, notebook1.Isbn, notebook1.Publisher, notebook1.PublishDate, notebook1.CoverURL); if (!notebook1.Equals(createdNotebook)) { sw.WriteLine("FAILED: CreateNotebookByDetails"); if (createdNotebook != null) { DeleteNotebook(createdNotebook.ID); } return(false); } else { DeleteNotebook(createdNotebook.ID); } } catch { sw.WriteLine("FAILED: CreateNotebookByDetails: Unexpected exception"); return(false); } return(true); }
public void DeleteNotebook(object sender, EventArgs e) { if (notebookID != null && notebookID != "") { GoogleFirestoreConnectionManager.DeleteNotebook(notebookID); Response.Redirect("./Notebooks.aspx"); } }
private bool GetNotebooksValidRequest(StreamWriter sw) { try { GoogleFirestoreConnectionManager.DeleteUser(userID1); List <Models.Notebook> compNotebooks = new List <Models.Notebook> { notebook1, notebook2, notebook3, notebook4, notebook5 }; GoogleFirestoreConnectionManager.HandleLogin(userID1, displayName1, email1); GoogleFirestoreConnectionManager.CreateNotebook(userID1, title1, author1, isbn1, publisher1, publishDate1, coverURL1); GoogleFirestoreConnectionManager.CreateNotebook(userID1, title2, author2, isbn2, publisher2, publishDate2, coverURL2); GoogleFirestoreConnectionManager.CreateNotebook(userID1, title3, author3, isbn3, publisher3, publishDate3, coverURL3); GoogleFirestoreConnectionManager.CreateNotebook(userID1, title4, author4, isbn4, publisher4, publishDate4, coverURL4); GoogleFirestoreConnectionManager.CreateNotebook(userID1, title5, author5, isbn5, publisher5, publishDate5, coverURL5); List <Models.Notebook> tempNotebooks = GoogleFirestoreConnectionManager.GetNotebooks(userID1); if (tempNotebooks.Count != compNotebooks.Count + 1) // +1 because of the unfiled "notebook" { sw.WriteLine("FAILED: GetNotebooks(string userID): Normal test case, count mismatch."); GoogleFirestoreConnectionManager.DeleteUser(userID1); return(false); } else { foreach (Models.Notebook n in tempNotebooks) { foreach (Models.Notebook t in compNotebooks) { if (t.Equals(n)) { compNotebooks.Remove(t); break; } } } if (compNotebooks.Count > 0) { sw.WriteLine("FAILED: GetNotebooks(string userID): Normal test case, Notebooks not the same."); GoogleFirestoreConnectionManager.DeleteUser(userID1); return(false); } } GoogleFirestoreConnectionManager.DeleteUser(userID1); } catch { sw.WriteLine("FAILED: GetNotebooks(string userID): Normal test case - unexpected exception."); return(false); } return(true); }
private bool NullUidThrowsException(StreamWriter sw) { try { GoogleFirestoreConnectionManager.HandleLogin(null, displayName1, email1); sw.WriteLine("FAILED: Null Uid Throws Exception; exception not thrown."); return(false); } catch { return(true); } }
private bool EmptyDisplayNameThrowsException(StreamWriter sw) { try { GoogleFirestoreConnectionManager.HandleLogin(userID1, "", email1); sw.WriteLine("FAILED: Empty Display Name Throws Exception; exception not thrown."); return(false); } catch { return(true); } }
private bool UpdateNoteNoteTextIsEmpty(StreamWriter sw) { try { GoogleFirestoreConnectionManager.UpdateNote(noteID1, notebookID1, ""); sw.WriteLine("FAILED: UpdateNote(string noteID, string noteText): noteText is empty."); return(false); } catch { return(true); } }
private bool UpdateNoteNoteIdIsNull(StreamWriter sw) { try { GoogleFirestoreConnectionManager.UpdateNote(null, notebookID1, text2); sw.WriteLine("FAILED: UpdateNote(string noteID, string noteText): noteID is null test case."); return(false); } catch { return(true); } }
private bool UpdateNoteNoteDoesNotExist(StreamWriter sw) { try { GoogleFirestoreConnectionManager.UpdateNote(noteID1 + "NOTEXIST", notebookID1, text2); sw.WriteLine("FAILED: UpdateNote(string noteID, string noteText): User does not exist."); return(false); } catch { return(true); } }
private bool GetNoteNoteIdIsNull(StreamWriter sw) { try { GoogleFirestoreConnectionManager.GetNote(null); sw.WriteLine("FAILED: GetNote(string noteID): noteID is null test case."); return(false); } catch { return(true); } }
private bool DeleteUserUserIdIsNull(StreamWriter sw) { try { GoogleFirestoreConnectionManager.DeleteUser(null); sw.WriteLine("FAILED: DeleteUser(string userID): userID is null test case."); return(false); } catch { return(true); } }
private bool DeleteNoteNoteIdIsEmpty(StreamWriter sw) { try { GoogleFirestoreConnectionManager.DeleteNote(""); sw.WriteLine("FAILED: DeleteNote(string noteID): noteID is empty test case."); return(false); } catch { return(true); } }
private bool GetNotesNotebookIsEmpty(StreamWriter sw) { try { GoogleFirestoreConnectionManager.GetNotebookNotes(""); sw.WriteLine("FAILED: GetNotes(string notebookID): Notebook is empty test case."); return(false); } catch { return(true); } }
private bool GetNotesValidRequest(StreamWriter sw) { try { GoogleFirestoreConnectionManager.HandleLogin(userID1, displayName1, email1); Models.Notebook createdNotebook = GoogleFirestoreConnectionManager.CreateNotebook(userID1, notebook1.Title, notebook1.Author, notebook1.Isbn, notebook1.Publisher, notebook1.PublishDate, notebook1.CoverURL); Note created1 = GoogleFirestoreConnectionManager.CreateNote(userID1, createdNotebook.ID, note1.Text); Note created2 = GoogleFirestoreConnectionManager.CreateNote(userID1, createdNotebook.ID, note2.Text); Note created3 = GoogleFirestoreConnectionManager.CreateNote(userID1, createdNotebook.ID, note3.Text); List <Models.Note> createdNotes = GoogleFirestoreConnectionManager.GetNotebookNotes(createdNotebook.ID); List <Models.Note> expectedNotes = new List <Models.Note> { new Note(created1.ID, userID1, createdNotebook.ID, text1, DateTime.Now, DateTime.Now), new Note(created2.ID, userID1, createdNotebook.ID, text2, DateTime.Now, DateTime.Now), new Note(created3.ID, userID1, createdNotebook.ID, text3, DateTime.Now, DateTime.Now) }; if (createdNotes.Count != expectedNotes.Count) { sw.WriteLine("FAILED: GetNotes(string notebookID): Normal test case, count mismatch."); GoogleFirestoreConnectionManager.DeleteUser(userID1); return(false); } else { foreach (Models.Note n in createdNotes) { foreach (Models.Note t in expectedNotes) { if (t.Equals(n)) { expectedNotes.Remove(t); break; } } } if (expectedNotes.Count > 0) { sw.WriteLine("FAILED: GetNotes(string notebookID): Normal test case, Notes not the same."); GoogleFirestoreConnectionManager.DeleteUser(userID1); return(false); } } GoogleFirestoreConnectionManager.DeleteUser(userID1); } catch { sw.WriteLine("FAILED: GetNotes(string notebookID): Normal test case - unexpected exception."); return(false); } return(true); }
private bool CreateNoteNoteTextIsNull(StreamWriter sw) { try { Models.Note temp = GoogleFirestoreConnectionManager.CreateNote(userID1, notebookID1, null); sw.WriteLine("FAILED: CreateNote(string userID, string notebookID, string noteText): CreateNote note text is null test case."); GoogleFirestoreConnectionManager.DeleteNote(temp.ID); return(false); } catch { return(true); } }
private bool CreateNoteUserIdIsEmpty(StreamWriter sw) { try { Models.Note temp = GoogleFirestoreConnectionManager.CreateNote("", notebookID1, text1); sw.WriteLine("FAILED: CreateNote(string userID, string notebookID, string noteText): CreateNote userID is empty test case."); GoogleFirestoreConnectionManager.DeleteNote(temp.ID); return(false); } catch { return(true); } }
private bool CreateNoteNotebookDoesNotExist(StreamWriter sw) { try { Models.Note temp = GoogleFirestoreConnectionManager.CreateNote(userID1, notebookID1 + "NOTEXIST", text1); sw.WriteLine("FAILED: CreateNote(string userID, string notebookID, string noteText): CreateNote Notebook does not exist test case."); GoogleFirestoreConnectionManager.DeleteNote(temp.ID); return(false); } catch { return(true); } }
public void ValidateUser(object sender, EventArgs e) { Notebook notebook = GoogleFirestoreConnectionManager.GetNotebook(notebookID); if (HandleLoginUserID.Value != notebook.UserID) { Response.Redirect("./Notebooks.aspx"); } NotebookTitle.InnerText = HttpUtility.UrlDecode(notebook.Title); GenerateNoteRows(GoogleFirestoreConnectionManager.GetNotebookNotes(notebookID)); }
public void UpdateNotebooks(object sender, EventArgs e) { string userID = HandleLoginUserID.Value; Notebooks = GoogleFirestoreConnectionManager.GetNotebooks(userID); List <HtmlGenericControl> notebookDivs = GenerateNotebookDivs(); foreach (HtmlGenericControl notebookDiv in notebookDivs) { MainNotebooks.Controls.Add(notebookDiv); } }
public void HandleNote(object sender, EventArgs e) { NotebookID = NotebookList.SelectedValue; if (IsEdit) { GoogleFirestoreConnectionManager.UpdateNote(NoteID, NotebookID, NoteText.Text); } else { GoogleFirestoreConnectionManager.CreateNote(HandleLoginUserID.Value, NotebookID, NoteText.Text); } Response.Redirect("Notebook.aspx?notebookID=" + NotebookID); }
private bool DeleteNoteNoteDoesNotExist(StreamWriter sw) { try { if (!GoogleFirestoreConnectionManager.DeleteNote(noteID1 + "NOTEXIST")) { sw.WriteLine("FAILED: DeleteNote(string noteID): Note does not exist test case."); return(false); } } catch { sw.WriteLine("FAILED: DeleteNote(string noteID): Note does not exist test case - unexpected exception."); return(false); } return(true); }
private bool GetNoteNoteDoesNotExist(StreamWriter sw) { try { GoogleFirestoreConnectionManager.GetNote(noteID1 + "NOTEXIST"); return(false); } catch (NotFoundException) { return(true); } catch { sw.WriteLine("FAILED: GetNote(string noteID): Note does not exist test case - unexpected exception."); return(false); } }
private bool GetNotesNotebookDoesNotExist(StreamWriter sw) { try { List <Models.Note> tempNotes = GoogleFirestoreConnectionManager.GetNotebookNotes(notebookID1 + "NOTEXIST"); if (tempNotes == null || tempNotes.Count != 0) { sw.WriteLine("FAILED: GetNotes(string notebookID): Notebook has no notes test case."); return(false); } } catch { sw.WriteLine("FAILED: GetNotes(string notebookID): Notebook has no notes test case - unexpected exception."); return(false); } return(true); }
private bool GetUserNotesUserHasNoNotes(StreamWriter sw) { try { List <Note> tempNotes = GoogleFirestoreConnectionManager.GetUserNotes(userID2); if (tempNotes == null || tempNotes.Count != 0) { sw.WriteLine("FAILED: GetNotes(string userID): User has no notes test case."); return(false); } } catch { sw.WriteLine("FAILED: GetNotes(string userID): User has no notes test case - unexpected exception."); return(false); } return(true); }