Пример #1
0
 public void SetUp()
 {
     Matcher = new EqualConstraint("Hello World!").IgnoreCase;
     GoodValues = new object[] { "hello world!", "Hello World!", "HELLO world!" };
     BadValues = new object[] { "goodbye", "Hello Friends!", string.Empty, null };
     Description = "\"Hello World!\", ignoring case";
 }
Пример #2
0
 protected override void SetUp()
 {
     Matcher = new EqualConstraint( 4 );
     GoodValues = new object[] { 4, 4.0f, 4.0d, 4.0000m };
     BadValues = new object[] { 5, null, "Hello" };
     Description = "4";
 }
        public void WriteMessageTo_DifferentJson_DelegateToEquals()
        {
            string expected = "{'prop'='value'}",
               actual = "{\"abcd\"=\"12345\"}";
            var subject = new JsonEqualConstraint(expected);
            var equals = new EqualConstraint(expected.Jsonify());

            Assert.That(getMessage(subject, actual),
                Is.EqualTo(getMessage(equals, actual)));
        }
        public void ChangeEventIsFiredAppropriatelyWhenFocusIsLost()
        {
            driver.Url = javascriptPage;

            IWebElement input = driver.FindElement(By.Id("changeable"));
            input.SendKeys("test");
            driver.FindElement(By.Id("clickField")).Click(); // move focus
            EqualConstraint firstConstraint = new EqualConstraint("focus change blur");
            EqualConstraint secondConstraint = new EqualConstraint("focus change blur");

            Assert.That(driver.FindElement(By.Id("result")).Text.Trim(), firstConstraint | secondConstraint);

            input.SendKeys(Keys.Backspace + "t");
            driver.FindElement(By.Id("clickField")).Click();  // move focus

            firstConstraint = new EqualConstraint("focus change blur focus blur");
            secondConstraint = new EqualConstraint("focus blur change focus blur");
            EqualConstraint thirdConstraint = new EqualConstraint("focus blur change focus blur change");
            EqualConstraint fourthConstraint = new EqualConstraint("focus change blur focus change blur"); //What Chrome does
            // I weep.
            Assert.That(driver.FindElement(By.Id("result")).Text.Trim(),
                       firstConstraint | secondConstraint | thirdConstraint | fourthConstraint);
        }
Пример #5
0
        public void PropertyEqualToValueWithTolerance()
        {
            Constraint c = new EqualConstraint(105m).Within(0.1m);
            TextMessageWriter w = new TextMessageWriter();
            c.WriteDescriptionTo(w);
            Assert.That(w.ToString(), Is.EqualTo("105m +/- 0.1m"));

            c = new PropertyConstraint("D", new EqualConstraint(105m).Within(0.1m));
            w = new TextMessageWriter();
            c.WriteDescriptionTo(w);
            Assert.That(w.ToString(), Is.EqualTo("property D equal to 105m +/- 0.1m"));
        }
Пример #6
0
		/// <summary>
		/// Verifies that two doubles are equal considering a delta. If the
		/// expected value is infinity then the delta value is ignored. If 
		/// they are not equals then an <see cref="AssertionException"/> is
		/// thrown.
		/// </summary>
		/// <param name="expected">The expected value</param>
		/// <param name="actual">The actual value</param>
		/// <param name="delta">The maximum acceptable difference between the
		/// the expected and the actual</param>
		/// <param name="message">The message that will be displayed on failure</param>
		/// <param name="args">Arguments to be used in formatting the message</param>
		static public void AreEqual(double expected, 
			double actual, double delta, string message, params object[] args) 
		{
			Constraint constraint = new EqualConstraint( expected );
			if ( double.IsNaN(expected) || double.IsInfinity(expected) )
				Assert.That(actual, Is.EqualTo( expected ), message, args);
			else
				Assert.That(actual, Is.EqualTo(expected).Within(delta), message, args);
        }
 private void HasLogMessage(EqualConstraint s)
 {
     // NSubstitute 
     //log.Received().Log(LogLevel.Error, Arg.Is<Func<string>>(x => Verify(x, s)));
     log.Verify(y=>y.Log(LogLevel.Error, It.Is<Func<string>>(x => Verify(x, s)), null));
 }
 private void HasLogMessageException(EqualConstraint s)
 {
     // NSubstitute 
     // log.Received().Log(LogLevel.Error, Arg.Is<Func<string>>(x => Verify(x, s)), exception);
     log.Verify(y => y.Log(LogLevel.Error, It.Is<Func<string>>(x => Verify(x, s)), It.IsAny<Exception>()));
 }