public void ComplexTypeShortcut_Custom_LoadedValueEqualsShortcutValue()
        {
            var SAVED_VALUE = ComplexType.Shortcut("shortcut1");
            var file        = new MemoryDataFile($"{SAVED_VALUE_KEY}:shortcut1");

            var loadedValue = file.Get <ComplexType>(SAVED_VALUE_KEY);

            Assert.AreEqual(SAVED_VALUE, loadedValue);
        }
        public void ComplexTypeShortcut_Method_LoadedValueEqualsShortcutValue()
        {
            var SAVED_VALUE = ComplexType.MethodShortcut(1, "test", false);
            var file        = new MemoryDataFile($"{SAVED_VALUE_KEY}:MethodShortcut(1, \"test\", false)");

            var loadedValue = file.Get <ComplexType>(SAVED_VALUE_KEY);

            Assert.AreEqual(SAVED_VALUE, loadedValue);
        }
        public void ComplexTypeShortcut_Constructor_LoadedValueEqualsShortcutValue()
        {
            var SAVED_VALUE = new ComplexType(0, "example", true);
            var file        = new MemoryDataFile($"{SAVED_VALUE_KEY}:(0, \"example\", true)");

            var loadedValue = file.Get <ComplexType>(SAVED_VALUE_KEY);

            Assert.AreEqual(SAVED_VALUE, loadedValue);
        }
        public void SaveLoad_Array_Ints()
        {
            var SAVED_VALUE = new int[] { 0, 1, 2, 3 };
            var file        = new MemoryDataFile();

            file.Set(SAVED_VALUE_KEY, SAVED_VALUE);
            var loadedValue = file.Get <int[]>(SAVED_VALUE_KEY);

            CollectionAssert.AreEqual(SAVED_VALUE, loadedValue);
        }
Exemple #5
0
        public static void PerformSaveLoadTest <T>(T SAVED_VALUE)
        {
            const string SAVED_VALUE_KEY = "test key";
            var          file            = new MemoryDataFile();

            file.Set(SAVED_VALUE_KEY, SAVED_VALUE);
            var loadedValue = file.Get <T>(SAVED_VALUE_KEY);

            Assert.AreEqual(SAVED_VALUE, loadedValue);
        }
Exemple #6
0
        public void SaveLoad_FileInfo()
        {
            var SAVED_VALUE = new FileInfo("C:/picturesofferrets/ferretsinlittlehats/ferretinalittlehat_16.png");

            var file = new MemoryDataFile();

            file.Set(SAVED_VALUE_KEY, SAVED_VALUE);
            var loadedValue = file.Get <FileInfo>(SAVED_VALUE_KEY);

            Assert.AreEqual(SAVED_VALUE.FullName, loadedValue.FullName);
        }
Exemple #7
0
        public static void PerformSaveLoadTest <T>(T SAVED_VALUE)
        {
            const string SAVED_VALUE_KEY = "test key";
            var          file            = new MemoryDataFile();

            file.Set(SAVED_VALUE_KEY, SAVED_VALUE);
            var loadedValue = file.Get <T>(SAVED_VALUE_KEY);

            Assert.AreEqual(SAVED_VALUE, loadedValue);

            Console.WriteLine($"Successfully saved and loaded {SAVED_VALUE}");
        }
        public void SaveLoad_HashSet_Ints()
        {
            var SAVED_VALUE = new HashSet <int>()
            {
                0, 1, 2, 3
            };
            var file = new MemoryDataFile();

            file.Set(SAVED_VALUE_KEY, SAVED_VALUE);
            var loadedValue = file.Get <HashSet <int> >(SAVED_VALUE_KEY);

            Assert.IsTrue(SAVED_VALUE.SequenceEqual(loadedValue));
        }
        public void SaveLoad_Dictionary_ComplexTypeToComplexType()
        {
            var SAVED_VALUE = new Dictionary <ComplexType, ComplexType>()
            {
                [new ComplexType(832, "jfhkdslfjsd", true)] = new ComplexType(22323, Environment.NewLine, false),
                [new ComplexType(int.MaxValue, "oof ouch owie my unit test", false)] = new ComplexType(int.MinValue, "penis lmao", true),
                [new ComplexType(8564698, "I like socialized healthcare", true)]     = new ComplexType(99999, "aaaaaaaaaaaaaaaaa", true),
            };
            var file = new MemoryDataFile();

            file.Set(SAVED_VALUE_KEY, SAVED_VALUE);
            var loadedValue = file.Get <Dictionary <ComplexType, ComplexType> >(SAVED_VALUE_KEY);

            CollectionAssert.AreEquivalent(SAVED_VALUE, loadedValue);
        }
        public void SaveLoad_Dictionary_StringToInt()
        {
            var SAVED_VALUE = new Dictionary <string, int>()
            {
                ["one"]   = 1,
                ["two"]   = 2,
                ["three"] = 3,
            };
            var file = new MemoryDataFile();

            file.Set(SAVED_VALUE_KEY, SAVED_VALUE);
            var loadedValue = file.Get <Dictionary <string, int> >(SAVED_VALUE_KEY);

            CollectionAssert.AreEquivalent(SAVED_VALUE, loadedValue);
        }
        public void SaveLoad_Array_DeeplyNestedInts()
        {
            var SAVED_VALUE = DeeplyNestedIntArray;
            var file        = new MemoryDataFile();

            file.Set(SAVED_VALUE_KEY, SAVED_VALUE);
            var loadedValue = file.Get <int[][][][]>(SAVED_VALUE_KEY);

            for (int i = 0; i < loadedValue.Length; i++)
            {
                for (int j = 0; j < loadedValue[i].Length; j++)
                {
                    for (int k = 0; k < loadedValue[i][j].Length; k++)
                    {
                        CollectionAssert.AreEqual(loadedValue[i][j][k], SAVED_VALUE[i][j][k]);
                    }
                }
            }
        }