Exemplo n.º 1
0
        public static void True(bool condition)
        {
#if XUNIT
            FrameworkAssert.True(condition);
#else
            FrameworkAssert.IsTrue(condition);
#endif
        }
Exemplo n.º 2
0
        public void ShouldProcessWebElement()
        {
            //Webelement
            var ele    = driver.FindElementById("input__text");
            var resEle = (WebElement)driver.ExecuteScript("return arguments[0];", ele);

            A.True(ele.Equals(resEle));
        }
Exemplo n.º 3
0
        public void ShouldProcessWebElements()
        {
            //Webelements
            var eles    = driver.FindElementsByTag("input");
            var resEles = (WebElements)driver.ExecuteScript("return arguments;", eles);

            A.AreEqual(eles.Count, resEles.Count);
            A.True(eles.First().Equals(resEles.First()));
        }
Exemplo n.º 4
0
        public void ShouldReturnIsEnabled()
        {
            var ele1 = driver.FindElementById("input__search");

            A.True(ele1.IsEnabled);

            var ele2 = driver.FindElementById("input__search_disabled");

            A.False(ele2.IsEnabled);
        }
Exemplo n.º 5
0
        public void ShouldReturnActiveElement()
        {
            var ele1 = driver.FindElementById("input__search");

            ele1.SendKeys("");

            var ele2 = driver.ActiveElement();

            A.True(ele1.Equals(ele2));
        }
Exemplo n.º 6
0
        public void ShouldReturnDisplayState()
        {
            var ele1 = driver.FindElementById("input__search");

            A.True(ele1.IsDisplayed);

            var ele2 = driver.FindElementById("input__search_hidden");

            A.False(ele2.IsDisplayed);
        }
Exemplo n.º 7
0
        public void ShouldDismissAlert()
        {
            driver.Get("/input.html");
            driver.ExecuteScript("window.setTimeout(function(){window.res=window.confirm('test accept');}, 100);");
            var alert = driver.SwitchToAlert();

            A.AreEqual("test accept", alert.Text);
            alert.Accept();
            A.True((bool)driver.ExecuteScript("return window.res;"));
            A.Null(driver.SwitchToAlert(0, false));
        }
Exemplo n.º 8
0
        public void CanValidateCorrectData()
        {
            // Arrange
            ValidatorTestObject validatorTestObject = new ValidatorTestObject {
                Name = "Test"
            };

            // Act
            bool actual = this.validator.IsValid(validatorTestObject);

            // Assert
            Assert.True(actual);
        }
Exemplo n.º 9
0
        public void ShouldReturnLocation()
        {
            var ele1 = driver.FindElementById("txt_div");

            Point expected = new Point(20, 156);
            Point actual   = ele1.Location();

            int diffX = Math.Abs(actual.X - expected.X);
            int diffY = Math.Abs(actual.Y - expected.Y);

            A.True(diffX < 2 && diffY < 20
                   , string.Format("Expected {0} but was {1}", expected, actual));
        }
Exemplo n.º 10
0
        public void ShouldReturnSelectedState()
        {
            var ele1 = driver.FindElementById("checkbox1");

            A.False(ele1.IsSelected);

            var ele2 = driver.FindElementById("checkbox2");

            A.True(ele2.IsSelected);

            var ele3 = driver.FindElementById("select_item2");

            A.True(ele2.IsSelected);
        }
Exemplo n.º 11
0
        public void CanValidate()
        {
            // Arrange
            YummySausageSalad yummySausageSalad = new YummySausageSalad {
                Name = "Wurstsalat"
            };
            Validator <YummySausageSalad> validator = new Validator <YummySausageSalad>();

            // Act
            bool actual = validator.IsValid(yummySausageSalad);

            // Assert
            Assert.True(actual);
        }
Exemplo n.º 12
0
        public void Verify_Config_True_Returned()
        {
            var configEntityList = new List <ConfigEntity> {
                ConfigEntity
            };
            var mockLogger = new Mock <ILogger>();

            mockLogger.Setup(x => x.LogAsync(It.IsAny <LogParams>())).Returns(Task.CompletedTask);

            var serviceProvider = new ServiceCollection()
                                  .AddSingleton <IConfigVerifier>(p => new ConfigVerifier(mockLogger.Object))
                                  .BuildServiceProvider();

            var configVerifier = serviceProvider.GetService <IConfigVerifier>();
            var result         = configVerifier.Verify(configEntityList);

            Assert.True(result);
        }
