示例#1
0
        public void MakeSubStoragesPUT1([PexAssumeUnderTest] String subName)
        {
            PexAssume.IsTrue(subName.Length < 255);
            PexAssume.IsTrue(subName.Contains("t"));
            String test1 = "HKEY_CURRENT_USER\\" + testKeyName + "\\" + subName;
            RegistrySettingsStorage sub1 = (RegistrySettingsStorage)storage.MakeChildStorage(subName);

            Console.WriteLine(test1.ToLower());
            Console.WriteLine(sub1.StorageKey.Name.ToLower());
            PexAssert.IsNotNull(sub1, "Sub1 is null");
            PexAssert.IsTrue(sub1.StorageKey.Name.ToLower().Equals(test1.ToLower()));
        }
示例#2
0
 public void IsAssemblyFileTypePUT1([PexAssumeUnderTest] String inpPath)
 {
     //PexAssume.IsFalse(inpPath.Contains("\0"));
     if (inpPath.EndsWith(".dll") || inpPath.EndsWith(".exe"))
     {
         PexAssert.IsTrue(PathUtils.IsAssemblyFileType(inpPath));
     }
     else
     {
         PexAssert.IsFalse(PathUtils.IsAssemblyFileType(inpPath));
     }
 }
示例#3
0
        public void CatchDoCatch <T>([PexAssumeNotNull] IEnumerable <T> begin, [PexAssumeNotNull] IEnumerable <T> rest, [PexAssumeNotNull] IEnumerable <T> alternative, bool shouldThrow)
        {
            var ex = new InvalidOperationException();
            var expectedCaughtCount = shouldThrow ? 1 : 0;
            var caughtCount         = 0;
            Func <Exception, IEnumerable <T> > replacer = x =>
            {
                caughtCount++;
                PexAssert.AreEqual(ex, x);
                return(alternative);
            };

            var start = begin;

            if (shouldThrow)
            {
                start = start.Concat(EnumerableEx.Throw <T>(ex));
            }
            start = start.Concat(rest);
            var enumerable = start.Catch(replacer);
            var enumerator = enumerable.GetEnumerator();

            var beginEnumerator = begin.GetEnumerator();

            while (beginEnumerator.MoveNext())
            {
                PexAssert.IsTrue(enumerator.MoveNext());
                PexAssert.AreEqual(beginEnumerator.Current, enumerator.Current);
            }

            if (shouldThrow)
            {
                var alternativeEnumerator = alternative.GetEnumerator();
                while (alternativeEnumerator.MoveNext())
                {
                    PexAssert.IsTrue(enumerator.MoveNext());
                    PexAssert.AreEqual(alternativeEnumerator.Current, enumerator.Current);
                }
            }
            else
            {
                var restEnumerator = rest.GetEnumerator();
                while (restEnumerator.MoveNext())
                {
                    PexAssert.IsTrue(enumerator.MoveNext());
                    PexAssert.AreEqual(restEnumerator.Current, enumerator.Current);
                }
            }
            PexAssert.IsFalse(enumerator.MoveNext());

            PexAssert.AreEqual(expectedCaughtCount, caughtCount);
        }
示例#4
0
        public void RemovePUT([PexAssumeUnderTest] IList <int> values, int randomPick)
        {
            DoublyLinkedList <int> dll = new DoublyLinkedList <int> (values);

            if (!values.Contains(randomPick))
            {
                PexAssert.IsFalse(dll.Remove(randomPick));
            }
            else
            {
                PexAssert.IsTrue(dll.Remove(randomPick));
            }
        }
示例#5
0
 public void NoScript_AnyInput(ErrorMode errorMode, [PexAssumeNotNull] string input)
 {
     PexAssume.EnumIsDefined(errorMode);
     try
     {
         var output = BBEncodeForTest(input, errorMode);
         PexAssert.IsTrue(!output.Contains("<script"));
     }
     catch (BBCodeParsingException)
     {
         PexAssume.Fail();
     }
 }
