public void ComplexTypeShortcut_Property_LoadedValueEqualsShortcutValue() { var SAVED_VALUE = ComplexType.PropertyShortcut; var file = new MemoryReadOnlyDataFile($"{SAVED_VALUE_KEY}:PropertyShortcut"); var loadedValue = file.Get <ComplexType>(SAVED_VALUE_KEY, null); Assert.AreEqual(SAVED_VALUE, loadedValue); }
public ReadableDataFile(string defaultFileText = null) { if (defaultFileText == null) { DefaultFileCache = null; // prevent infinite recursion lol } else { DefaultFileCache = new MemoryReadOnlyDataFile(defaultFileText, null); } }
public static void PerformInvalidFileStructureTest(string invalidFileStructure) { try { var file = new MemoryReadOnlyDataFile(invalidFileStructure); } catch (InvalidFileStructureException expectedException) { Console.WriteLine("Got expected exception:"); Console.WriteLine(expectedException); } }
public static void PerformParsingErrorTest <TData>(string validFileStructure_invalidData) { var file = new MemoryReadOnlyDataFile(validFileStructure_invalidData); // Use try/catch instead of Assert.ThrowsException so we can print the exception details. // The point of these tests is to make sure the exceptions are working properly, so it's nice to // manually check that the error messages are what they should be. // It might be cool in the future to actually test that the error messages, or at least the line numbers, are correct. try { file.Get <TData>("data"); } catch (CannotRetrieveDataFromNodeException expectedException) { Console.WriteLine("Got expected exception:"); Console.WriteLine(expectedException); } }