コード例 #1
0
        private static string generateMessage(Expectation expectation, object[] generatedEvents)
        {
            var sb = new StringBuilder();
            sb.AppendFormat("Expected {0}", expectation);
            sb.AppendLine();
            sb.AppendFormat("but the following {0} result(s) were found: ", generatedEvents.Length);
            sb.AppendLine();

            sb.Append(string.Join(Environment.NewLine, generatedEvents));

            return sb.ToString();
        }
コード例 #2
0
ファイル: SpecInfo.cs プロジェクト: heartysoft/dokimi
 public void ReportExpectation(Expectation expectation)
 {
     ReportExpectation(formatMessage(expectation));
 }
コード例 #3
0
ファイル: WhatHappens.cs プロジェクト: simoneb/Roger
 private void Arrange(Expectation expectation)
 {
     expectations.Add(expectation);
 }
コード例 #4
0
        private static void SetupMockServerRequest(MockServerClient mockServerClient, Expectation expectation, HttpRequest httpRequest, HttpResponse httpResponse)
        {
            var isSecure       = expectation.HttpRequest.IsSecure.HasValue && expectation.HttpRequest.IsSecure.Value;
            var unlimitedTimes = expectation.Times == null || expectation.Times.IsUnlimited;

            mockServerClient
            .When(httpRequest
                  .WithMethod(expectation.HttpRequest.Method)
                  .WithPath(expectation.HttpRequest.Path)
                  .WithQueryStringParameters(expectation.HttpRequest.Parameters.ToArray())
                  .WithBody(expectation.HttpRequest.Body)
                  .WithSecure(isSecure),
                  unlimitedTimes ? Times.Unlimited() : Times.Exactly(expectation.Times.Count))
            .Respond(httpResponse
                     .WithStatusCode(expectation.HttpResponse.StatusCode)
                     .WithHeaders(expectation.HttpResponse.Headers.ToArray())
                     .WithBody(expectation.HttpResponse.Body ?? string.Empty)
                     .WithDelay(GetTimeSpanDelay(expectation.HttpResponse.Delay)));
        }
コード例 #5
0
 public void Assert()
 {
     Expectation.Assert();
 }
コード例 #6
0
 /// <summary>
 /// Adds a comment for the expectation that is added to the error message if the expectation is not met.
 /// </summary>
 /// <param name="comment">The comment that is shown in the error message if this expectation is not met.
 /// You can describe here why this expectation has to be met.</param>
 public IVerifyableExpectation Comment(string comment)
 {
     return(Expectation.Comment(comment));
 }
コード例 #7
0
        static void assertMatchesBase <T, TMatch, TGenerex, TGenerexMatch>(GenerexBase <T, TMatch, TGenerex, TGenerexMatch> generex, T[] input, Expectation isMatch, Expectation isMatchAt1, Expectation isMatchUpTo1, Expectation isMatchExact, Expectation isMatchReverse, object[] match, object[] matchExact, object[] matchReverse, int matches, int matchesReverse)
            where TGenerex : GenerexBase <T, TMatch, TGenerex, TGenerexMatch>
            where TGenerexMatch : GenerexMatch <T>
        {
            // Test 1: generex.Method(input)
            assertExpectation(isMatch, () => generex.IsMatch(input));
            assertExpectation(isMatchAt1, () => generex.IsMatchAt(input, 1));
            assertExpectation(isMatchUpTo1, () => generex.IsMatchUpTo(input, input.Length - 1));
            assertExpectation(isMatchExact, () => generex.IsMatchExact(input));
            assertExpectation(isMatchReverse, () => generex.IsMatchReverse(input));
            assertIntOrThrow(matches, () => generex.Matches(input).Count());
            assertIntOrThrow(matchesReverse, () => generex.MatchesReverse(input).Count());

            // Test 2: input.Method(generex)
            assertExpectation(isMatch, () => input.IsMatch(generex));
            assertExpectation(isMatchAt1, () => input.IsMatchAt(generex, 1));
            assertExpectation(isMatchUpTo1, () => input.IsMatchUpTo(generex, input.Length - 1));
            assertExpectation(isMatchExact, () => input.IsMatchExact(generex));
            assertExpectation(isMatchReverse, () => input.IsMatchReverse(generex));
            assertIntOrThrow(matches, () => input.Matches(generex).Count());
            assertIntOrThrow(matchesReverse, () => input.MatchesReverse(generex).Count());
        }
コード例 #8
0
 /// <summary>
 /// Review the expressions associated to this expectation
 /// </summary>
 /// <param name="expectation"></param>
 private void Review(Expectation expectation)
 {
     expectation.Value = ReviewExpression(expectation.Step, expectation.Value);
 }
