예제 #1
0
        public void Argument_Threading()
        {
            //arrange
            Action notNullCheck = () =>
            {
                for (int j = 0; j < 1000; j++)
                {
                    Validate.Argument("").IsNotNull().Check();
                }
            };

            ArgumentValidationCounter.Reset();

            List <Task> tasks = new List <Task>();


            //act
            for (int i = 0; i < 50; i++)
            {
                tasks.Add(Task.Run(notNullCheck));
            }

            Task.WaitAll(tasks.ToArray());


            //assert
            Assert.IsTrue(ArgumentValidationCounter.CreationCount <= 20);
            Assert.AreEqual(0, ArgumentValidationCounter.MissingCount);
        }
예제 #2
0
        public void Argument_FootprintTest()
        {
            //set these to zero since previous tests may have moved them.
            ArgumentValidationCounter.Reset();

            Argument_ComplexTest();

            Assert.AreEqual(0, ArgumentValidationCounter.MissingCount);

            var createCount = ArgumentValidationCounter.CreationCount;

            for (int i = 0; i < 100; i++)
            {
                Argument_ComplexTest();
            }

            Assert.AreEqual(createCount, ArgumentValidationCounter.CreationCount);
            Assert.AreEqual(0, ArgumentValidationCounter.MissingCount);
        }