Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 public ReadableDataFile(string defaultFileText = null)
 {
     if (defaultFileText == null)
     {
         DefaultFileCache = null; // prevent infinite recursion lol
     }
     else
     {
         DefaultFileCache = new MemoryReadOnlyDataFile(defaultFileText, null);
     }
 }
Esempio n. 3
0
 public static void PerformInvalidFileStructureTest(string invalidFileStructure)
 {
     try
     {
         var file = new MemoryReadOnlyDataFile(invalidFileStructure);
     }
     catch (InvalidFileStructureException expectedException)
     {
         Console.WriteLine("Got expected exception:");
         Console.WriteLine(expectedException);
     }
 }
Esempio n. 4
0
        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);
            }
        }