コード例 #1
0
ファイル: PrefixConstraint.cs プロジェクト: alfeg/nunit
        /// <summary>
        /// Construct given a base constraint
        /// </summary>
        /// <param name="baseConstraint"></param>
        protected PrefixConstraint(IResolveConstraint baseConstraint)
            : base(baseConstraint)
        {
            Guard.ArgumentNotNull(baseConstraint, "baseConstraint");

            this.baseConstraint = baseConstraint.Resolve();
        }
コード例 #2
0
		public static void WithHeader(this RequestHandler handler, string header, IResolveConstraint match)
		{
			string headerValue;
			handler.LastRequest().RequestHead.Headers.TryGetValue(header, out headerValue);
			Assert.That(headerValue, Is.Not.Null, "Request did not contain a header '{0}'", header);
			Assert.That(headerValue, match);
		}
コード例 #3
0
 public static void That(object actual, IResolveConstraint expected, string message, bool @continue = true)
 {
     try
     {
         Assert.That(actual, expected, message);
     }
     catch (AssertionException ae)
     {
         TestFailure.HandleAssertionException(ae, @continue);
     }
 }
コード例 #4
0
ファイル: KoanAssert.cs プロジェクト: psrodriguez/CIAPI.CS
 public static void That(object actual, IResolveConstraint expression, string message)
 {
     try
     {
         Assert.That(actual, expression, message);
     }
     catch (Exception ex)
     {
         throw new FailedToReachEnlightenmentException(ex.Message);
     }
 }
コード例 #5
0
ファイル: JoinTest.cs プロジェクト: 2gis/nuclear-join
        private static void Test(Func<IQueryable<Order>, IQueryable<OrderPosition>, IQueryable<long>> func, IResolveConstraint expected)
        {
            using (var source1 = CreateOrdersDbConnection())
            using (var source2 = CreateOrderPositionsDbConnection())
            {
                var orders = source1.GetTable<Order>().Where(x => x.Id < 1000);
                var positions = source2.GetTable<OrderPosition>().Where(x => x.OrderId < 2000);
                var join = func.Invoke(orders, positions);

                Assert.That(() => join.ToArray(), expected);
            }
        }
コード例 #6
0
ファイル: CalamariResult.cs プロジェクト: bjewell52/Calamari
        public void AssertServiceMessage(string name, IResolveConstraint resolveConstraint = null, Dictionary<string, object> properties = null, string message = "", params object[] args)
        {

            switch (name)
            {
                case ServiceMessageNames.CalamariFoundPackage.Name:
                    Assert.That(captured.CalamariFoundPackage, resolveConstraint, message, args);
                    break;
                case ServiceMessageNames.FoundPackage.Name:
                    Assert.That(captured.FoundPackage, Is.Not.Null);
                    if (properties != null)
                    {
                        Assert.That(resolveConstraint, Is.Not.Null, "Resolve constraint was not provided");
                        foreach (var property in properties)
                        {
                            var fp = JObject.FromObject(captured.FoundPackage);
                            string value;
                            if (property.Key.Contains("."))
                            {
                                var props = property.Key.Split(new[] {'.'}, StringSplitOptions.RemoveEmptyEntries);
                                value = fp[props[0]][props[1]].ToString();
                            }
                            else
                            {
                                value = fp[property.Key].ToString();
                            }
                            AssertServiceMessageValue(property.Key, property.Value, value, resolveConstraint);
                        }
                    }
                    break;
                case ServiceMessageNames.PackageDeltaVerification.Name:
                    Assert.That(captured.DeltaVerification, Is.Not.Null);
                    if (properties != null)
                    {
                        foreach (var property in properties)
                        {
                            var dv = JObject.FromObject(captured.DeltaVerification);
                            string value;
                            if (property.Key.Contains("."))
                            {
                                var props = property.Key.Split(new[] {'.'}, StringSplitOptions.RemoveEmptyEntries);
                                value = dv[props[0]][props[1]].ToString();
                            }
                            else
                            {
                                value = dv[property.Key].ToString();
                            }
                            AssertServiceMessageValue(property.Key, property.Value, value, resolveConstraint);
                        }
                    }
                    break;
            }
        }
