예제 #1
0
        public void Test()
        {
            var tddHandler = new TDDHandler();

            var settings = new DifferentTypesLocalSettings();

            settings.DeleteObjectSettings();

            Assert.IsFalse(settings.ContainsObjectSetting(s => s.m_Boolean));

            settings.SaveObjectSettings();

            Assert.IsTrue(settings.ContainsObjectSetting(s => s.m_Boolean));

            Assert.IsTrue(DifferentTypesLocalSettings.ContainsObjectSetting(settings, (DifferentTypesLocalSettings s) => s.m_Boolean));

            // static settings

            CollectionsSettings.DeleteSettings();

            Assert.IsFalse(CollectionsSettings.ContainsSetting(s => CollectionsSettings.IntList));

            CollectionsSettings.SaveSettings();

            Assert.IsTrue(CollectionsSettings.ContainsSetting(s => CollectionsSettings.IntList));

            tddHandler.CheckErrors();
        }
        public void Test()
        {
            var tddHandler = new TDDHandler();

            const Int32 iterations = 10000;

            InitializeCollections(iterations);

            for (Int32 i = 0; i < iterations; i++)
            {
                CollectionsSettings.IntList.Add(i);
                CollectionsSettings.Int2StringDictionary.Add(i, i.ToString());
                CollectionsSettings.IntSet.Add(i);

                CollectionsSettings.SecureIntList.Add(i);
                CollectionsSettings.SecureInt2StringDictionary.Add(i, i.ToString());
                CollectionsSettings.SecureIntSet.Add(i);
            }

            CollectionsSettings.SaveSettings();

            // reset existing values
            InitializeCollections(iterations);

            CollectionsSettings.LoadSettings();

            // Check collections size
            Assert.AreEqual(CollectionsSettings.IntList.Count, iterations);
            Assert.AreEqual(CollectionsSettings.Int2StringDictionary.Count, iterations);
            Assert.AreEqual(CollectionsSettings.IntSet.Count, iterations);

            Assert.AreEqual(CollectionsSettings.SecureIntList.Count, iterations);
            Assert.AreEqual(CollectionsSettings.SecureInt2StringDictionary.Count, iterations);
            Assert.AreEqual(CollectionsSettings.SecureIntSet.Count, iterations);

            for (Int32 i = 0; i < iterations; i++)
            {
                // Check list
                Assert.AreEqual(CollectionsSettings.IntList[i], i);

                // Check dictionary
                string strValue;
                CollectionsSettings.Int2StringDictionary.TryGetValue(i, out strValue);
                Assert.IsTrue(strValue == i.ToString());

                // Check hash set
                Assert.IsTrue(CollectionsSettings.IntSet.Contains(i));

                // Check secure list
                Assert.AreEqual(CollectionsSettings.SecureIntList[i], i);

                // Check secure dictionary
                string secureStrValue;
                CollectionsSettings.SecureInt2StringDictionary.TryGetValue(i, out secureStrValue);

                Assert.IsTrue(secureStrValue == i.ToString());

                // Check secure hash set
                Assert.IsTrue(CollectionsSettings.SecureIntSet.Contains(i));

                tddHandler.CheckErrors();
            }
        }