public void Test_UpdateNote() { NoteAdministration.Notes.Clear(); NoteAdministration.AddNote(test.Information, test.AccountEmail); Assert.IsTrue(NoteAdministration.ChangeNote(test, "this is a test")); Assert.AreEqual(test.Information, "this is a test"); try { NoteAdministration.ChangeNote(test, "this is a test"); } catch (Exception exception) { Assert.IsTrue(exception is PlannerExceptions); Assert.AreEqual(exception.Message, "The old note doesn't exist in the note list"); } Note TestDBNote = new Note("tester", "*****@*****.**"); NoteAdministration.AddNote(TestDBNote.Information, TestDBNote.AccountEmail); Assert.IsTrue(NoteAdministration.ChangeNote(TestDBNote, "test 123")); Assert.AreEqual(TestDBNote.Information, "test 123"); try { NoteAdministration.ChangeNote(new Note("testing", "*****@*****.**"), TestDBNote.Information); } catch (Exception exception) { Assert.IsTrue(exception is PlannerExceptions); Assert.AreEqual(exception.Message, "The old note doesn't exist in the note list"); } }
public void Test_DeleteNote() { NoteAdministration.Notes.Clear(); NoteAdministration.AddNote(test.Information, test.AccountEmail); Note note = NoteDatabase.GetNote(new Note(test.Information, test.AccountEmail)); Assert.IsTrue(NoteAdministration.RemoveNote(note)); try { NoteAdministration.RemoveNote(test); } catch (Exception exception) { Assert.IsTrue(exception is PlannerExceptions); Assert.AreEqual(exception.Message, "Note doesn't exist in the note list"); } //Database test NoteAdministration.AddNote("tester", "*****@*****.**"); Note not2 = NoteDatabase.GetNote(new Note("tester", "*****@*****.**")); Assert.IsTrue(NoteAdministration.RemoveNote(new Note("tester", "*****@*****.**"))); NoteDatabase noteDatabase = new NoteDatabase(); Assert.IsNotNull(noteDatabase.GetNote(new Note("tester", "*****@*****.**"))); }
public void Test_EmptyNoteToUser() { NoteAdministration.Notes.Clear(); Assert.IsTrue(NoteAdministration.AddNote(test.Information + "e", "*****@*****.**")); Assert.IsTrue(NoteAdministration.AddNote(test.Information + "a", "")); Assert.IsTrue(NoteAdministration.AddNote(test.Information + "b", "")); Assert.IsTrue(NoteAdministration.AddNote(test.Information + "d", "*****@*****.**")); NoteAdministration.EmptyNotesToUser(new Account("Tester", "Unit", "*****@*****.**")); foreach (Note note in NoteAdministration.Notes) { Assert.IsTrue(note.AccountEmail != ""); } Assert.AreEqual(NoteAdministration.Notes.Count, 4); }
public void Test_AddNote() { //Add local Note testNote = test; Note test2Note = testNote; Assert.AreEqual(testNote, test2Note); Assert.IsTrue(NoteAdministration.AddNote(testNote.Information, testNote.AccountEmail)); //test for a dubbel try { NoteAdministration.AddNote(testNote.Information, testNote.AccountEmail); } catch (Exception exception) { Assert.IsTrue(exception is PlannerExceptions); Assert.AreEqual(exception.Message, "Note already exist in the note list"); } //add local and database Note test3Note = new Note(test.Information + "testing", "*****@*****.**"); Assert.AreNotEqual(testNote, test3Note); Assert.IsTrue(NoteAdministration.AddNote(test3Note.Information, test3Note.AccountEmail)); try { NoteAdministration.AddNote(test3Note.Information, test3Note.AccountEmail); } catch (Exception exception) { Assert.IsTrue(exception is PlannerExceptions); Assert.AreEqual(exception.Message, "Note already exist in the note list"); } Note note = NoteDatabase.GetNote(new Note(test.Information, "*****@*****.**")); Assert.IsTrue(NoteAdministration.RemoveNote(note)); CollectionAssert.AllItemsAreUnique(NoteAdministration.Notes); }