Example #1
0
        public void ResultsProxyTest()
        {
            TestPlan tp = new TestPlan();

            tp.ChildTestSteps.Add(new DelegateTestStep
            {
                RunAction = (r) =>
                {
                    var rand = new Random();

                    IConvertible[] values = new IConvertible[3];
                    values[0]             = rand.NextDouble();
                    values[1]             = rand.NextDouble();
                    values[2]             = rand.NextDouble();

                    r.Publish("Publish1", new List <string> {
                        "a", "b", "c"
                    }, values);
                    r.Publish("Publish2", new List <string> {
                        "a", "b", "c"
                    }, values);
                    r.PublishTable("PublishTable", new List <string> {
                        "a", "b", "c"
                    }, values.Select(v => new IConvertible[1] {
                        v
                    }).ToArray());

                    values[0] = rand.NextDouble();
                    values[1] = rand.NextDouble();
                    values[2] = rand.NextDouble();

                    values[0] = "abc";
                    values[1] = "rand";
                    values[2] = "rand.NextDouble()";
                    r.Publish("PublishStrings", new List <string> {
                        "a", "b", "c"
                    }, values);

                    values[0] = null;
                    values[1] = "rand";
                    values[2] = true;
                    r.Publish("PublishMixed", new List <string> {
                        "a", "b", "c"
                    }, values);
                }
            });

            var rl = new ResultValidator();

            tp.Execute(new List <ResultListener> {
                rl
            });

            Assert.AreEqual(5, rl.Results.Count, "Number of results");
            foreach (var res in rl.Results)
            {
                Assert.IsTrue(res.Name.StartsWith("Publish"), "Name of result");
                Assert.AreEqual(3, res.Columns.Length, "Number of columns in " + res.Name);

                Assert.AreEqual(1, res.Columns[0].Data.Length);
                Assert.AreEqual(1, res.Columns[1].Data.Length);
                Assert.AreEqual(1, res.Columns[2].Data.Length);

                Assert.AreEqual("a", res.Columns[0].Name);
                Assert.AreEqual("b", res.Columns[1].Name);
                Assert.AreEqual("c", res.Columns[2].Name);
            }
        }