示例#6
0
        public void ShellSortListPUT(char[] actual)
        {
            if (actual == null)
            {
                actual.ShellSort();
                PexAssert.IsTrue(false, "Exception was expected");
            }
            IList <char> result   = actual.ShellSort();
            IList <char> expected = actual.InsertionSort();

            PexAssert.AreSame(expected, result);
            PexObserve.ValueForViewing <IList <char> >("Shell sort result", actual);
        }
示例#7
0
        public void RemoveRightChildLessThanLeftTest()
        {
            Heap <int> actual = new Heap <int> {
                5, 3, 8, 10, 6, 11, 12, 13
            };
            Heap <int> expected = new Heap <int> {
                3, 6, 8, 10, 13, 11, 12
            };

            PexAssert.IsTrue(actual.Remove(5));
            PexAssert.AreEqual(7, actual.Count);
            CollectionAssert.AreEqual(expected, actual);
        }
示例#8
0
        public int AddCantidadTest(
            [PexAssumeUnderTest] Carrito target,
            int index,
            int cantidad
            )
        {
            PexAssume.IsTrue(index > 0);
            int result = target.AddCantidad(index, cantidad);

            PexAssert.IsTrue(cantidad > 0);
            return(result);
            // TODO: agregar aserciones a método CarritoTest.AddCantidadTest(Carrito, Int32, Int32)
        }
示例#9
0
        public void PUT_RemoveEdgeContract([PexAssumeUnderTest] UndirectedGraph.UndirectedGraph <int, Edge <int> > ug, int source, int target)
        {
            AssumePrecondition.IsTrue(ug.ContainsVertex(source) && ug.ContainsVertex(target));

            int  Old_ugVertexCount          = ug.VertexCount;
            int  Old_ugEdgeCount            = ug.EdgeCount;
            int  Old_ugAdjacentDegreeSource = ug.AdjacentDegree(source);
            int  Old_ugAdjacentDegreeTarget = ug.AdjacentDegree(target);
            int  Old_source = source;
            int  Old_target = target;
            bool Old_ugAllowParallelEdges   = ug.AllowParallelEdges;
            bool Old_ugContainsVertexSource = ug.ContainsVertex(source);
            bool Old_ugContainsVertexTarget = ug.ContainsVertex(target);
            bool Old_Ret = PexChoose.Value <bool>("default_Ret");

            //code
            bool New_Ret = ug.RemoveEdge(new Edge <int>(source, target));

            int  New_ugVertexCount          = ug.VertexCount;
            int  New_ugEdgeCount            = ug.EdgeCount;
            int  New_ugAdjacentDegreeSource = ug.AdjacentDegree(source);
            int  New_ugAdjacentDegreeTarget = ug.AdjacentDegree(target);
            int  New_source = source;
            int  New_target = target;
            bool New_ugAllowParallelEdges   = ug.AllowParallelEdges;
            bool New_ugContainsVertexSource = ug.ContainsVertex(source);
            bool New_ugContainsVertexTarget = ug.ContainsVertex(target);

            PexObserve.ValueForViewing("$old_ug_vertex_count", Old_ugVertexCount);
            PexObserve.ValueForViewing("$new_ug_vertex_count", New_ugVertexCount);
            PexObserve.ValueForViewing("$old_ug_edge_count", Old_ugEdgeCount);
            PexObserve.ValueForViewing("$new_ug_edge_count", New_ugEdgeCount);
            PexObserve.ValueForViewing("$old_ug_adjacent_degree_source", Old_ugAdjacentDegreeSource);
            PexObserve.ValueForViewing("$new_ug_adjacent_degree_source", New_ugAdjacentDegreeSource);
            PexObserve.ValueForViewing("$old_ug_adjacent_degree_target", Old_ugAdjacentDegreeTarget);
            PexObserve.ValueForViewing("$new_ug_adjacent_degree_target", New_ugAdjacentDegreeTarget);
            PexObserve.ValueForViewing("$old_ug_source", Old_source);
            PexObserve.ValueForViewing("$new_ug_source", New_source);
            PexObserve.ValueForViewing("$old_ug_target", Old_target);
            PexObserve.ValueForViewing("$new_ug_target", New_target);
            PexObserve.ValueForViewing("$old_ret", Old_Ret);
            PexObserve.ValueForViewing("$new_ret", New_Ret);
            PexObserve.ValueForViewing("$old_ug_contains_source", Old_ugContainsVertexSource);
            PexObserve.ValueForViewing("$new_ug_contains_source", New_ugContainsVertexSource);
            PexObserve.ValueForViewing("$old_ug_contains_target", Old_ugContainsVertexTarget);
            PexObserve.ValueForViewing("$new_ug_contains_target", New_ugContainsVertexTarget);
            PexObserve.ValueForViewing("$old_ug_allow_parallel_edges", Old_ugAllowParallelEdges);
            PexObserve.ValueForViewing("$new_ug_allow_parallel_edges", New_ugAllowParallelEdges);

            PexAssert.IsTrue(false);
        }
