Beispiel #1
0
        public async Task PostShouldUpdateChannelNameIfLoginPassesAsync()
        {
            //arrange
            var mockRepo     = new Mock <IRepository>();
            var inputCreator = new Creator()
            {
                FirstName = "Marielle",
                LastName  = "Nolasco",
                Email     = "*****@*****.**"
            };
            var controller = new CreatorController(mockRepo.Object);

            //act
            var result = await controller.PostAsync(inputCreator);

            //assert
            Assert.IsAssignableFrom <OkResult>(result);
        }
Beispiel #2
0
        public async Task PostShouldAddCreatorIfLoginFailsAsync()
        {
            //arrange
            var mockRepo = new Mock <IRepository>();

            mockRepo.Setup(x => x.LogInAsync(It.IsAny <string>())).Throws(new Persistence.CreatorDoesNotExistException());
            var inputCreator = new Creator()
            {
                FirstName = "Marielle",
                LastName  = "Nolasco",
                Email     = "*****@*****.**"
            };
            var controller = new CreatorController(mockRepo.Object);

            //act
            var result = await controller.PostAsync(inputCreator);

            //assert
            Assert.IsAssignableFrom <CreatedAtActionResult>(result);
        }
Beispiel #3
0
        public async Task PostShouldHandleChannelNameTakenExceptionAsync()
        {
            //arrange
            var mockRepo = new Mock <IRepository>();

            mockRepo.Setup(x => x.UpdateChannelNameAsync(It.IsAny <string>(), It.IsAny <Creator>())).Throws(new Persistence.ChannelNameTakenException());
            var inputCreator = new Creator()
            {
                FirstName = "Marielle",
                LastName  = "Nolasco",
                Email     = "*****@*****.**"
            };
            var controller = new CreatorController(mockRepo.Object);

            //act
            var result = await controller.PostAsync(inputCreator);

            //assert
            Assert.IsAssignableFrom <BadRequestResult>(result);
        }