Пример #1
0
        public async Task Details_ShouldReturnTest()
        {
            //Arrange
            var testModel = new InterviewerTestDetailsViewModel()
            {
                Id   = 1,
                Name = "Test 1",
                Url  = "https://www.mysite.bg/"
            };

            bool serviceCalled = false;

            var mockRepository = new Mock <IInterviewerTestsService>();

            mockRepository.Setup(service => service.Details(It.IsAny <int>()))
            .ReturnsAsync(testModel)
            .Callback(() => serviceCalled = true);

            var controller = new TestsController(mockRepository.Object);

            //Act
            var result = await controller.Details(1);

            //Assert
            Assert.IsInstanceOfType(result, typeof(ViewResult));
            Assert.IsTrue(serviceCalled);
        }
Пример #2
0
        public void TestControllerDetailsReturnsCorrectTestById()
        {
            var controller    = new TestsController(mockContext.Object);
            var detailsResult = controller.Details(1);

            //TODO

            Assert.AreEqual(false, true);
        }
Пример #3
0
        public async Task Testcase_TestsController_Returns_TestModel()
        {
            //arrange
            var testContext = await GetWeTestDbContext();

            TestsController sut = new TestsController(testContext);

            //act
            var result = await sut.Details("8") as ViewResult;

            var modelToTest = result.Model as Test;

            //assert
            Assert.NotNull(modelToTest);
            Assert.NotNull(modelToTest.TestTitle);
        }