示例#10
0
        public void IndexerPUT([PexAssumeNotNull] List <int> input, int randomPick)
        {
            Heap <int> actual = new Heap <int>(input);

            if (randomPick > -1 && randomPick < input.Count)
            {
                PexObserve.ValueForViewing <int>("Value at index" + randomPick, actual[randomPick]);
            }
            else
            {
                int val = actual[randomPick];
                PexAssert.IsTrue(false, "ArgumentOutOfRangeException was expected");
            }
        }
示例#11
0
        public void MemoizeWithBufferSizeThree()
        {
            var source     = Enumerable.Range(0, 10);
            var x          = new List <int>();
            var enumerable = source.Do(x.Add).Memoize(3);

            var firstEnumerator = enumerable.GetEnumerator();

            for (var i = 0; i < 5; i++)
            {
                PexAssert.IsTrue(firstEnumerator.MoveNext());
                PexAssert.AreEqual(i, firstEnumerator.Current);
            }

            var secondEnumerator = enumerable.GetEnumerator();

            for (var i = 0; i < 5; i++)
            {
                PexAssert.IsTrue(secondEnumerator.MoveNext());
                PexAssert.AreEqual(i + 2, secondEnumerator.Current);
            }

            PexAssert.AreElementsEqual(x, Enumerable.Range(0, 7), (a, b) => object.Equals(a, b));

            var thirdEnumerator = enumerable.GetEnumerator();

            for (var i = 0; i < 6; i++)
            {
                PexAssert.IsTrue(thirdEnumerator.MoveNext());
                PexAssert.AreEqual(i + 4, thirdEnumerator.Current);
            }
            PexAssert.IsFalse(thirdEnumerator.MoveNext());

            for (var i = 0; i < 5; i++)
            {
                PexAssert.IsTrue(firstEnumerator.MoveNext());
                PexAssert.AreEqual(i + 5, firstEnumerator.Current);
            }
            PexAssert.IsFalse(firstEnumerator.MoveNext());

            for (var i = 0; i < 3; i++)
            {
                PexAssert.IsTrue(secondEnumerator.MoveNext());
                PexAssert.AreEqual(i + 7, secondEnumerator.Current);
            }
            PexAssert.IsFalse(secondEnumerator.MoveNext());


            PexAssert.AreElementsEqual(x, source, (a, b) => object.Equals(a, b));
        }