コード例 #9
0
        public static void AssertMatches <T, TGenerex, TGenerexMatch>(GenerexNoResultBase <T, TGenerex, TGenerexMatch> generex, T[] input, Expectation isMatch, Expectation isMatchAt1, Expectation isMatchUpTo1, Expectation isMatchExact, Expectation isMatchReverse, object[] match, object[] matchExact, object[] matchReverse, int matches, int matchesReverse)
            where TGenerex : GenerexNoResultBase <T, TGenerex, TGenerexMatch>
            where TGenerexMatch : GenerexMatch <T>
        {
            assertMatchesBase(generex, input, isMatch, isMatchAt1, isMatchUpTo1, isMatchExact, isMatchReverse, match, matchExact, matchReverse, matches, matchesReverse);

            // Test 1: generex.Method(input)
            assertMatch <T, TGenerexMatch>(match, () => generex.Match(input));
            assertMatch <T, TGenerexMatch>(matchExact, () => generex.MatchExact(input));
            assertMatch <T, TGenerexMatch>(matchReverse, () => generex.MatchReverse(input));

            // Test 2: input.Method(generex)
            assertMatch <T, TGenerexMatch>(match, () => input.Match(generex));
            assertMatch <T, TGenerexMatch>(matchExact, () => input.MatchExact(generex));
            assertMatch <T, TGenerexMatch>(matchReverse, () => input.MatchReverse(generex));
        }
コード例 #10
0
        public static void AssertMatches <T, TResult, TGenerex, TGenerexMatch>(GenerexWithResultBase <T, TResult, TGenerex, TGenerexMatch> generex, T[] input, Expectation isMatch, Expectation isMatchAt1, Expectation isMatchUpTo1, Expectation isMatchExact, Expectation isMatchReverse, object[] match, object[] matchExact, object[] matchReverse, int matches, int matchesReverse)
            where TGenerex : GenerexWithResultBase <T, TResult, TGenerex, TGenerexMatch>
            where TGenerexMatch : GenerexMatch <T, TResult>
        {
            assertMatchesBase(generex, input, isMatch, isMatchAt1, isMatchUpTo1, isMatchExact, isMatchReverse, match, matchExact, matchReverse, matches, matchesReverse);

            assertMatch <T, TResult, TGenerexMatch>(match, () => generex.Match(input), () => generex.RawMatch(input));
            assertMatch <T, TResult, TGenerexMatch>(matchExact, () => generex.MatchExact(input), () => generex.RawMatchExact(input));
            assertMatch <T, TResult, TGenerexMatch>(matchReverse, () => generex.MatchReverse(input), () => generex.RawMatchReverse(input));
        }
コード例 #11
0
 public static void AssertMatches <TGenerex, TResult, TGenerexMatch>(GenerexWithResultBase <char, TResult, TGenerex, TGenerexMatch> generex, string input, Expectation isMatch, Expectation isMatchAt1, Expectation isMatchUpTo1, Expectation isMatchExact, Expectation isMatchReverse, object[] match, object[] matchExact, object[] matchReverse, int matches, int matchesReverse)
     where TGenerex : GenerexWithResultBase <char, TResult, TGenerex, TGenerexMatch>
     where TGenerexMatch : GenerexMatch <char, TResult>
 {
     AssertMatches(generex, input.ToCharArray(), isMatch, isMatchAt1, isMatchUpTo1, isMatchExact, isMatchReverse, match, matchExact, matchReverse, matches, matchesReverse);
 }
コード例 #12
0
        private Expectation ParseRecursiveExpectation(IMockExpectationContainer container, Expectation current, Type type)
        {
            var typeInstance  = IdentifyReturnType(type);
            var typeContainer = typeInstance as IMockExpectationContainer;

            if (typeContainer == null)
            {
                return(current);
            }

            var genericType     = typeof(ExpectMethod <>);
            var replaceType     = genericType.MakeGenericType(type);
            var replaceInstance = Activator.CreateInstance(replaceType) as Expectation;

            replaceInstance.SetReturnValue(typeInstance);
            container.RemoveExpectation(current);
            container.AddExpectation(replaceInstance);

            typeContainer.MarkForExpectation(current);
            return(replaceInstance);
        }
コード例 #13
0
 public ExpectationFailedException(Expectation expectation, object[] generatedEvents)
     : base(generateMessage(expectation, generatedEvents))
 {
 }
コード例 #14
0
ファイル: SpecInfo.cs プロジェクト: heartysoft/dokimi
 public SpecInfo ReportExpectationFail(Expectation expectation, Exception e)
 {
     return ReportExpectationFail(formatMessage(expectation), e);
 }
コード例 #15
0
 protected SpecifyActionBase(Expectation expectation)
 {
     this.expectation = expectation;
 }
コード例 #16
0
ファイル: SpecInfo.cs プロジェクト: heartysoft/dokimi
 public SpecInfo ReportExpectationPass(Expectation expectation)
 {
     return ReportExpectationPass(formatMessage(expectation));
 }
コード例 #17
0
 public SpecifyAction(Expectation expectation)
     : base(expectation)
 {
 }
コード例 #18
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="id"></param>
 public Expect(Expectation expectation)
     : base(expectation.Expression, expectation)
 {
     Expectation = expectation;
     State = EventState.Active;
 }
コード例 #19
0
ファイル: ExpectExpression.cs プロジェクト: tmont/ntestify
 internal ExpectExpression(Expectation <T> expectation)
 {
     this.expectation = expectation;
 }