コード例 #7
0
ファイル: Assert.cs プロジェクト: LionFree/Cush
 /// <summary>
 ///     Apply a constraint to a referenced boolean, succeeding if the constraint
 ///     is satisfied and throwing an assertion exception on failure.
 /// </summary>
 /// <param name="actual">The actual value to test</param>
 /// <param name="constraint">A Constraint to be applied</param>
 internal static void That(ref bool actual, IResolveConstraint constraint)
 {
     That(ref actual, constraint.Resolve(), null, null);
 }
コード例 #8
0
 /// <summary>
 ///     Apply a constraint to an actual value, succeeding if the constraint
 ///     is satisfied and throwing an assertion exception on failure.
 ///     Used as a synonym for That in rare cases where a private setter
 ///     causes a Visual Basic compilation error.
 /// </summary>
 /// <param name="stepName">The Step Name to Allure report</param>
 /// <param name="actual">The actual value to test</param>
 /// <param name="expression">A Constraint to be applied</param>
 public bool ByVal(string stepName, object actual, IResolveConstraint expression, params object[] stepParams)
 {
     return(VerifyRunner(stepName, () => Assert.That(actual, expression, null, null), Status.failed, stepParams));
 }
コード例 #9
0
 /// <summary>
 /// Apply a constraint to a referenced value, succeeding if the constraint
 /// is satisfied and throwing an InconclusiveException on failure.
 /// </summary>
 /// <param name="constraint">A Constraint to be applied</param>
 /// <param name="actual">The actual value to test</param>
 /// <param name="message">The message that will be displayed on failure</param>
 static public void That(ref bool actual, IResolveConstraint constraint, string message)
 {
     Assume.That(ref actual, constraint.Resolve(), message, null);
 }
コード例 #10
0
 static void AssertServiceMessageValue(string property, object expected, string actual, IResolveConstraint resolveConstraint)
 {
     Assert.That(actual, Is.Not.Null);
     Assert.That(actual, Is.Not.Empty);
     Assert.That(actual.Equals(expected), resolveConstraint,
         "Expected property '{0}' to have value '{1}' but was actually '{2}'", property,
         expected, actual);
 }
コード例 #11
0
ファイル: Assert.cs プロジェクト: imgen/Andr.Unit
        /// <summary>
        /// Apply a constraint to an actual value, succeeding if the constraint
        /// is satisfied and throwing an assertion exception on failure.
        /// </summary>
        /// <param name="expression">A Constraint to be applied</param>
        /// <param name="actual">The actual value to test</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 That(object actual, IResolveConstraint expression, string message, params object[] args)
        {
            Constraint constraint = expression.Resolve();

            Assert.IncrementAssertCount();
            if (!constraint.Matches(actual))
            {
                MessageWriter writer = new TextMessageWriter(message, args);
                constraint.WriteMessageTo(writer);
                throw new AssertionException(writer.ToString());
            }
        }
コード例 #12
0
 /// <summary>
 /// Apply a constraint to an actual value, succeeding if the constraint
 /// is satisfied and throwing an InconclusiveException on failure.
 /// </summary>
 /// <param name="expression">A Constraint expression to be applied</param>
 /// <param name="actual">The actual value to test</param>
 static public void That(object actual, IResolveConstraint expression)
 {
     Assume.That(actual, expression, null, null);
 }
コード例 #13
0
 public static void Should(this TestDelegate invocation, IResolveConstraint constraint, string message)
 {
     Assert.That(invocation, constraint, message);
 }
コード例 #14
0
 /// <summary>
 /// Apply a constraint to an actual value, succeeding if the constraint
 /// is satisfied and throwing an assertion exception on failure.
 /// </summary>
 /// <param name="expr">A Constraint expression to be applied</param>
 /// <param name="del">An ActualValueDelegate returning the value to be tested</param>
 public void Expect(ActualValueDelegate del, IResolveConstraint expr)
 {
     Assert.That(del, expr.Resolve(), null, null);
 }
