public EggplantElement WaitForPresent(int secs)
        {
            Log.Message(string.Format("Waiting for element {0} to be present within (" + secs + ") seconds.", locator));
            var now     = DateTime.Now;
            var endTime = DateTime.Now.AddSeconds(secs);

            while (now < endTime)
            {
                if (Driver.IsPresent(locator))
                {
                    Log.Message(string.Format("Verification Passed : Element {0} is present.", locator));
                    return(this);
                }
                else
                {
                    Thread.Sleep(500);
                    now = DateTime.Now;
                }
            }
            TestLog.BeginSection("ERROR FOUND");
            Log.Message(string.Format("!----ERROR : Element not found: " + locator + "."));
            LogSourceImage();
            //LogFailureImage(string.Format("!----ERROR : Element not found: " + locator + "."));
            TestLog.End();
            throw new Exception(string.Format("Element was not present after {0} seconds", secs));
        }
 protected void Logout()
 {
     using (TestLog.BeginSection("Lgout from sharpcms adminpage"))
     {
         Ie.Link(Find.ByText("Log out")).Click();
         Assert.IsTrue(Ie.ContainsText("Login"), "Expected to find \"Login \" on the page.");
     }
 }
示例#3
0
 public void PrintActions()
 {
     TestLog.BeginSection("Actions");
     foreach (Action a in actions)
     {
         TestLog.WriteLine(a.name + " : " + a._time.ToString("HH:mm:ss.ffff"));
     }
     TestLog.End();
 }
            public void Test()
            {
                using (TestLog.BeginSection("Section *\n*"))
                {
                    TestLog.WriteLine("Text *\0* Content");
                }

                DiagnosticLog.WriteLine("Diagnostic *\0* Log");
            }
示例#5
0
 public static void Message(string message, Image image)
 {
     TestLog.BeginSection("");
     Log.Message(message);
     if (image != null)
     {
         TestLog.EmbedImage(null, image);
     }
     TestLog.End();
 }
 public void DoScreenshotTest()
 {
     Assert.IsNotNull(ie);
     using (TestLog.BeginSection("Go to Google, enter MbUnit as a search term and click I'm Feeling Lucky"))
     {
         ie.GoTo("http://www.google.com");
         ie.TextField(Find.ByName("q")).TypeText("MbUnit");
         ie.Button(Find.ByName("btnI")).Click();
     }
     Assert.IsTrue(ie.ContainsText("NUnit"), "Expected to find NUnit on the page.");
 }
        public void CreatePage()
        {
            Login();

            using (TestLog.BeginSection("Go to sharpcms adminpage and press logout"))
            {
                Ie.Link(Find.ByText("Pages")).Click();
                Assert.IsTrue(Ie.ContainsText("German"), "Expected to find \"German\" on the page.");
                Ie.Link(Find.ByText("German")).Click();
                Assert.IsTrue(Ie.ContainsText("Page data "), "Expected to find \"Page data \" on the page.");
            }

            Logout();
        }
