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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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]);
                    }
                }
            }
        }