Esempio n. 1
0
        private static string CreateExceptionMessage(
            IEnumerable<IFakeObjectCall> calls, CallWriter callWriter, string callDescription, string repeatDescription, int matchedCallCount)
        {
            var writer = new StringBuilderOutputWriter();
            writer.WriteLine();

            using (writer.Indent())
            {
                AppendCallDescription(callDescription, writer);
                AppendExpectation(calls, repeatDescription, matchedCallCount, writer);
                AppendCallList(calls, callWriter, writer);
                writer.WriteLine();
            }

            return writer.Builder.ToString();
        }
Esempio n. 2
0
 private void WriteActualValueTo(StringBuilderOutputWriter builder)
 {
     builder.Write(
         "When called with the following arguments the method did not throw the appropriate exception:");
     builder.WriteLine();
     this.state.WriteFailingCallsDescriptions(builder);
 }
Esempio n. 3
0
        private string CreateExceptionMessage(string callDescription, string repeatDescription, int repeat)
        {
            var outputWriter = new StringBuilderOutputWriter();

            outputWriter.WriteLine();

            using (outputWriter.Indent())
            {
                AppendCallDescription(callDescription, outputWriter);
                this.AppendExpectation(repeatDescription, repeat, outputWriter);
                this.AppendCallList(outputWriter);
                outputWriter.WriteLine();
            }

            return(outputWriter.Builder.ToString());
        }
Esempio n. 4
0
        private static string CreateExceptionMessage(
            IEnumerable <IFakeObjectCall> calls, CallWriter callWriter, string callDescription, string repeatDescription, int matchedCallCount)
        {
            var writer = new StringBuilderOutputWriter();

            writer.WriteLine();

            using (writer.Indent())
            {
                AppendCallDescription(callDescription, writer);
                AppendExpectation(calls, repeatDescription, matchedCallCount, writer);
                AppendCallList(calls, callWriter, writer);
                writer.WriteLine();
            }

            return(writer.Builder.ToString());
        }
Esempio n. 5
0
 public void WriteFailingCallsDescriptions(StringBuilderOutputWriter builder)
 {
     using (builder.Indent())
     {
         foreach (var call in this.unguardedCalls)
         {
             call.WriteFailingCallDescription(builder);
             builder.WriteLine();
         }
     }
 }
        private static void ThrowExceptionWhenAssertionFailed(
            List<AssertedCall> assertedCalls, CallWriter callWriter, IEnumerable<IFakeObjectCall> originalCallList)
        {
            var message = new StringBuilderOutputWriter();

            message.WriteLine();
            message.WriteLine();

            using (message.Indent())
            {
                message.Write("Assertion failed for the following calls:");
                message.WriteLine();

                using (message.Indent())
                {
                    foreach (var call in assertedCalls)
                    {
                        message.Write("'");
                        message.Write(call.CallDescription);
                        message.Write("' ");
                        message.Write("repeated ");
                        message.Write(call.RepeatDescription);
                        message.WriteLine();
                    }
                }

                message.Write("The calls where found but not in the correct order among the calls:");
                message.WriteLine();

                using (message.Indent())
                {
                    callWriter.WriteCalls(originalCallList, message);
                }
            }

            throw new ExpectationException(message.Builder.ToString());
        }
Esempio n. 7
0
        private static void ThrowExceptionWhenAssertionFailed(
            List <AssertedCall> assertedCalls, CallWriter callWriter, List <ICompletedFakeObjectCall> originalCallList)
        {
            var message = new StringBuilderOutputWriter();

            message.WriteLine();
            message.WriteLine();

            using (message.Indent())
            {
                message.Write("Assertion failed for the following calls:");
                message.WriteLine();

                using (message.Indent())
                {
                    foreach (var call in assertedCalls)
                    {
                        message.Write("'");
                        message.Write(call.CallDescription);
                        message.Write("' ");
                        message.Write("repeated ");
                        message.Write(call.RepeatDescription);
                        message.WriteLine();
                    }
                }

                message.Write("The calls where found but not in the correct order among the calls:");
                message.WriteLine();

                using (message.Indent())
                {
                    callWriter.WriteCalls(originalCallList, message);
                }
            }

            throw new ExpectationException(message.Builder.ToString());
        }
Esempio n. 8
0
            public void BeNullGuarded()
            {
                var matches = this.Matches(this.call);
                if (matches)
                {
                    return;
                }

                var builder = new StringBuilderOutputWriter();
                this.WriteDescriptionTo(builder);
                builder.WriteLine();
                this.WriteActualValueTo(builder);
                var reason = builder.Builder.ToString();
                Execute.Assertion.FailWith(reason);
            }
Esempio n. 9
0
            public void BeNullGuarded()
            {
                var matches = this.Matches(this.call);

                if (matches)
                {
                    return;
                }

                var builder = new StringBuilderOutputWriter();

                this.WriteDescriptionTo(builder);
                builder.WriteLine();
                this.WriteActualValueTo(builder);
                var reason = builder.Builder.ToString();

                Execute.Assertion.FailWith(reason);
            }
Esempio n. 10
0
        private string CreateExceptionMessage(string callDescription, string repeatDescription, int repeat)
        {
            var outputWriter = new StringBuilderOutputWriter();
            outputWriter.WriteLine();

            using (outputWriter.Indent())
            {
                AppendCallDescription(callDescription, outputWriter);
                this.AppendExpectation(repeatDescription, repeat, outputWriter);
                this.AppendCallList(outputWriter);
                outputWriter.WriteLine();
            }

            return outputWriter.Builder.ToString();
        }
Esempio n. 11
0
 private void WriteActualValueTo(StringBuilderOutputWriter builder)
 {
     builder.Write(
         "When called with the following arguments the method did not throw the appropriate exception:");
     builder.WriteLine();
     this.state.WriteFailingCallsDescriptions(builder);
 }
Esempio n. 12
0
 public void WriteFailingCallsDescriptions(StringBuilderOutputWriter builder)
 {
     using (builder.Indent())
     {
         foreach (var call in this.unguardedCalls)
         {
             call.WriteFailingCallDescription(builder);
             builder.WriteLine();
         }
     }
 }