コード例 #15
0
 /// <summary>
 /// Apply a constraint to a referenced value, succeeding if the constraint
 /// is satisfied and throwing an assertion exception on failure.
 /// </summary>
 /// <param name="constraint">A Constraint to be applied</param>
 /// <param name="actual">The actual value to test</param>
 /// <param name="message">The message that will be displayed on failure</param>
 public void Expect(ref bool actual, IResolveConstraint constraint, string message)
 {
     Assert.That(ref actual, constraint.Resolve(), message, null);
 }
コード例 #16
0
 /// <summary>
 /// Apply a constraint to a referenced boolean, succeeding if the constraint
 /// is satisfied and throwing an assertion exception on failure.
 /// </summary>
 /// <param name="constraint">A Constraint to be applied</param>
 /// <param name="actual">The actual value to test</param>
 public void Expect(ref bool actual, IResolveConstraint constraint)
 {
     Assert.That(ref actual, constraint.Resolve(), null, null);
 }
コード例 #17
0
 public static async Task <Exception> ThrowsAsync(IResolveConstraint expression, AsyncTestDelegate code)
 {
     return(await ThrowsAsync(expression, code, string.Empty, null));
 }
コード例 #18
0
 public static void If <T>(ActualValueDelegate <T> actual, IResolveConstraint constraint)
 {
     constraint.Resolve().ApplyTo(actual);
 }
コード例 #19
0
 /// <summary>
 /// Applies an <see cref="IResolveConstraint"/> that, <b>if satisfied</b>, will throw an <see cref="IgnoreException"/>.
 /// </summary>
 /// <remarks>
 /// This is the more idiomatic use of the word "ignore", but actually inverts (i.e. <see cref="NotConstraint"/>)
 /// the provided <paramref name="constraint"/>.
 /// </remarks>
 /// <param name="actual">the actual <typeparamref name="T"/> value</param>
 /// <param name="constraint">the <see cref="IResolveConstraint"/> applied to <paramref name="actual"/></param>
 /// <typeparam name="T">the type of <paramref name="actual"/></typeparam>
 public static void If <T>(T actual, IResolveConstraint constraint)
 {
     Unless(actual, new NotConstraint(constraint.Resolve()));
 }
コード例 #20
0
 public void GetDownloadLink_InvalidNode_Throws(INode node, IResolveConstraint constraint)
 {
     Assert.That(
         () => this.Client.GetDownloadLink(node),
         constraint);
 }
コード例 #21
0
 public static Transmission AddPositionConstraint(this Transmission transmission, IResolveConstraint constraint) {
     return transmission.AddPropertyContraint(new ReusableConstraint(constraint), Utils.NameOf(() => transmission.Position));
 }
コード例 #22
0
 /// <summary>
 /// Apply a constraint to an actual value, succeeding if the constraint
 /// is satisfied and throwing an assertion exception on failure.
 /// </summary>
 /// <param name="expr">A Constraint expression to be applied</param>
 /// <param name="del">An ActualValueDelegate returning the value to be tested</param>
 /// <param name="message">The message that will be displayed on failure</param>
 public void Expect(ActualValueDelegate del, IResolveConstraint expr, string message)
 {
     Assert.That(del, expr.Resolve(), message, null);
 }
コード例 #23
0
ファイル: KoanAssert.cs プロジェクト: psrodriguez/CIAPI.CS
 public static void That(object actual, IResolveConstraint expression)
 {
     That(actual, expression, string.Empty);
 }
コード例 #24
0
 /// <summary>
 /// Apply a constraint to an actual value, succeeding if the constraint
 /// is satisfied and throwing an assertion exception on failure.
 /// </summary>
 /// <param name="del">An ActualValueDelegate returning the value to be tested</param>
 /// <param name="expr">A Constraint expression to be applied</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>
 public void Expect(ActualValueDelegate del, IResolveConstraint expr, string message, params object[] args)
 {
     Assert.That(del, expr, message, args);
 }
コード例 #25
0
ファイル: Assert.cs プロジェクト: imgen/Andr.Unit
 /// <summary>
 /// Apply a constraint to an actual value, succeeding if the constraint
 /// is satisfied and throwing an assertion exception on failure.
 /// </summary>
 /// <param name="expression">A Constraint to be applied</param>
 /// <param name="actual">The actual value to test</param>
 static public void That(object actual, IResolveConstraint expression)
 {
     Assert.That(actual, expression, null, null);
 }
