public void TestMethod3()
        {
            //Arrange
            var stubLogger = new StubILogger {ShouldLog = () => true};
            var sut = new ClassA();
            var observer = new StubObserver();
            stubLogger.InstanceObserver = observer;

            //Act
            sut.GetName(stubLogger);

            var calls = observer.GetCalls();
        }
        public void GetEventName_Test_Fakes()
        {
            //arrange
            var stubLogger = new StubILogger { IsLoggerEnabledGet = () => true };
            var diagonizeStub = new DiagonizeStubs();
            var observer = new StubObserver();
            stubLogger.InstanceObserver = observer;

            //act
            diagonizeStub.GetEventName(stubLogger);
            var calls = observer.GetCalls();

               //assert
            Assert.IsNotNull(calls);
            Assert.AreEqual(2, calls.Length);
        }
        public void Test_Stub_Observer_Contains_Valid_Argument_And_Method_Info()
        {
            // Arrange
            var mock = new StubILogWriter();
            var stubObserver = new StubObserver();
            mock.InstanceObserver = stubObserver;

            // Act
            ((ILogWriter)mock).Write("Foo");

            // Assert
            var calls = stubObserver.GetCalls();
            CollectionAssert.IsNotEmpty(calls, "Should be at least one call to the observer.");

            var callInfo = calls[0];

            Assert.That(callInfo.GetArguments()[0], Is.EqualTo("Foo"),
                "Mocked method should be called with 'Foo' argument.");

            Assert.That(callInfo.StubbedMethod.Name, Is.EqualTo("Write"),
                "ILogWriter.Write method should be called.");
        }
Example #4
0
 /// <summary>
 /// Gets the calls made to the Execute method of the provided observer
 /// </summary>
 /// <param name="observer"></param>
 /// <returns></returns>
 private IEnumerable<StubObservedCall> GetExecuteCall(StubObserver observer)
 {
     return observer.GetCalls().Where(c => c.StubbedMethod.Name == "Execute");
 }