示例#1
0
        public void SaveToFile_GivenXMLServiceAndNonExistingPath_WhenSavingFile_ThenItShouldThrowDirectoryNotFoundException()
        {
            XMLStorageService storageService = new XMLStorageService();
            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 void SaveToFile_GivenXMLServiceAndNonExistingPath_WhenSavingFile_ThenItShouldThrowDirectoryNotFoundException()
        {
            XMLStorageService storageService = new XMLStorageService();
            Note note = new Note("Titel", "Foo", DateTime.Now, DateTime.Now);

            Assert.Throws <DirectoryNotFoundException>(() => storageService.SaveToFile(note, @"C:\NotExistingPath\A", TYPE));
        }
        public void GivenXMLServiceTitleAndText_WhenSavingNewFileAndReadingOut_ThenTheContentShouldBeTheSame()
        {
            //Arrange
            XMLStorageService storageService = new XMLStorageService();
            Note expectedNote = new Note("Titel", "Foo", DateTime.Now, DateTime.Now);

            //Act
            storageService.SaveToFile(expectedNote, Path.Combine(PATH, "test" + XML_EXTENSION), TYPE);
            Note actualNote = (Note)storageService.OpenFile(Path.Combine(PATH, "test" + XML_EXTENSION), TYPE);

            //Assert
            Assert.Equal(expectedNote.Title, actualNote.Title);
            Assert.Equal(expectedNote.Text, actualNote.Text);
            Assert.Equal(expectedNote.LastEdited.ToString(), actualNote.LastEdited.ToString());
            Assert.Equal(expectedNote.Created.ToString(), actualNote.Created.ToString());
        }
示例#4
0
        public async void GivenXMLServiceTitleAndText_WhenSavingNewFileAndReadingOut_ThenTheContentShouldBeTheSame()
        {
            //Arrange
            string            combinedPathToFile = Path.Combine(PATH, "test" + XML_EXTENSION);
            XMLStorageService storageService     = new XMLStorageService();
            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);
        }