コード例 #26
0
 /// <summary>
 /// Apply a constraint to a referenced value, succeeding if the constraint
 /// is satisfied and throwing an assertion exception on failure.
 /// </summary>
 /// <param name="actual">The actual value to test</param>
 /// <param name="expression">A Constraint to be applied</param>
 public void Expect <T>(ref T actual, IResolveConstraint expression)
 {
     Assert.That(ref actual, expression, null, null);
 }
コード例 #27
0
ファイル: UseTests.cs プロジェクト: ben-biddington/Bang
 private void Then_error(IResolveConstraint matchesThis)
 {
     Assert.That(_result.Error.Trim(), matchesThis);
 }
コード例 #28
0
 /// <summary>
 /// Apply a constraint to a referenced value, succeeding if the constraint
 /// is satisfied and throwing an assertion exception on failure.
 /// </summary>
 /// <param name="actual">The actual value to test</param>
 /// <param name="expression">A Constraint to be applied</param>
 /// <param name="message">The message that will be displayed on failure</param>
 public void Expect <T>(ref T actual, IResolveConstraint expression, string message)
 {
     Assert.That(ref actual, expression, message, null);
 }
コード例 #29
0
		public static void WithBody(this RequestHandler handler, IResolveConstraint constraint)
		{
			Assert.That(handler.GetBody(), constraint.Resolve());
		}
コード例 #30
0
 /// <summary>
 /// Asserts that the code represented by a delegate throws an exception
 /// that satisfies the constraint provided.
 /// </summary>
 /// <param name="code">A TestDelegate to be executed</param>
 /// <param name="constraint">A ThrowsConstraint used in the test</param>
 public void Expect(TestDelegate code, IResolveConstraint constraint)
 {
     Assert.That((object)code, constraint);
 }
コード例 #31
0
 /// <summary>
 ///     Asserts that the code represented by a delegate throws an exception
 ///     that satisfies the constraint provided.
 /// </summary>
 /// <param name="stepName">The Step Name to Allure report</param>
 /// <param name="code">A TestDelegate to be executed</param>
 /// <param name="constraint">A ThrowsConstraint used in the test</param>
 /// <param name="getExceptionMessage">A function to build the message included with the Exception</param>
 public bool That(string stepName, TestDelegate code, IResolveConstraint constraint,
                  Func <string> getExceptionMessage, params object[] stepParams)
 {
     return(VerifyRunner(stepName, () => Assert.That((object)code, constraint, getExceptionMessage),
                         Status.failed, stepParams));
 }
コード例 #32
0
        //private Assertions assert = new Assertions();
        //public virtual Assertions Assert
        //{
        //    get { return assert; }
        //}
        #endregion

        #region Expect

        #region Object

        /// <summary>
        /// Apply a constraint to an actual value, succeeding if the constraint
        /// is satisfied and throwing an assertion exception on failure. Works
        /// identically to Assert.That.
        /// </summary>
        /// <param name="actual">The actual value to test</param>
        /// <param name="expression">A Constraint to be applied</param>
        public void Expect(object actual, IResolveConstraint expression)
        {
            Assert.That(actual, expression, null, null);
        }
コード例 #33
0
 /// <summary>
 ///     Apply a constraint to an actual value, succeeding if the constraint
 ///     is satisfied and throwing an assertion exception on failure.
 ///     Used as a synonym for That in rare cases where a private setter
 ///     causes a Visual Basic compilation error.
 /// </summary>
 /// <remarks>
 ///     This method is provided for use by VB developers needing to test
 ///     the value of properties with private setters.
 /// </remarks>
 /// <param name="stepName">The Step Name to Allure report</param>
 /// <param name="actual">The actual value to test</param>
 /// <param name="expression">A Constraint expression to be applied</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>
 public bool ByVal(string stepName, object actual, IResolveConstraint expression, string message,
                   params object[] args)
 {
     return(VerifyRunner(stepName, () => Assert.That(actual, expression, message, args), Status.failed));
 }
