Esempio n. 1
0
        public async Task Create_WithValidCourse_ReturnsProperView()
        {
            //Arrange
            var thread = new Thread()
            {
                Name        = "Random name",
                Description = "Random description"
            };

            var model = new ThreadCreationBindingModel()
            {
                Name        = thread.Name,
                Description = thread.Description
            };

            var mockRepository = new Mock <IAdminThreadsService>();

            mockRepository
            .Setup(repo => repo.AddThreadAsync(model))
            .ReturnsAsync(thread);

            var controller = new ThreadsController(mockRepository.Object);

            //Act
            var result = await controller.Create(model);

            //Assert
            Assert.IsInstanceOfType(result, typeof(RedirectToActionResult));
        }
Esempio n. 2
0
        public void Create_WithValidCourse_ShouldCallService()
        {
            //Arrange
            var serviceCalled = false;
            var model         = new ThreadCreationBindingModel()
            {
                Name        = "Random name",
                Description = "Random description"
            };

            var mockRepository = new Mock <IAdminThreadsService>();

            mockRepository
            .Setup(repo => repo.AddThreadAsync(model))
            .Callback(() => serviceCalled = true);

            var controller = new ThreadsController(mockRepository.Object);

            //Act
            var result = controller.Create(model);

            //Assert
            Assert.IsTrue(serviceCalled);
        }
Esempio n. 3
0
 public void TestCreate()
 {
     controller.Create("session", ActionLoggerDummy.dummyThread);
     controller.AddPost(1, "session", ActionLoggerDummy.dummyPost);
 }