public void SaveToFile_GivenCSVServiceAndNonExistingPath_WhenSavingFile_ThenItShouldThrowDirectoryNotFoundException() { CSVStorageService storageService = new CSVStorageService(); Note note = new Note("Titel", "Foo", DateTime.UtcNow.ToString("o"), DateTime.UtcNow.ToString("o")); Assert.ThrowsAsync <DirectoryNotFoundException>(() => storageService.Save <Note>(note, @"C:\NotExistingPath\A")); }
public async void GivenCSVServiceTitleAndText_WhenSavingNewFileAndReadingOut_ThenTheContentShouldBeTheSame() { //Arrange string combinedPathToFile = Path.Combine(PATH, "test" + CSV_EXTENSION); CSVStorageService storageService = new CSVStorageService(); DateTime dateTime = DateTime.UtcNow; Note expectedNote = new Note("Titel", "Foo", dateTime.ToString("o"), dateTime.ToString("o")); //Act await storageService.Save(expectedNote, combinedPathToFile); Note actualNote = await storageService.Open <Note>(combinedPathToFile); //Assert Assert.Equal(expectedNote.Title, actualNote.Title); Assert.Equal(expectedNote.Text, actualNote.Text); Assert.Equal(expectedNote.LastEditedRoundTrip, actualNote.LastEditedRoundTrip); Assert.Equal(expectedNote.CreatedRoundTrip, actualNote.CreatedRoundTrip); }