コード例 #34
0
 /// <summary>
 /// Apply a constraint to an actual value, succeeding if the constraint
 /// is satisfied and throwing an assertion exception on failure. Works
 /// identically to Assert.That.
 /// </summary>
 /// <param name="actual">The actual value to test</param>
 /// <param name="expression">A Constraint to be applied</param>
 /// <param name="message">The message to be displayed in case of failure</param>
 public void Expect(object actual, IResolveConstraint expression, string message)
 {
     Assert.That(actual, expression, message, null);
 }
コード例 #35
0
 /// <summary>
 /// Construct a ReusableConstraint
 /// </summary>
 /// <param name="c">The constraint or expression to be reused</param>
 public ReusableConstraint(IResolveConstraint c)
 {
     this.constraint = c.Resolve();
 }
コード例 #36
0
 /// <summary>
 /// Apply a constraint to an actual value, succeeding if the constraint
 /// is satisfied and throwing an assertion exception on failure. Works
 /// identically to Assert.That.
 /// </summary>
 /// <param name="actual">The actual value to test</param>
 /// <param name="expression">A Constraint to be applied</param>
 /// <param name="message">The message to be displayed in case of failure</param>
 /// <param name="args">Arguments to use in formatting the message</param>
 public void Expect(object actual, IResolveConstraint expression, string message, params object[] args)
 {
     Assert.That(actual, expression, message, args);
 }
コード例 #37
0
        /// <summary>
        /// This operator creates a constraint that is satisfied if the
        /// argument constraint is not satisfied.
        /// </summary>
        public static Constraint operator !(Constraint constraint)
        {
            IResolveConstraint r = (IResolveConstraint)constraint;

            return(new NotConstraint(r.Resolve()));
        }
コード例 #38
0
        public async Task SetSecretWithExtendedProps()
        {
            string             secretName = Recording.GenerateId();
            IResolveConstraint createdUpdatedConstraint = Is.EqualTo(DateTimeOffset.FromUnixTimeSeconds(1565114301));

            KeyVaultSecret setResult = null;

            try
            {
                var            exp = new DateTimeOffset(new DateTime(637027248120000000, DateTimeKind.Utc));
                DateTimeOffset nbf = exp.AddDays(-30);

                var secret = new KeyVaultSecret(secretName, "CrudWithExtendedPropsValue1")
                {
                    Properties =
                    {
                        ContentType = "password",
                        NotBefore   = nbf,
                        ExpiresOn   = exp,
                        Tags        =
                        {
                            { "tag1", "value1" },
                            { "tag2", "value2" }
                        },
                    },
                };

                setResult = await Client.SetSecretAsync(secret);

                if (Mode != RecordedTestMode.Playback)
                {
                    DateTimeOffset now = DateTimeOffset.UtcNow;
                    createdUpdatedConstraint = Is.InRange(now.AddMinutes(-5), now.AddMinutes(5));
                }

                RegisterForCleanup(secret.Name, delete: false);

                Assert.IsNotEmpty(setResult.Properties.Version);
                Assert.AreEqual("password", setResult.Properties.ContentType);
                Assert.AreEqual(nbf, setResult.Properties.NotBefore);
                Assert.AreEqual(exp, setResult.Properties.ExpiresOn);
                Assert.AreEqual(2, setResult.Properties.Tags.Count);
                Assert.AreEqual("value1", setResult.Properties.Tags["tag1"]);
                Assert.AreEqual("value2", setResult.Properties.Tags["tag2"]);
                Assert.AreEqual(secretName, setResult.Name);
                Assert.AreEqual("CrudWithExtendedPropsValue1", setResult.Value);
                Assert.AreEqual(VaultUri, setResult.Properties.VaultUri);
                Assert.AreEqual("Recoverable+Purgeable", setResult.Properties.RecoveryLevel);
                Assert.That(setResult.Properties.CreatedOn, createdUpdatedConstraint);
                Assert.That(setResult.Properties.UpdatedOn, createdUpdatedConstraint);

                KeyVaultSecret getResult = await Client.GetSecretAsync(secretName);

                AssertSecretsEqual(setResult, getResult);
            }
            finally
            {
                DeleteSecretOperation deleteOperation = await Client.StartDeleteSecretAsync(secretName);

                DeletedSecret deleteResult = deleteOperation.Value;

                AssertSecretPropertiesEqual(setResult.Properties, deleteResult.Properties);
            }
        }
