Esempio n. 1
0
        public void Test_ShouldReturnView_WhenTestIsFinsihed(int testId)
        {
            //Arrange
            var mockFullTestService  = new Mock <ITestService>();
            var mockHelperFactory    = new Mock <IHelperFactory>();
            var mockViewModelFactory = new Mock <IViewModelFactory>();

            var fakeTest = new Test {
                CorrectCount = 0
            };

            mockFullTestService.Setup(x => x.GetTestById(It.IsAny <int>())).Returns(fakeTest);
            mockFullTestService.Setup(x => x.UserIsOwner(It.IsAny <int>())).Returns(true);

            var controller        = new TestsController(mockFullTestService.Object, mockHelperFactory.Object, mockViewModelFactory.Object);
            var fakeTestViewModel = new TestViewModel(testId);

            //Act
            controller.Test(fakeTestViewModel);

            //Assert
            controller.WithCallTo(x => x.Test(fakeTestViewModel)).ShouldRenderView("FinishedTest");
        }
Esempio n. 2
0
        public void Test_ShouldCallServiceGetTestById_WhenTestIsFinished(int testId)
        {
            //Arrange
            var mockFullTestService  = new Mock <ITestService>();
            var mockHelperFactory    = new Mock <IHelperFactory>();
            var mockViewModelFactory = new Mock <IViewModelFactory>();

            var fakeTest = new Test {
                CorrectCount = 0
            };

            mockFullTestService.Setup(x => x.GetTestById(It.IsAny <int>())).Returns(fakeTest);
            mockFullTestService.Setup(x => x.UserIsOwner(It.IsAny <int>())).Returns(true);

            var controller        = new TestsController(mockFullTestService.Object, mockHelperFactory.Object, mockViewModelFactory.Object);
            var fakeTestViewModel = new TestViewModel(testId);

            //Act
            controller.Test(fakeTestViewModel);

            //Assert
            mockFullTestService.Verify(x => x.GetTestById(testId), Times.Once);
        }