Exemple #1
0
        public async Task Create_NoCondition_ViewReturned()
        {
            var audioBooksService = new Mock <IAudioBookServiceAsync>();

            var controller = new AudioBookManualController(audioBooksService.Object);

            var result = await controller.Create();

            Assert.IsType <ViewResult>(result);
        }
Exemple #2
0
        public async Task Create_DataPassed_ViewWithInformationReturned()
        {
            var audioBook = new AudioBook();
            var audioBooksService = new Mock<IAudioBookServiceAsync>();
            audioBooksService.Setup(x => x.Add(It.IsAny<AudioBook>())).Returns(Task.FromResult(audioBook));

            var controller = new AudioBookManualController(audioBooksService.Object);

            var result = await controller.Create(audioBook);

            Assert.IsType<RedirectToActionResult>(result);
        }
Exemple #3
0
        public async Task Create_ModelNotValid_ViewReturned()
        {
            var audioBook = new AudioBook();
            var audioBooksService = new Mock<IAudioBookServiceAsync>();
            audioBooksService.Setup(x => x.Add(It.IsAny<AudioBook>())).Returns(Task.FromResult(audioBook));

            var controller = new AudioBookManualController(audioBooksService.Object);
            controller.ModelState.AddModelError("Author", "Required");

            var result = await controller.Create(audioBook);

            Assert.IsType<ViewResult>(result);
        }