コード例 #39
0
 public static void Should(this object actual, IResolveConstraint constraint, string message)
 {
     Assert.That(actual, constraint, message);
 }
コード例 #40
0
 public void Move_InvalidParameters_Throws(INode node, INode destinationParentNode, IResolveConstraint constraint)
 {
     Assert.That(
         () => this.Client.Move(node, destinationParentNode),
         constraint);
 }
コード例 #41
0
 public static void Should(this object actual, IResolveConstraint constraint)
 {
     Assert.That(actual, constraint);
 }
コード例 #42
0
 public void OnGridTest(Cell otherCell, IResolveConstraint expectation)
 {
     var cell = new Cell(3, 4, true);
     Assert.That(cell.IsNextTo(otherCell), expectation);
 }
コード例 #43
0
 /// <summary>
 /// Returns the constraint provided as an argument - used to allow custom
 /// custom constraints to easily participate in the syntax.
 /// </summary>
 public Constraint Matches(IResolveConstraint constraint)
 {
     return(this.Append((Constraint)constraint.Resolve()));
 }
コード例 #44
0
 /// <summary>
 /// Asserts that the code represented by a delegate throws an exception
 /// that satisfies the constraint provided.
 /// </summary>
 /// <param name="code">A TestDelegate to be executed</param>
 /// <param name="constraint">A ThrowsConstraint used in the test</param>
 static public void That(TestDelegate code, IResolveConstraint constraint)
 {
     Assume.That((object)code, constraint);
 }
コード例 #45
0
 public void CreateFolder_InvalidParameters_Throws(string name, INode parentNode, IResolveConstraint constraint)
 {
     Assert.That(
         () => this.Client.CreateFolder(name, parentNode),
         constraint);
 }
コード例 #46
0
ファイル: Assert.Exceptions.cs プロジェクト: yunmiha/TizenFX
 /// <summary>
 /// Verifies that a delegate throws a particular exception when called.
 /// </summary>
 /// <param name="expression">A constraint to be satisfied by the exception</param>
 /// <param name="code">A TestSnippet delegate</param>
 public static Exception Throws(IResolveConstraint expression, TestDelegate code)
 {
     return(Throws(expression, code, string.Empty, null));
 }
コード例 #47
0
 public static void Should(this object actual, IResolveConstraint expression)
 {
     Assert.That(actual, expression);
 }
コード例 #48
0
        /// <summary>
        /// This operator creates a constraint that is satisfied if the
        /// argument constraint is not satisfied.
        /// </summary>
        public static Constraint operator !(Constraint constraint)
        {
            IResolveConstraint r = constraint as IResolveConstraint;

            return(new NotConstraint(r == null ? new NullConstraint() : r.Resolve()));
        }
コード例 #49
0
ファイル: Assert.cs プロジェクト: imgen/Andr.Unit
 /// <summary>
 /// Apply a constraint to an actual value, succeeding if the constraint
 /// is satisfied and throwing an assertion exception on failure.
 /// </summary>
 /// <param name="expression">A Constraint to be applied</param>
 /// <param name="actual">The actual value to test</param>
 /// <param name="message">The message that will be displayed on failure</param>
 static public void That(object actual, IResolveConstraint expression, string message)
 {
     Assert.That(actual, expression, message, null);
 }
コード例 #50
0
 public NodeForTypeConstraint(Type type, IResolveConstraint constraint)
 {
     this.type = type;
     this.constraint = constraint.Resolve();
 }
コード例 #51
0
 /// <summary>
 /// Construct a ReusableConstraint from a constraint expression
 /// </summary>
 /// <param name="c">The expression to be resolved and reused</param>
 public ReusableConstraint(IResolveConstraint c)
 {
     this.constraint = c.Resolve();
 }