示例#8
0
            public void Simplify(string leftDocument, string rightDocument, int expectedNumberOfDiffs)
            {
                DiffSet originalDiffSet   = DiffSet.GetDiffSet(leftDocument, rightDocument);
                DiffSet simplifiedDiffSet = originalDiffSet.Simplify();

                using (TestLog.BeginSection("Original DiffSet"))
                    originalDiffSet.WriteTo(TestLog.Default);
                using (TestLog.BeginSection("Simplified DiffSet"))
                    simplifiedDiffSet.WriteTo(TestLog.Default);

                VerifyDiffSetIsValid(simplifiedDiffSet);
                Assert.LessThanOrEqualTo(simplifiedDiffSet.Diffs.Count, originalDiffSet.Diffs.Count);

                Assert.AreEqual(expectedNumberOfDiffs, simplifiedDiffSet.Diffs.Count);
            }
        private static void AssertTrace <T>(Expression <System.Func <T> > expr,
                                            T expectedValue, string[] expectedTrace)
        {
            using (TestLog.BeginSection(expr.Format()))
            {
                var tracer = new ExpressionTracer();

                TestLog.WriteLine("Rewritten expression: {0}", tracer.Rewrite(expr).Format());
                T actualValue = tracer.Compile(expr)();

                Assert.AreEqual(expectedValue, actualValue, "Expression result should be equal.");
                Assert.Over.Pairs(expectedTrace, tracer.Trace, Assert.AreEqual,
                                  "Expression trace should be equal.");
            }
        }
        protected void Login()
        {
            using (TestLog.BeginSection("Go to sharpcms adminpage"))
            {
                Ie.GoTo("http://localhost:17267/cleansite/login.aspx");
                Assert.IsTrue(Ie.ContainsText("Login"), "Unable to load adminpage! Ensure that the webserver is started");
            }

            using (TestLog.BeginSection("Enter the password and press login"))
            {
                Ie.TextField(Find.ByName("data_login")).TypeText("admin");
                Ie.TextField(Find.ByName("data_password")).TypeText("admin");
                Ie.Button(Find.ByValue("Login")).Click();
                Assert.IsTrue(Ie.ContainsText("Pages"), "Expected to find \"Pages\" on the page.");
            }
        }
示例#11
0
        public static AssertionFailure[] Capture(GallioAction action)
        {
            AssertionFailure[] failures = AssertionHelper.Eval(action);

            if (failures.Length != 0)
            {
                using (TestLog.BeginSection("Captured Assertion Failures"))
                {
                    foreach (AssertionFailure failure in failures)
                    {
                        failure.WriteTo(TestLog.Default);
                    }
                }
            }

            return(failures);
        }
            public string Run()
            {
                StringWriter textWriter = new StringWriter();

                textWriter.NewLine = "\n";
                Console.SetOut(textWriter);

                Assert.IsFalse(RuntimeAccessor.IsInitialized);

                TestLog.AttachPlainText("Attachment1", "Text");
                using (TestLog.BeginSection("Test Section"))
                {
                    TestLog.WriteLine("Foo");
                    TestLog.EmbedExisting("Attachment1");
                }

                return(textWriter.ToString());
            }
        public void Sections()
        {
            TestLog.Write("Some text with no newline.");

            using (TestLog.BeginSection("A section."))
            {
                TestLog.WriteLine("Some text.");
                TestLog.WriteLine("More text.");

                TestLog.EmbedImage("An image", Resources.MbUnitLogo);

                using (TestLog.BeginSection("Another section."))
                {
                    TestLog.Write("Same image as above.");
                    TestLog.EmbedExisting("An image");
                }
            }
        }
示例#14
0
        public void GetTests()
        {
            using (var repository = new UnmanagedTestRepository(resources))
            {
                Assert.IsTrue(repository.IsValid);
                TestInfoData[] items = repository.GetTests().ToArray();
                Assert.IsNotEmpty(items);

                using (TestLog.BeginSection(String.Format("Found {0} test item(s):", items.Length)))
                {
                    foreach (TestInfoData item in items)
                    {
                        DiagnosticLog.WriteLine("{0}: Fixture={1}, Test={2}, Row={3}, Kind={4}",
                                                item.Name, item.Native.Position.pTestFixture, item.Native.Position.pTest,
                                                item.Native.Position.pRow, item.Kind);
                    }
                }
            }
        }
示例#15
0
        public void PrintActionTimings()
        {
            TestLog.BeginSection("Test Action Timings:");
            DateTime start;
            DateTime end;
            TimeSpan difference;

            for (int i = 1; i < actions.Count; i++)
            {
                start      = actions[i - 1]._time;
                end        = actions[i]._time;
                difference = end.Subtract(start);
                TestLog.WriteLine(actions[i].name + " : " + difference);
            }
            start      = actions[0]._time;
            end        = actions[actions.Count - 1]._time;
            difference = end.Subtract(start);
            TestLog.WriteLine("All Actions : " + difference);
            TestLog.End();
        }
