Esempio n. 1
0
        public void TestValidate()
        {
            // Must have 2 or more String subnodes
            try
            {
                concatNode.Validate(SupportExprValidationContextFactory.MakeEmpty(container));
                Assert.Fail();
            }
            catch (ExprValidationException)
            {
                // Expected
            }

            // Must have only string-type subnodes
            concatNode.AddChildNode(new SupportExprNode(typeof(string)));
            concatNode.AddChildNode(new SupportExprNode(typeof(int?)));
            try
            {
                concatNode.Validate(SupportExprValidationContextFactory.MakeEmpty(container));
                Assert.Fail();
            }
            catch (ExprValidationException)
            {
                // Expected
            }
        }
Esempio n. 2
0
        private void RunAssertionThreading(ThreadingProfile threadingProfile)
        {
            concatNode = new ExprConcatNode();
            var textA = "This is the first text";
            var textB = "Second text";
            var textC = "Third text, some more";

            foreach (var text in Arrays.AsList(textA, textB, textC))
            {
                concatNode.AddChildNode(new ExprConstantNodeImpl(text));
            }

            concatNode.Validate(SupportExprValidationContextFactory.MakeEmpty(container, threadingProfile));

            var numThreads = 4;
            var numLoop    = 10000;

            var threads = new List <Pair <Thread, SupportConcat> >(numThreads);

            for (var i = 0; i < numThreads; i++)
            {
                var supportConcat = new SupportConcat(concatNode, numLoop, textA + textB + textC);
                var thread        = new Thread(supportConcat.Run);
                threads.Add(new Pair <Thread, SupportConcat>(thread, supportConcat));
                thread.Start();
            }

            foreach (var threadPair in threads)
            {
                threadPair.First.Join();
                Assert.IsFalse(threadPair.Second.IsFail);
            }
        }