示例#12
0
        public void Let([PexAssumeNotNull] IEnumerable <int> source)
        {
            Func <IEnumerable <int>, IEnumerable <int> > result = xs => xs.Select(x => x * 2);
            var enumerable       = source.Let(result);
            var enumerator       = enumerable.GetEnumerator();
            var sourceEnumerator = source.GetEnumerator();

            while (sourceEnumerator.MoveNext())
            {
                PexAssert.IsTrue(enumerator.MoveNext());
                PexAssert.AreEqual(sourceEnumerator.Current * 2, enumerator.Current);
            }
            PexAssert.IsFalse(enumerator.MoveNext());
        }
示例#13
0
        public string TrimStart(string input, string startsWith, StringComparison comparisonType)
        {
            string result = CommonStringExtensions.TrimStart(input, startsWith, comparisonType);

            PexAssert.IsNotNull(result);
            PexAssert.IsTrue(result.Length <= input.Length);

            bool stillStartsWith      = result.StartsWith(startsWith, comparisonType);
            bool isStartsWithNotEmpty = startsWith.Length > 0;

            PexAssert.IsTrue(!stillStartsWith || !isStartsWithNotEmpty);

            return(result);
        }
        public string TrimEndOnce(string input, string startsWith, StringComparison comparisonType)
        {
            string result = CommonStringExtensions.TrimEndOnce(input, startsWith, comparisonType);

            PexAssert.IsNotNull(result);
            PexAssert.IsTrue(result.Length <= input.Length);

            int originalStartsWithCount = CommonStringExtensions.CountSubstringStart(input, startsWith);
            int resultStartsWithCount   = CommonStringExtensions.CountSubstringStart(result, startsWith);

            PexAssert.IsTrue(originalStartsWithCount - resultStartsWithCount <= 1);

            return(result);
        }
示例#15
0
        public void Finally <T>([PexAssumeNotNull] IEnumerable <T> begin, [PexAssumeNotNull] IEnumerable <T> rest, bool shouldThrow)
        {
            var done       = false;
            var enumerable = begin;
            var exception  = new Exception();

            if (shouldThrow)
            {
                enumerable = enumerable.Concat(EnumerableEx.Throw <T>(exception));
            }

            enumerable = enumerable.Concat(rest);

            enumerable = enumerable.Finally(() => done = true);

            var enumerator = enumerable.GetEnumerator();

            var beginEnumerator = begin.GetEnumerator();

            while (beginEnumerator.MoveNext())
            {
                PexAssert.IsTrue(enumerator.MoveNext());
                PexAssert.AreEqual(beginEnumerator.Current, enumerator.Current);
            }

            if (shouldThrow)
            {
                try
                {
                    enumerator.MoveNext();
                    PexAssert.Fail();
                }
                catch (Exception ex)
                {
                    PexAssert.AreEqual(exception, ex);
                }
            }
            else
            {
                var restEnumerator = rest.GetEnumerator();

                while (restEnumerator.MoveNext())
                {
                    PexAssert.IsTrue(enumerator.MoveNext());
                    PexAssert.AreEqual(restEnumerator.Current, enumerator.Current);
                }
                PexAssert.IsFalse(enumerator.MoveNext());
            }
            PexAssert.IsTrue(done);
        }
示例#16
0
        /// Summary
        /// Time: 14 min 15 sec
        /// Pattern: Constructor Test, State Relation
        /// Generalizes four unit tests AddTest, ClearTest, ContainsTest, CopyIEnumerableToSetTest into one PUT
        public void AddTest([PexAssumeUnderTest] HashSet <int> newelements)
        {
            OrderedSet <int> actual = new OrderedSet <int>(newelements);

            PexAssert.AreEqual(newelements.Count, actual.Count);

            foreach (int elem in newelements)
            {
                PexAssert.IsTrue(actual.Contains(elem));
            }

            actual.Clear();
            PexAssert.AreEqual(0, actual.Count);
        }
        public void MakeSubStorages()
        {
            RegistrySettingsStorage sub1 = (RegistrySettingsStorage)storage.MakeChildStorage("Sub1");
            RegistrySettingsStorage sub2 = (RegistrySettingsStorage)storage.MakeChildStorage("Sub2");

            Assert.IsNotNull(sub1, "Sub1 is null");
            Assert.IsNotNull(sub2, "Sub2 is null");

            String test1 = "HKEY_CURRENT_USER\\" + testKeyName + "\\Sub1";

            PexAssert.IsTrue(sub1.StorageKey.Name.ToLower().Equals(test1.ToLower()));
            String test2 = "HKEY_CURRENT_USER\\" + testKeyName + "\\Sub2";

            PexAssert.IsTrue(sub2.StorageKey.Name.ToLower().Equals(test2.ToLower()));
        }
