Exemplo n.º 1
0
        public void ctor_WhenViewIsLoaded_CallsViewRender()
        {
            var mockView = Substitute.For<IView>();

            Presenter p = new Presenter(mockView, Substitute.For<ILogger>());
            mockView.Loaded += Raise.Event<Action>();

            mockView.Received().Render(Arg.Is<string>(s => s.Contains("Hello World")));
        }
Exemplo n.º 2
0
        public void ctor_WhenViewhasError_CallsLogger()
        {
            var stubView = Substitute.For<IView>();
            var mockLogger = Substitute.For<ILogger>();

            Presenter p = new Presenter(stubView, mockLogger);
            stubView.ErrorOccured += Raise.Event<Action<string>>("fake error");

            mockLogger.Received().LogError(Arg.Is<string>(s => s.Contains("fake error")));
        }
Exemplo n.º 3
0
        public void ctor_WhenViewhasError_CallsLogger()
        {
            var stubView = new Mock<IView>();
            var mockLogger = new Mock<ILogger>();

            Presenter p = new Presenter(stubView.Object, mockLogger.Object);
            stubView.Raise(view => view.ErrorOccured += null, "fake error");

            mockLogger.Verify(logger => 
                logger.LogError(It.Is<string>(s => s.Contains("fake error"))));

        }