public void Cancel_NoGigWithGivenIdExists_ShouldReturnNotFound()
        {
            var result = _controller.Cancel(2);

            //  Assertion
            result.Should().BeOfType <NotFoundResult>();
        }
        public void Cancel_NoGigWithGivenIdExists_ShouldReturnNotFound()
        {
            // Act
            var result = _controller.Cancel(1).Result;

            // Assert
            Assert.IsInstanceOf <NotFoundResult>(result);
        }
        public void Cancel_NoGigWithGivenIdExists_ShouldReturnNotFound()
        {
            var cancelTask = _controller.Cancel(1);

            cancelTask.Wait();

            cancelTask.Result.Should().BeOfType <NotFoundResult>();
        }
        public void Cancel_NoGigWithGivenIdExists_ShouldReturnNotFound()
        {
            //because we've not used a setup method in our mockRepository
            //if we call _unitOfWork.Gigs.GetGigWithAttendees(id)
            //it will return null by default
            var result = _controller.Cancel(1);

            result.Should().BeOfType <NotFoundResult>(); //Should() is a FluentAssertion from the installed package
        }
Beispiel #5
0
        public void Cancel_NoGigWithGivenId_ShouldReturnNotFound()
        {
            var attendDTO = new EventsManagementWeb.Core.Dtos.AttendanceDTO();

            attendDTO.gidID = 1;
            var result = _controller.Cancel(attendDTO);

            result.Should().BeOfType <NotFoundResult>();
        }
Beispiel #6
0
        public async void Cancel_HappyPath_ShouldReturnOkObject()
        {
            var gigId = 1;

            _mockRepository.Setup(r => r.GetGigWithId(gigId, true)).ReturnsAsync(new Gig());

            var result = await _controller.Cancel(gigId);

            result.Should().BeOfType <OkObjectResult>();
        }
Beispiel #7
0
        public void Cancel_GigCanceled_ShouldReturnNotFound()
        {
            var gig = new Gig();

            gig.Cancel();

            _mockRepository.Setup(r => r.GetGigWithAttendancesAsync(1)).ReturnsAsync(gig);

            var result = _controller.Cancel(1).Result;

            result.Should().BeOfType <NotFoundResult>();
        }
        public void Cancel_ShouldReturn_GigIsCanceled()
        {
            //Arrage
            var user = _context.Users.First();

            _gigsController.MockCurrentUser(user.Id, user.UserName);
            var genre = _context.Genres.First(g => g.Id == 1);
            var gig   = new Gig()
            {
                Artist   = user,
                DateTime = DateTime.Now.AddDays(1),
                Genre    = genre,
                Venue    = "Venue1"
            };

            _context.Gigs.Add(gig);
            _context.SaveChanges();

            // Action
            var result = _gigsController.Cancel(gig.Id);

            // assert
            _context.Entry(gig).Reload();
            gig.IsCanceled.Should().Be(true);
            result.Should().BeOfType <OkResult>();
        }
Beispiel #9
0
        public void Cancel_WhenCalled_ShouldCancelTheGivenGigs()
        {
            // Arrange
            var users = _context.Users.ToList();

            _controller.MockCurrentUser(users[0].Id, users[0].UserName);

            var genre = _context.Genres.Single(g => g.Id == 1);
            var gig   = new Gig {
                Artist = users[0], DateTime = DateTime.Now.AddDays(1), Genre = genre, Venue = "-"
            };
            var attendee = new Attendance {
                Attendee = users[1],
                Gig      = gig
            };

            gig.Attendances.Add(attendee);
            _context.Gigs.Add(gig);
            _context.SaveChanges();

            // Act
            var result = _controller.Cancel(gig.Id);

            var userNotifications = _context.UserNotifications.ToList();
            var notifications     = _context.Notifications.ToList();

            // Assert
            _context.Entry(gig).Reload();
            gig.IsCanceled.Should().BeTrue();
            userNotifications.Should().HaveCount(1);
            notifications.Should().HaveCount(1);
            notifications.First().NotificationType.Should().Be(NotificationType.GigCanceled);
        }
Beispiel #10
0
        public void Cancel_UserCancelingAnotherAnotherUsersGig_ShouldReturnUnauthorized()
        {
            var gig = new Gig()
            {
                ArtistId = _userId + "-Boza"
            };

            _mockGigRepository.Setup(r => r.GetGigWithAttendeese(gigId)).Returns(gig);

            var result = _controller.Cancel(gigId);

            result.Should().BeOfType <UnauthorizedResult>();
        }
Beispiel #11
0
        public void Cancel_WhenCalled_ShouldReturnOk()
        {
            //ARRANGE
            var user = _context.Users.First();

            _controller.MockCurrentUserApi(user.Id, user.UserName);

            var genre = _context.Genres.First();
            var gig   = new Gig {
                Venue = "Venue", DateTime = DateTime.Now.AddDays(3), Artist = user, Genre = genre
            };

            _context.Gigs.Add(gig);
            _context.SaveChanges();

            //ACT
            var result = _controller.Cancel(gig.Id);

            //ASSERT
            result.Should().BeOfType <OkResult>();
        }
        //name of the method under test - condition - expected result
        //this is Roy Osherove's naming convention from "The Art of Unit Testing" book;
        public void Cancel_NoGigWithGivenIdExist_ShouldRetrunNotFound()
        {
            var result = _controller.Cancel(1);

            result.Should().BeOfType <NotFoundResult>();
        }
        public void Cancel_NoGigWithGivenIDExists_ShouldReturnNotFound()
        {
            var result = _controller.Cancel(1);

            result.Should().BeOfType <HttpNotFoundResult>();
        }
Beispiel #14
0
        public void Cancel_NoGigWithGivenIdExists_ShouldReturnNotFound()
        {
            var result = _sut.Cancel(1);

            result.Should().BeOfType <NotFoundResult>();
        }
        public void Cancel_NoGigWithGivenIdExists_ShouldReturnNotFound()
        {
            var result = _controller.Cancel("1");

            Assert.IsType <NotFoundResult>(result);
        }
Beispiel #16
0
        public void Cancel_NoGigWithGivenIdExists_ShouldReturnNotFound() // Name_Condition_ExpectedResult()
        {
            var result = _controller.Cancel(1);

            result.Should().BeOfType <NotFoundResult>();
        }
        public void Cancel_NogigWithgivenIdExists_ReturnNotFound()
        {
            var result = _controller.Cancel(1);

            result.Should().BeOfType <NotFoundResult>();
        }