Exemple #1
0
 private static void AppendCallList(IEnumerable <IFakeObjectCall> calls, CallWriter callWriter, IOutputWriter writer)
 {
     using (writer.Indent())
     {
         callWriter.WriteCalls(calls, writer);
     }
 }
Exemple #2
0
 private static void AppendCallList(IEnumerable<IFakeObjectCall> calls, CallWriter callWriter, IOutputWriter writer)
 {
     using (writer.Indent())
     {
         callWriter.WriteCalls(calls, writer);
     }
 }
Exemple #3
0
        public FakeAsserter(IEnumerable<IFakeObjectCall> calls, CallWriter callWriter)
        {
            Guard.AgainstNull(calls, nameof(calls));
            Guard.AgainstNull(callWriter, nameof(callWriter));

            this.calls = calls;
            this.callWriter = callWriter;
        }
 public SequentialCallContext(CallWriter callWriter)
 {
     Guard.AgainstNull(callWriter, nameof(callWriter));
     this.callWriter = callWriter;
     this.fakeManagers = new HashSet<FakeManager>();
     this.assertedCalls = new List<AssertedCall>();
     this.currentSequenceNumber = -1;
 }
 public SequentialCallContext(CallWriter callWriter)
 {
     Guard.AgainstNull(callWriter, "callWriter");
     this.callWriter            = callWriter;
     this.fakeManagers          = new HashSet <FakeManager>();
     this.assertedCalls         = new List <AssertedCall>();
     this.currentSequenceNumber = -1;
 }
Exemple #6
0
        public FakeAsserter(IEnumerable <IFakeObjectCall> calls, CallWriter callWriter)
        {
            Guard.AgainstNull(calls, nameof(calls));
            Guard.AgainstNull(callWriter, nameof(callWriter));

            this.calls      = calls;
            this.callWriter = callWriter;
        }
Exemple #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OrderedFakeAsserter"/> class.
        /// </summary>
        /// <param name="calls">The calls.</param>
        /// <param name="callWriter">The call writer.</param>
        public OrderedFakeAsserter(IEnumerable <IFakeObjectCall> calls, CallWriter callWriter)
        {
            this.originalCallList = calls;
            this.calls            = new Queue <IFakeObjectCall>(calls);
            this.callWriter       = callWriter;

            this.assertedCalls = new List <AssertedCall>();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="OrderedFakeAsserter"/> class.
        /// </summary>
        /// <param name="calls">The calls.</param>
        /// <param name="callWriter">The call writer.</param>
        public OrderedFakeAsserter(IEnumerable<IFakeObjectCall> calls, CallWriter callWriter)
        {
            this.originalCallList = calls;
            this.calls = new Queue<IFakeObjectCall>(calls);
            this.callWriter = callWriter;

            this.assertedCalls = new List<AssertedCall>();
        }
Exemple #9
0
        public FakeAsserter(IEnumerable <ICompletedFakeObjectCall> calls, CallWriter callWriter, StringBuilderOutputWriter.Factory outputWriterFactory)
        {
            Guard.AgainstNull(calls, nameof(calls));
            Guard.AgainstNull(callWriter, nameof(callWriter));

            this.calls               = calls;
            this.callWriter          = callWriter;
            this.outputWriterFactory = outputWriterFactory;
        }
        public OrderedFakeAsserter(IEnumerable <IFakeObjectCall> calls, CallWriter callWriter)
        {
            Guard.AgainstNull(calls, "calls");
            Guard.AgainstNull(callWriter, "callWriter");

            this.originalCallList = calls;
            this.calls            = new Queue <IFakeObjectCall>(calls);
            this.callWriter       = callWriter;
        }
Exemple #11
0
 public SequentialCallContext(CallWriter callWriter, StringBuilderOutputWriter.Factory outputWriterFactory)
 {
     Guard.AgainstNull(callWriter, nameof(callWriter));
     this.callWriter            = callWriter;
     this.outputWriterFactory   = outputWriterFactory;
     this.fakeManagers          = new HashSet <FakeManager>();
     this.assertedCalls         = new List <AssertedCall>();
     this.currentSequenceNumber = -1;
 }
        public OrderedFakeAsserter(IEnumerable<IFakeObjectCall> calls, CallWriter callWriter)
        {
            Guard.AgainstNull(calls, "calls");
            Guard.AgainstNull(callWriter, "callWriter");

            this.originalCallList = calls;
            this.calls = new Queue<IFakeObjectCall>(calls);
            this.callWriter = callWriter;
        }
Exemple #13
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();
        }
Exemple #14
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());
        }
        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());
        }
        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());
        }
Exemple #17
0
 public FakeAsserter(IEnumerable <IFakeObjectCall> calls, CallWriter callWriter)
 {
     this.Calls      = calls;
     this.callWriter = callWriter;
 }
 public FakeAsserter(IEnumerable<IFakeObjectCall> calls, CallWriter callWriter)
 {
     this.Calls = calls;
     this.callWriter = callWriter;
 }
 public void Setup()
 {
     this.callWriter = A.Fake<CallWriter>();
 }
 public void SetUp()
 {
     this.calls = new List<IFakeObjectCall>();
     this.callWriter = A.Fake<CallWriter>();
 }
 public FakeAsserterTests()
 {
     this.calls = new List<IFakeObjectCall>();
     this.callWriter = A.Fake<CallWriter>();
 }