Exemplo n.º 13
0
        public static Exception Throws <T>(Action action) where T : Exception
        {
            Exception targetException = null;

            try
            {
                action();
            }
            catch (T ex)
            {
                // Test pass
                return(ex);
            }
#if PORTABLE
            catch (System.Reflection.TargetInvocationException ex)
            {
                var inner = ex.InnerException;
                if (inner is T)
                {
                    return(inner);
                }
                else
                {
                    FrameworkAssert.Fail(String.Format("Wrong exception type thrown. Expected {0}, got {1}.", typeof(T), inner.GetType()));
                }
            }
#endif
            catch (Exception ex)
            {
#if XUNIT
                FrameworkAssert.True(false, String.Format("Wrong exception type thrown. Expected {0}, got {1}.", typeof(T), ex.GetType()));
#else
                FrameworkAssert.Fail(String.Format("Wrong exception type thrown. Expected {0}, got {1}.", typeof(T), ex.GetType()));
#endif
            }
#if XUNIT
            FrameworkAssert.True(false, String.Format("No Expected {0} was thrown", typeof(T).FullName));
#else
            FrameworkAssert.Fail(String.Format("No Expected {0} was thrown", typeof(T).FullName));
#endif
            throw new Exception();
        }
Exemplo n.º 14
0
        private void ShouldZipAndUnzipWithoutLose(bool compress)
        {
            string testfolder = Path.Combine(System.IO.Path.GetTempPath(), DateTime.Now.Ticks.ToString());

            Directory.CreateDirectory(testfolder);

            string path1 = Path.Combine(testfolder, "text1.txt");
            string path2 = Path.Combine(testfolder, "text2.txt");

            string text1 = "";
            string text2 = "START data\r\n ééúóáEN\u0247D";

            CreateTextFile(path1, text1);
            CreateTextFile(path2, text2);

            string zippath    = Path.Combine(testfolder, "archive.zip");
            string extractdir = Path.Combine(testfolder, "extract");
            string path11     = Path.Combine(extractdir, "text1.txt");
            string path22     = Path.Combine(extractdir, "text2.txt");

            try {
                using (var zip = new ZipFile(compress)) {
                    zip.AddFile(path1);
                    zip.AddFile(path2);
                    zip.SaveAs(zippath);
                }

                ZipFile.ExtractAll(zippath, extractdir);

                A.True(Directory.Exists(extractdir));
                A.True(File.Exists(path11));
                A.True(File.Exists(path22));

                var text11 = File.ReadAllText(path11);
                A.AreEqual(text1, text11);

                var text22 = File.ReadAllText(path22);
                A.AreEqual(text2, text22);
            } finally {
                Directory.Delete(testfolder, true);
            }
        }
Exemplo n.º 15
0
        public void ShouldCreatePDF()
        {
            string tempPath = System.IO.Path.GetTempPath() + @"\my-capture.pdf";

            if (System.IO.File.Exists(tempPath))
            {
                System.IO.File.Delete(tempPath);
            }

            var pdf = new PdfFile();

            //Define the PDF page size and margins

            pdf.SetPageSize(210, 297, "mm");
            pdf.SetMargins(10, 10, 10, 15, "mm");

            //Add a title and informations to the PDF
            pdf.AddTextCenter(text: "Selenium search result", size: 20, bold: true);
            pdf.AddTitle("Title A");
            pdf.AddText(text: "Description = Search for Eiffel tower", size: 9, color: "DarkBlue");
            pdf.AddLink("http://www.test.com", "Test link");

            //Add a text paragraph to the PDF file
            string text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam sit amet libero arcu, et molestie purus. Ut in sem lacus, sit amet rhoncus erat. In aliquet arcu at nunc porta sollicitudin. Cras ante nisl, hendrerit quis bibendum quis, egestas vitae mi. Donec ac felis at eros placerat iaculis. Nam quam sapien, scelerisque vel bibendum et, mollis sit amet augue. Nullam egestas, lectus ut laoreet vulputate, neque quam vestibulum sapien, ut vehicula nunc metus et nulla. Curabitur ac lorem augue. Nullam quis justo eu arcu volutpat ultrices ac at orci.";

            pdf.AddText(text: text, size: 10);

            pdf.AddPage();

            //Take a screenschot and add it to the PDF file
            using (var img = new Utils().TakeScreenShot()) {
                pdf.AddBookmark("Bookmark");
                pdf.AddTitle("Capture A");
                pdf.AddImage(img, false);
            }

            pdf.SaveAs(tempPath);

            A.True(System.IO.File.Exists(tempPath));
            A.Greater(new System.IO.FileInfo(tempPath).Length, 25000);
        }
Exemplo n.º 16
0
 public static void assert(bool condition, object msg)
 {
     ////throw new global::System.NotImplementedException("System.Assert : Use NUnit Asserts");
     NUnitAssert.True(condition, "{0}", msg);
 }
Exemplo n.º 17
0
 public static void assert(bool condition)
 {
     NUnitAssert.True(condition);
 }
Exemplo n.º 18
0
 public void assert(bool condition, object msg) =>
 NUnitAssert.True(condition, "{0}", msg);
Exemplo n.º 19
0
 public void assert(bool condition) =>
 NUnitAssert.True(condition);