public NoteKeeperForm() { InitializeComponent(); try { _noteKeeperOperator = new NoteKeeperOperator(new XMLStorageService()); _noteKeeperOperator.OpenLastSavedNoteViaMetaData(); UpdateNoteOnForms(); } catch (UnauthorizedAccessException un) { Debug.WriteLine(un.Message); MessageBox.Show("Currently you are unauthorized to create a Directory in this space in order to store your Notes!"); Application.Exit(); } catch (IOException io) { Debug.WriteLine(io.Message); MessageBox.Show("The specified directory path is a file!"); Application.Exit(); } catch (Exception ex) { Debug.WriteLine(ex.Message); MessageBox.Show("Oops, something went wrong! Please lookup in the non-existing Log-File!"); Application.Exit(); } }
public void SaveWithStaticFileName_GivenJSONServiceTitleAndText_WhenOverridingOldFile_ThenCreatedTimeShouldStayTheSame() { //Arrange NoteKeeperOperator noteKeeperOperator = new NoteKeeperOperator(new JSONStorageService(), PATH); noteKeeperOperator.SaveWithStaticFileName("Titel", "Foo"); long expectedDateTime = noteKeeperOperator.Note.Created.ToFileTime(); //Act noteKeeperOperator.SaveWithStaticFileName("Titel", "Foo"); long actualDateTime = noteKeeperOperator.Note.Created.ToFileTime(); //Assert Assert.Equal(expectedDateTime, actualDateTime); }
public void GivenJSONServiceAndNote_WhenSavingFileAndClosingApp_ThenTheSameNoteShouldBeLoadedViaMetaDataFileNextTimeAfterOpeningApp() { NoteKeeperOperator noteKeeperOperator = new NoteKeeperOperator(new JSONStorageService(), PATH); noteKeeperOperator.SaveWithDynamicFileName("Titel", "Foo"); Note expectedNote = noteKeeperOperator.Note; noteKeeperOperator = new NoteKeeperOperator(new JSONStorageService(), PATH); noteKeeperOperator.OpenLastSavedNoteViaMetaData(); Note actualNote = noteKeeperOperator.Note; Assert.Equal(expectedNote.Title, actualNote.Title); Assert.Equal(expectedNote.Text, actualNote.Text); Assert.Equal(expectedNote.Created.ToString(), actualNote.Created.ToString()); Assert.Equal(expectedNote.LastEdited.ToString(), actualNote.LastEdited.ToString()); }
public void SaveWithStaticFileName_GivenJSONServiceTitleAndText_WhenOverridingOldFile_ThenLastEditedTimeShouldBeGreaterThanCreatedTime() { //Arrange NoteKeeperOperator noteKeeperOperator = new NoteKeeperOperator(new JSONStorageService(), PATH); noteKeeperOperator.SaveWithStaticFileName("Titel", "Foo"); long createdFileTime = noteKeeperOperator.Note.Created.ToFileTime(); noteKeeperOperator.OpenLastSavedNote(); //Act noteKeeperOperator.SaveWithStaticFileName("Titel", "Foo"); long lastEditedFileTime = noteKeeperOperator.Note.LastEdited.ToFileTime(); //Assert Assert.True(lastEditedFileTime > createdFileTime); }