示例#16
0
        public void JoinProducesCoveringsOfAllPairs(int[] counts, int empiricalUpperBound)
        {
            int dimensions = counts.Length;

            DataBinding binding = new DataBinding(0, null);

            IDataProvider[] providers           = new IDataProvider[dimensions];
            DataBinding[][] bindingsPerProvider = new DataBinding[dimensions][];
            for (int i = 0; i < dimensions; i++)
            {
                providers[i]           = Mocks.StrictMock <IDataProvider>();
                bindingsPerProvider[i] = new DataBinding[] { binding };

                IDataItem[] providerItems = new IDataItem[counts[i]];
                for (int j = 0; j < counts[i]; j++)
                {
                    providerItems[j] = new ScalarDataItem <int>(j, null, false);
                }

                Expect.Call(providers[i].GetItems(bindingsPerProvider[i], true)).Return(providerItems);
            }

            Mocks.ReplayAll();

            List <IList <IDataItem> > itemLists = new List <IList <IDataItem> >(PairwiseJoinStrategy.Instance.Join(providers, bindingsPerProvider, true));

            int[][] values = new int[itemLists.Count][];
            using (TestLog.BeginSection(String.Format("{0} combinations.", itemLists.Count)))
            {
                for (int i = 0; i < itemLists.Count; i++)
                {
                    IList <IDataItem> itemList = itemLists[i];
                    Assert.AreEqual(dimensions, itemList.Count);

                    values[i] = new int[dimensions];
                    for (int j = 0; j < itemList.Count; j++)
                    {
                        int value = (int)itemList[j].GetValue(binding);
                        values[i][j] = value;

                        if (j != 0)
                        {
                            TestLog.Write(",");
                        }
                        TestLog.Write(value);
                    }

                    TestLog.WriteLine();
                }
            }

            // Check pairings.
            bool   missingPairing   = false;
            double meanOccurrences  = 0;
            double stdevOccurrences = 0;
            int    pairingCount     = 0;

            using (TestLog.BeginSection("Pairings"))
            {
                for (int firstDimension = 0; firstDimension < dimensions; firstDimension++)
                {
                    for (int secondDimension = firstDimension + 1; secondDimension < dimensions; secondDimension++)
                    {
                        for (int firstValue = 0; firstValue < counts[firstDimension]; firstValue++)
                        {
                            for (int secondValue = 0; secondValue < counts[secondDimension]; secondValue++)
                            {
                                int occurrences = 0;
                                for (int i = 0; i < values.Length; i++)
                                {
                                    if (values[i][firstDimension] == firstValue && values[i][secondDimension] == secondValue)
                                    {
                                        occurrences += 1;
                                    }
                                }

                                TestLog.WriteLine("{0} x {1} : ({2}, {3}) -> {4} occurrences.",
                                                  firstDimension, secondDimension, firstValue, secondValue, occurrences);

                                if (occurrences == 0)
                                {
                                    missingPairing = true;
                                }

                                pairingCount += 1;
                                double diff = occurrences - meanOccurrences;
                                meanOccurrences  += diff / pairingCount;
                                stdevOccurrences += diff * (occurrences - meanOccurrences);
                            }
                        }
                    }
                }
            }

            if (pairingCount > 1)
            {
                stdevOccurrences = Math.Sqrt(stdevOccurrences / (pairingCount - 1));
            }
            else
            {
                stdevOccurrences = 0;
            }

            using (TestLog.BeginSection("Statistics"))
            {
                // A mean of exactly 1 implies we have found a minimal covering.
                // A low standard deviation indicates good uniformity among the covered pairs.  0 would be ideal.
                TestLog.WriteLine("Pairing Occurrence Mean: {0}", meanOccurrences);
                TestLog.WriteLine("Pairing Occurrence Stdev: {0}", stdevOccurrences);
            }

            Assert.IsFalse(missingPairing, "One or more pairings were not covered!");
            Assert.LessThanOrEqualTo(values.Length, empiricalUpperBound, "There were more combinations produced than previously measured.  Has the algorithm gotten worse?");
        }