コード例 #52
0
 /// <summary>
 ///     Apply a constraint to an actual value, succeeding if the constraint
 ///     is satisfied and throwing an assertion exception on failure.
 /// </summary>
 /// <param name="stepName">The Step Name to Allure report</param>
 /// <typeparam name="TActual">The Type being compared.</typeparam>
 /// <param name="del">An ActualValueDelegate returning the value to be tested</param>
 /// <param name="expr">A Constraint expression to be applied</param>
 public bool That <TActual>(string stepName, ActualValueDelegate <TActual> del, IResolveConstraint expr,
                            params object[] stepParams)
 {
     return(VerifyRunner(stepName, () => Assert.That(del, expr.Resolve(), null, null), Status.failed,
                         stepParams));
 }
コード例 #53
0
ファイル: UseTests.cs プロジェクト: ben-biddington/Bang
 private void Then_message(IResolveConstraint matchesThis)
 {
     Assert.That(_result.Message.Trim(), matchesThis);
 }
コード例 #54
0
 /// <summary>
 ///     Apply a constraint to an actual value, succeeding if the constraint
 ///     is satisfied and throwing an assertion exception on failure.
 /// </summary>
 /// <param name="stepName">The Step Name to Allure report</param>
 /// <typeparam name="TActual">The Type being compared.</typeparam>
 /// <param name="del">An ActualValueDelegate returning the value to be tested</param>
 /// <param name="expr">A Constraint expression to be applied</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>
 public bool That <TActual>(string stepName, ActualValueDelegate <TActual> del, IResolveConstraint expr,
                            string message, params object[] args)
 {
     return(VerifyRunner(stepName, () =>
     {
         var constraint = expr.Resolve();
         TestExecutionContext.CurrentContext.IncrementAssertCount();
         var result = constraint.ApplyTo(del);
         if (!result.IsSuccess)
         {
             ReportFailure(result, message, args);
         }
     }, Status.failed));
 }
コード例 #55
0
 public void AssertOutputVariable(string name, IResolveConstraint resolveConstraint)
 {
     var variable = captured.OutputVariables.Get(name);
     Assert.That(variable, resolveConstraint);
 }
コード例 #56
0
 private static Constraint OperatorAndImplementation(IResolveConstraint left, IResolveConstraint right)
 {
     return new AndConstraint(left.Resolve(), right.Resolve());
 }
コード例 #57
0
 /// <summary>
 ///     Asserts that the code represented by a delegate throws an exception
 ///     that satisfies the constraint provided.
 /// </summary>
 /// <param name="stepName">The Step Name to Allure report</param>
 /// <param name="code">A TestDelegate to be executed</param>
 /// <param name="constraint">A ThrowsConstraint used in the test</param>
 public bool That(string stepName, TestDelegate code, IResolveConstraint constraint, params object[] stepParams)
 {
     return(VerifyRunner(stepName, () => Assert.That(code, constraint, null, null), Status.failed, stepParams));
 }
コード例 #58
0
ファイル: Assert.cs プロジェクト: LionFree/Cush
 /// <summary>
 ///     Apply a constraint to a referenced value, succeeding if the constraint
 ///     is satisfied and throwing an assertion exception on failure.
 /// </summary>
 /// <param name="actual">The actual value to test</param>
 /// <param name="constraint">A Constraint to be applied</param>
 /// <param name="message">The message that will be displayed on failure</param>
 internal static void That(ref bool actual, IResolveConstraint constraint, string message)
 {
     That(ref actual, constraint.Resolve(), message, null);
 }
コード例 #59
0
 /// <summary>
 /// Construct given a base constraint
 /// </summary>
 /// <param name="resolvable"></param>
 protected PrefixConstraint(IResolveConstraint resolvable) : base(resolvable)
 {
     if ( resolvable != null )
         this.baseConstraint = resolvable.Resolve();
 }
コード例 #60
0
 /// <summary>
 ///     Asserts that the code represented by a delegate throws an exception
 ///     that satisfies the constraint provided.
 /// </summary>
 /// <param name="stepName">The Step Name to Allure report</param>
 /// <param name="code">A TestDelegate to be executed</param>
 /// <param name="constraint">A ThrowsConstraint used in the test</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>
 public bool That(string stepName, TestDelegate code, IResolveConstraint constraint, string message,
                  params object[] args)
 {
     return(VerifyRunner(stepName, () => Assert.That((object)code, constraint, message, args), Status.failed));
 }