Beispiel #1
0
        public void IsFalse()
        {
            var b = false;
            var guardValidator  = new Action(() => Guard.That(b).IsFalse());
            var nativeValidator = new Action(() =>
            {
                // ReSharper disable once UseMethodAny.2
                if (b != false)
                {
                    throw new Exception();
                }
            });

            PerfTestHelper.RunTest(5.4, DefaultReply, guardValidator, nativeValidator);
        }
Beispiel #2
0
        public void CountIs()
        {
            var array           = Enumerable.Repeat(string.Empty, 10).ToArray();
            var guardValidator  = new Action(() => Guard.That(array).CountIs(10));
            var nativeValidator = new Action(() =>
            {
                // ReSharper disable once UseMethodAny.2
                if (array.Length != 10)
                {
                    throw new Exception();
                }
            });

            PerfTestHelper.RunTest(9, DefaultReply * 10, guardValidator, nativeValidator);
        }
Beispiel #3
0
        public void Length()
        {
            var enumerable      = Enumerable.Repeat(string.Empty, 10);
            var guardValidator  = new Action(() => Guard.That(enumerable).Length(10));
            var nativeValidator = new Action(() =>
            {
                // ReSharper disable once UseMethodAny.2
                if (enumerable.Count() != 10)
                {
                    throw new Exception();
                }
            });

            PerfTestHelper.RunTest(1.75, DefaultReply, guardValidator, nativeValidator);
        }
Beispiel #4
0
        public void IsNotEmpty()
        {
            var collection = new List <int> {
                1, 2, 3
            };

            var guardValidator  = new Action(() => Guard.That(collection).IsNotEmpty());
            var nativeValidator = new Action(() =>
            {
                // ReSharper disable once UseMethodAny.2
                if (collection.Count == 0)
                {
                    throw new Exception();
                }
            });

            PerfTestHelper.RunTest(3.5, DefaultReply, guardValidator, nativeValidator);
        }
Beispiel #5
0
        public void Contains_Pred(int itemsCount, long repliesCount)
        {
            var list = new List <string>(Enumerable.Repeat(string.Empty, itemsCount))
            {
                "test", "test"
            };
            var dataSource      = list.AsEnumerable();
            var guardValidator  = new Action(() => Guard.That(dataSource).Contains(text => text == "test"));
            var nativeValidator = new Action(() =>
            {
                // ReSharper disable once UseMethodAny.2
                if (dataSource.All(text => text != "test"))
                {
                    throw new Exception();
                }
            });

            PerfTestHelper.RunTest(1.3, repliesCount, guardValidator, nativeValidator);
        }