示例#18
0
        public void RemoveMaxRightChildGreaterTest()
        {
            Heap <int> actual = new Heap <int>(Strategy.Max)
            {
                46, 23, 44, 66, 51, 32, 17, 8
            };
            Heap <int> expected = new Heap <int>(Strategy.Max)
            {
                66, 46, 44, 23, 8, 32, 17
            };

            PexAssert.IsTrue(actual.Remove(51));
            PexAssert.AreEqual(7, actual.Count);
            CollectionAssert.AreEqual(expected, actual);
        }
示例#19
0
        public void MergeOrderedCharsPUT(char[] unsorted)
        {
            if (unsorted == null)
            {
                unsorted.MergeSort();
                PexAssert.IsTrue(false, "ArgumentNullException was expected");
            }
            IList <char> actual   = unsorted.MergeSort();
            IList <char> expected = unsorted.ShellSort();

            for (int i = 0; i < actual.Count; i++)
            {
                PexAssert.AreEqual(expected[i], actual[i]);
            }
        }
示例#20
0
        public void SelectManyProjectOther <TFirst, TSecond>([PexAssumeNotNull] TFirst[] first, [PexAssumeNotNull] TSecond[] second)
        {
            var enumerable = first.SelectMany(second);
            var enumerator = enumerable.GetEnumerator();

            for (var i = 0; i < first.Length; i++)
            {
                for (var j = 0; j < second.Length; j++)
                {
                    PexAssert.IsTrue(enumerator.MoveNext());
                    PexAssert.AreEqual(second[j], enumerator.Current);
                }
            }
            PexAssert.IsFalse(enumerator.MoveNext());
        }
示例#21
0
 public void NoHtmlChars_AnyInput(ErrorMode errorMode, [PexAssumeNotNull] string input)
 {
     PexAssume.EnumIsDefined(errorMode);
     try
     {
         var output = BBCodeTestUtil.SimpleBBEncodeForTest(input, errorMode);
         PexObserve.ValueForViewing("output", output);
         PexAssert.IsTrue(output.IndexOf('<') == -1);
         PexAssert.IsTrue(output.IndexOf('>') == -1);
     }
     catch (BBCodeParsingException)
     {
         PexAssume.Fail();
     }
 }
