public void TestLoadEditSaveWhenDeleted() { //create the default database: IKp2aApp app = SetupAppWithDefaultDatabase(); IOConnection.DeleteFile(new IOConnectionInfo { Path = DefaultFilename }); //save it and reload it so we have a base version SaveDatabase(app); app = LoadDatabase(DefaultFilename, DefaultPassword, DefaultKeyfile); //delete the file: File.Delete(DefaultFilename); //modify the database by adding a group: app.GetDb().KpDatabase.RootGroup.AddGroup(new PwGroup(true, true, "TestGroup", PwIcon.Apple), true); //save the database again: _testCacheSupervisor.Reset(); SaveDatabase(app); Assert.IsNull(((TestKp2aApp)app).LastYesNoCancelQuestionTitle); _testCacheSupervisor.AssertNoCall(); //load database to a new app instance: IKp2aApp resultApp = LoadDatabase(DefaultFilename, DefaultPassword, DefaultKeyfile); //ensure the change was saved: AssertDatabasesAreEqual(app.GetDb().KpDatabase, resultApp.GetDb().KpDatabase); }
public void TestSaveToRemote() { SetupFileStorage(); //read the file once. Should now be in the cache. ReadToMemoryStream(_fileStorage, CachingTestFile); _testCacheSupervisor.Reset(); //write something to the cache: string newContent = "new content"; WriteContentToCacheFile(newContent); _testCacheSupervisor.AssertNoCall(); Assert.AreEqual(newContent, File.ReadAllText(CachingTestFile)); }