//  [PexMethod]
        //Case when number of subkeys are more than the name and value
        public void TestClearRoutinesPUT2([PexAssumeUnderTest] String[] name, Object[] value, [PexAssumeUnderTest] String[] key)
        {
            //PexAssume.IsNotNull(mainKey);
            PexAssume.IsNotNull(value);
            PexAssume.IsTrue(name.Length >= 1);
            PexAssume.IsTrue(key.Length >= name.Length);
            PexAssume.IsTrue(name.Length == value.Length);

            for (int i = 0; i < key.Length; i++)
            {
                if (i < name.Length)
                {
                    PexAssume.IsNotNullOrEmpty(name[i]);
                    PexAssume.IsTrue(value[i] is String || value[i] is int);
                    PexAssume.IsNotNull(value[i]);
                }
                //if (i < key.Length)
                PexAssume.IsNotNull(key[i]);
            }
            NUnitRegistry.TestMode = true;
            using (RegistryKey mainKey = NUnitRegistry.CurrentUser)
            {
                mainKey.SetValue(name[0], value[0]);
                int         k          = 0;
                RegistryKey prevSubKey = null;
                prevSubKey = mainKey;
                for (k = 1; k < key.Length; k++)
                {
                    RegistryKey subKey = null;
                    subKey     = prevSubKey.CreateSubKey(key[k - 1]);
                    prevSubKey = subKey;
                    if (k < name.Length)
                    {
                        subKey.SetValue(name[k], value[k]);
                    }
                }

                NUnitRegistry.ClearTestKeys();
                PexAssert.IsTrue(mainKey.ValueCount == 0);
                PexAssert.IsTrue(mainKey.SubKeyCount == 0);
            }
        }
        public void SaveAndLoadSettingsPUT1([PexAssumeUnderTest] String[] name, [PexAssumeUnderTest] Object[] value)
        {
            PexAssume.IsTrue(name.Length == value.Length);
            for (int i = 0; i < value.Length; i++)
            {
                PexAssume.IsTrue(value[i] is String || value[i] is int);
                PexAssume.IsNotNullOrEmpty(name[i]);
                PexAssume.IsNotNull(value[i]);
            }

            for (int i = 0; i < name.Length; i++)
            {
                storage.SaveSetting(name[i], value[i]);
            }
            for (int i = 0; i < name.Length; i++)
            {
                PexAssert.AreEqual(value[i], storage.GetSetting(name[i]));
                PexAssert.AreEqual(value[i], testKey.GetValue(name[i]));
            }
        }
Example #3
0
        public void Test_HeadAndTailOfNonEmptySequence <T>([PexAssumeNotNull] T[] arr)
        {
            PexAssume.IsNotNullOrEmpty(arr);
            var seq0 = RandomAccessSequence.FromEnumerable(arr);
            var seq  = seq0;

            foreach (var t in arr)
            {
                Assert.Equal(t, seq.Head);
                seq = seq.Tail;
            }
            Assert.Empty(seq);

            seq = seq0;
            foreach (var t in arr.Reverse())
            {
                Assert.Equal(t, seq.Last);
                seq = seq.Init;
            }
            Assert.Empty(seq);
        }
        public void RemoveSettingsPUT1([PexAssumeUnderTest] String[] name, [PexAssumeUnderTest] Object[] value)
        {
            PexAssume.IsTrue(name.Length == value.Length);
            for (int i = 0; i < value.Length; i++)
            {
                PexAssume.IsTrue(value[i] is String || value[i] is int);
                PexAssume.IsNotNullOrEmpty(name[i]);
                PexAssume.IsNotNull(value[i]);
                //PexAssume.IsTrue(name[i].Contains("t"));
            }

            for (int i = 0; i < name.Length; i++)
            {
                storage.SaveSetting(name[i], value[i]);
            }
            for (int i = 0; i < name.Length; i++)
            {
                if (storage.GetSetting(name[i]) != null)
                {
                    storage.RemoveSetting(name[i]);
                    PexAssert.IsNull(storage.GetSetting(name[i]), name[i] + " not removed");
                }
            }
        }
Example #5
0
 public void Test_IsEmptyWorksCorrectly <T>(T[] arr)
 {
     Assert.True(RandomAccessSequence.Empty <int>().IsEmpty);
     PexAssume.IsNotNullOrEmpty(arr);
     Assert.False(RandomAccessSequence.FromEnumerable(arr).IsEmpty);
 }
        public void TestClearRoutinesPUT4([PexAssumeUnderTest] String[] name, Object[] value, [PexAssumeUnderTest] String[] key)
        {
            //PexAssume.IsNotNull(mainKey);
            PexAssume.IsNotNull(value);
            PexAssume.IsTrue(name.Length >= 1);
            //PexAssume.IsTrue(key.Length < name.Length);
            PexAssume.IsTrue(name.Length == value.Length);

            for (int i = 0; i < name.Length; i++)
            {
                //if (i < name.Length)
                //{

                PexAssume.IsNotNullOrEmpty(name[i]);
                PexAssume.IsTrue(name[i].Contains("test"));
                PexAssume.IsTrue(value[i] is String || value[i] is int);
                PexAssume.IsNotNull(value[i]);
                // }
                //if (i < key.Length)
                //    PexAssume.IsNotNull(key[i]);
            }

            for (int j = 0; j < key.Length; j++)
            {
                PexAssume.IsNotNull(key[j]);
                PexAssume.IsFalse(key[j].Equals(""));
                PexAssume.IsTrue(key[j].Contains("test"));
            }

            NUnitRegistry.TestMode = true;
            using (RegistryKey mainKey = NUnitRegistry.CurrentUser)
            {
                mainKey.SetValue(name[0], value[0]);
                int       maxVal  = key.Length > name.Length ? key.Length : name.Length;
                int       k       = 0;
                ArrayList keyList = new ArrayList();
                keyList.Add(mainKey);
                for (k = 0; k < maxVal; k++)
                {
                    Random rand   = new Random(k + 1);
                    int    genNum = rand.Next();
                    if (keyList.Count - 1 == 0)
                    {
                        genNum = 0;
                    }
                    else
                    {
                        genNum = genNum % (keyList.Count - 1);
                    }
                    Console.WriteLine(genNum);
                    Console.WriteLine(keyList.ToArray()[genNum].ToString());
                    RegistryKey subKey = null;

                    if (k < key.Length)
                    {
                        subKey = ((keyList.ToArray())[genNum] as RegistryKey).CreateSubKey(key[k]);
                        keyList.Add(subKey);
                    }
                    else
                    {
                        subKey = (keyList.ToArray())[genNum] as RegistryKey;
                    }
                    // RegistryKey subKey = mainKey.CreateSubKey(key[k - 1]);
                    // RegistryKey testSubKey = subKey.CreateSubKey("test" + keyList.Count);
                    // testSubKey.SetValue("boo", "booo");

                    if (k < name.Length)
                    {
                        subKey.SetValue(name[k], value[k]);
                    }
                }

                NUnitRegistry.ClearTestKeys();
                PexAssert.IsTrue(mainKey.ValueCount == 0);
                PexAssert.IsTrue(mainKey.SubKeyCount == 0);
            }
        }
Example #7
0
 public static RemoteTestAgent Create([PexAssumeUnderTest] String name)
 {
     PexAssume.IsNotNullOrEmpty(name);
     return(new RemoteTestAgent(name));
 }