示例#22
0
        public void PUT_AdjacentEdgeContract([PexAssumeUnderTest] UndirectedGraph.UndirectedGraph <int, Edge <int> > ug, int x, int index)
        {
            AssumePrecondition.IsTrue(ug.ContainsVertex(x) && (index < ug.AdjacentDegree(x)) && (index >= 0));

            int  Old_ugVertexCount    = ug.VertexCount;
            int  Old_ugEdgeCount      = ug.EdgeCount;
            int  Old_ugAdjacentDegree = ug.AdjacentDegree(x);
            int  Old_x                    = x;
            int  Old_index                = index;
            int  Old_Ret_Source           = PexChoose.Value <int>("old_Ret_Source");
            int  Old_Ret_Target           = PexChoose.Value <int>("old_Ret_Target");
            bool Old_ugAllowParallelEdges = ug.AllowParallelEdges;
            bool Old_ugContainsVertexX    = ug.ContainsVertex(x);

            //code
            var e = ug.AdjacentEdge(x, index);
            int New_Ret_Source = e.Source;
            int New_Ret_Target = e.Target;

            int  New_ugVertexCount    = ug.VertexCount;
            int  New_ugEdgeCount      = ug.EdgeCount;
            int  New_ugAdjacentDegree = ug.AdjacentDegree(x);
            int  New_x     = x;
            int  New_index = index;
            bool New_ugAllowParallelEdges = ug.AllowParallelEdges;
            bool New_ugContainsVertexX    = ug.ContainsVertex(x);

            PexObserve.ValueForViewing("$old_ug_vertex_count", Old_ugVertexCount);
            PexObserve.ValueForViewing("$new_ug_vertex_count", New_ugVertexCount);
            PexObserve.ValueForViewing("$old_ug_edge_count", Old_ugEdgeCount);
            PexObserve.ValueForViewing("$new_ug_edge_count", New_ugEdgeCount);
            PexObserve.ValueForViewing("$old_ug_adjacent_degree", Old_ugAdjacentDegree);
            PexObserve.ValueForViewing("$new_ug_adjacent_degree", New_ugAdjacentDegree);
            PexObserve.ValueForViewing("$old_ug_x", Old_x);
            PexObserve.ValueForViewing("$new_ug_x", New_x);
            PexObserve.ValueForViewing("$old_ug_index", Old_index);
            PexObserve.ValueForViewing("$new_ug_index", New_index);
            PexObserve.ValueForViewing("$old_ret_source", Old_Ret_Source);
            PexObserve.ValueForViewing("$new_ret_source", New_Ret_Source);
            PexObserve.ValueForViewing("$old_ret_target", Old_Ret_Target);
            PexObserve.ValueForViewing("$new_ret_target", New_Ret_Target);
            PexObserve.ValueForViewing("$old_ug_contains_x", Old_ugContainsVertexX);
            PexObserve.ValueForViewing("$new_ug_contains_x", New_ugContainsVertexX);
            PexObserve.ValueForViewing("$old_ug_allow_parallel_edges", Old_ugAllowParallelEdges);
            PexObserve.ValueForViewing("$new_ug_allow_parallel_edges", New_ugAllowParallelEdges);

            PexAssert.IsTrue(false);
        }
示例#23
0
        public void ContainsPUT([PexAssumeNotNull] List <int> input, int randomPick)
        {
            Heap <int> minHeap = new Heap <int>(input);
            Heap <int> maxHeap = new Heap <int>(input, Strategy.Max);;

            if (input.Contains(randomPick))
            {
                PexAssert.IsTrue(minHeap.Contains(randomPick));
                PexAssert.IsTrue(maxHeap.Contains(randomPick));
            }
            else
            {
                PexAssert.IsFalse(minHeap.Contains(randomPick));
                PexAssert.IsFalse(maxHeap.Contains(randomPick));
            }
        }
示例#24
0
 public void InsertionSortPUT(int[] unsorted)
 {
     if (unsorted == null)
     {
         unsorted.InsertionSort();
         PexAssert.IsTrue(false, "Expected the exception to be thrown");
     }
     int[] temp = new int[unsorted.Length];
     for (int i = 0; i < unsorted.Length; i++)
     {
         temp[unsorted.Length - (i + 1)] = unsorted[i];
     }
     int[] actual = temp.InsertionSort() as int[];
     PexObserve.ValueForViewing <IList <int> >("Insertion sort result", actual);
     //PexAssert.AreEqual(unsorted.ShellSort(), actual);
 }
示例#25
0
        public void RepeatEnumerableCountTimes <T>([PexAssumeNotNull] T[] value, int count)
        {
            var items      = value.Length;
            var enumerable = EnumerableEx.Repeat((IEnumerable <T>)value, count);
            var enumerator = enumerable.GetEnumerator();

            for (var i = 0; i < count; i++)
            {
                for (var j = 0; j < items; j++)
                {
                    PexAssert.IsTrue(enumerator.MoveNext());
                    PexAssert.AreEqual(value[j], enumerator.Current);
                }
            }
            PexAssert.IsFalse(enumerator.MoveNext());
        }
