public void DeleteConfigurationRemovesFromList() { var configurationToDelete = _configurations[0]; // SUT _controller.DeleteConfiguration(configurationToDelete); Assert.That(_configurations, Is.Not.Contains(configurationToDelete), "Should have removed configuration from list of configurations"); Assert.That(_controller.IsDirty, "made changes; should be dirty"); }
public void DeleteConfigurationResetsReversalToShippedDefaultIfNoProjectAllReversal() { var defaultReversalPath = Path.Combine(FwDirectoryFinder.DefaultConfigurations, "ReversalIndex"); // construct a controller to work in the default reversal directory _controller = new DictionaryConfigurationManagerController(Cache, null, _configurations, new List <string>(), _projectConfigPath, defaultReversalPath); var allRevFileName = DictionaryConfigurationModel.AllReversalIndexesFilenameBase + DictionaryConfigurationModel.FileExtension; var shippedRootDefaultConfigurationPath = Path.Combine(defaultReversalPath, allRevFileName); FileUtils.WriteStringtoFile(shippedRootDefaultConfigurationPath, "bogus data that is unread, the file is read from the real defaults", Encoding.UTF8); var configurationToDelete = _configurations[0]; configurationToDelete.FilePath = Path.Combine("whateverdir", "en" + DictionaryConfigurationModel.FileExtension); configurationToDelete.Label = "English"; configurationToDelete.WritingSystem = "en"; var pathToConfiguration = configurationToDelete.FilePath; FileUtils.WriteStringtoFile(pathToConfiguration, "customized file contents", Encoding.UTF8); Assert.That(FileUtils.FileExists(pathToConfiguration), "Unit test not set up right"); Assert.IsFalse(FileUtils.FileExists(Path.Combine(_projectConfigPath, allRevFileName)), "Unit test not set up right"); // SUT _controller.DeleteConfiguration(configurationToDelete); Assert.That(FileUtils.FileExists(pathToConfiguration), "The English reversal file should have been reset to defaults, not deleted."); Assert.That(configurationToDelete.Label, Is.EqualTo("English"), "The label should still be English after a reset."); Assert.That(configurationToDelete.WritingSystem, Is.EqualTo("en"), "The writingsystem should still be en after a reset."); Assert.That(configurationToDelete.IsReversal, Is.True, "The reset configuration files should still be a reversal file."); Assert.Contains(configurationToDelete, _configurations, "The configuration should still be present in the list after being reset."); Assert.That(_controller.IsDirty, "Resetting is a change that is saved later; should be dirty"); // Not asserting that the configurationToDelete.FilePath file contents are reset because that will happen later when it is saved. }