示例#26
0
        public void TestClearRoutinesPUT3([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(value[i] is String || value[i] is int);
                PexAssume.IsNotNull(value[i]);
                // }
                if (i < key.Length)
                {
                    PexAssume.IsNotNull(key[i]);
                    PexAssume.IsTrue(key[i].Contains("t"));
                }
            }
            NUnitRegistry.TestMode = true;
            using (RegistryKey mainKey = NUnitRegistry.CurrentUser)
            {
                mainKey.SetValue(name[0], value[0]);
                int       k       = 0;
                ArrayList keyList = new ArrayList();
                keyList.Add(mainKey);
                for (k = 1; k < name.Length; k++)
                {
                    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]);
                    keyList.Add(subKey);
                }

                NUnitRegistry.ClearTestKeys();
                PexAssert.IsTrue(mainKey.ValueCount == 0);
                PexAssert.IsTrue(mainKey.SubKeyCount == 0);
            }
        }
示例#27
0
        public string TrimEnd(string input, string endsWith, StringComparison comparisonType)
        {
            PexAssume.IsNotNull(input);
            PexAssume.IsNotNull(endsWith);

            string result = CommonStringExtensions.TrimEnd(input, endsWith, comparisonType);

            PexAssert.IsNotNull(result);
            PexAssert.IsTrue(result.Length <= input.Length);

            bool stillEndsWith      = result.EndsWith(endsWith, comparisonType);
            bool isEndsWithNotEmpty = endsWith.Length > 0;

            PexAssert.IsTrue(!stillEndsWith || !isEndsWithNotEmpty);

            return(result);
        }
示例#28
0
 public void SetCollectionNodeTest(
     [PexAssumeUnderTest] XmpTag target,
     string ns,
     string name,
     string[] values,
     XmpNodeType type
     )
 {
     PexAssume.IsNotNull(ns);
     PexAssume.IsNotNull(name);
     PexAssume.IsNotNull(values);
     PexAssume.IsTrue(!values.Contains(null));
     PexAssume.IsTrue(type != XmpNodeType.Simple && type != XmpNodeType.Alt);
     target.SetCollectionNode(ns, name, values, type);
     PexAssert.IsTrue(values.SequenceEqual(target.GetCollectionNode(ns, name)));
     // TODO: add assertions to method XmpTagTest.SetCollectionNodeTest(XmpTag, String, String, String[], XmpNodeType)
 }
示例#29
0
 public string[] GetCollectionNodeTest(
     [PexAssumeUnderTest] XmpTag target,
     string ns,
     string name,
     string[] values
     )
 {
     PexAssume.IsNotNull(ns);
     PexAssume.IsNotNull(name);
     PexAssume.IsNotNull(values);
     PexAssume.IsTrue(!values.Contains(null));
     target.SetCollectionNode(ns, name, values, XmpNodeType.Seq);
     string[] result = target.GetCollectionNode(ns, name);
     PexAssert.IsTrue(result.SequenceEqual(values));
     return(result);
     // TODO: add assertions to method XmpTagTest.GetCollectionNodeTest(XmpTag, String, String)
 }
示例#30
0
        public void AnyMatchingPUT(string basestring, string input)
        {
            if (basestring == null || input == null)
            {
                basestring.Any(input);
                PexAssert.IsTrue(false, "Exception should have been thrown");
            }
            Regex charPattern = new Regex(@"^[a-zA-Z\s]*$");

            basestring = Regex.Replace(basestring, @"[\s]+", "            ");
            input      = Regex.Replace(input, @"[\s]+", "            ");
            int actual = basestring.Any(input);
            /** compute expected **/
            int expected = input.IndexOfAny(basestring.ToCharArray());

            PexAssert.AreEqual(expected, actual);
        }