public void GetUpcomingGigsByArtist_GigIsCanceled_ShouldNotBeReturned() { string userId = "1"; var gig = new Gig { DateTime = DateTime.Now.AddDays(1), ArtistId = userId }; gig.Cancel(); mockGig.SetSource(new[] { gig }); var gigs = _gigRepository.GetUpcomingGigsByArtist(userId); gigs.Should().BeEmpty(); }
public void GetUpComingGigsByArtist_GigIsCancelled_ShouldNotBeReturned() { var gig = new Gig() { ArtistId = "1", DateTime = DateTime.Now.AddDays(1) }; gig.Cancel(); _mockGigs.SetSource(new[] { gig }); var gigs = _repository.GetUpComingGigsByArtists("1"); gigs.Should().BeEmpty(); }
public void GetUserUpcomingGigs_GigIsCanceled_ShouldNotBeReturned() { var gig = new Gig { DateTime = DateTime.Now.AddDays(-1), ArtistId = "1" }; gig.Cancel(); _MockGigs.SetSource(new[] { gig }); var gigs = _repository.GetUserUpcomingGigs("1"); gigs.Should().BeEmpty(); }
public void Cancel_GigIsCanceled_ShouldReturnNotFound() { //here we mock a gig by ourselves var gig = new Gig(); gig.Cancel(); //set a cancel gig //here we setup that GetGigWithAttendees(1) inside _controller.Cancel(1) will //return this gig above _mockRepository.Setup(r => r.GetGigWithAttendees(1)).Returns(gig); var result = _controller.Cancel(1); result.Should().BeOfType <NotFoundResult>(); }
public void Cancel_WhenCalled_EachAttendeeShouldHaveANotification() { var gig = new Gig(); gig.Attendances.Add(new Attendance { Attendee = new ApplicationUser() }); gig.Cancel(); //TODO: This could be pushed into the Gig class (eg gig.GetAttendees()) var attendees = gig.Attendances.Select(a => a.Attendee).ToList(); attendees[0].UserNotifications.Count.Should().Be(1); }
public void GetUpcomingGigs_CanceledGigsInTheFuture_ShoudNotBeReturned() { var gig = new Gig() { Date = DateTime.Now.AddDays(4) }; gig.Cancel(); _mockGigs.SetSource(new[] { gig }); var gigs = _gigRepo.GetUpcomingGigs(); gigs.Should().BeEmpty(); }
public void GetUserAvailableGigs_GigIsCanceled_ShouldNotBeReturned() { var gig = new Gig() { Date = DateTime.Now.AddDays(1), ArtistId = "1" }; gig.Cancel(); _mockGigs.SetSource(new[] { gig }); var gigs = _gigRepo.GetUserFutureAvailableGigs("1"); gigs.Should().BeEmpty(); }
public void GetUpcomingGigsByArtist_GigIsCancelled_ShouldNotBeReturned() { var gig = new Gig() { DateTime = DateTime.Now.AddDays(+1), ArtistId = _userId }; gig.Cancel(); _mockGigs.SetSource(new[] { gig }); var gigs = _repository.GetUpcommingGigsByArtist(gig.ArtistId); gigs.Should().BeEmpty(); }
public void GetUpcomingGigsByArtist_GigIsCanceled_ShouldNotBeReturned() { var gig = new Gig() { DateTime = DateTime.Now.AddDays(1), ArtistId = "1" }; gig.Cancel(); _mockGigs.SetSource(new[] { gig }); // List<Gig> = [] var gigs = _repository.GetUpcomingGigsByArtist("1"); gigs.Should().BeEmpty(); }
public void Cancel_WhenCalled_EachAttendeeShouldHaveANotification() { var gig = new Gig(); gig.Attendances.Add(new Attendance { Attendee = new ApplicationUser { Id = "1" } }); gig.Cancel(); var attendees = gig.Attendances.Select(a => a.Attendee).ToList(); attendees[0].UserNotifications.Count.Should().Be(1); }
public void GetComingGigsByArtist_GigIsForADifferentArtist_ShouldNotBeReturned() { var gig = new Gig() { DateTime = DateTime.Now.AddDays(1), ArtistId = "1" }; gig.Cancel(); _mockGigs.SetSource(new[] { gig }); var gigs = _repository.GetUpcomingGigsByArtist(gig.ArtistId + "-"); gigs.Should().BeEmpty(); }
public void GetGigs_GigsIsCancelled_ShouldNotBeReturned() { var gig = new Gig() { DateTime = DateTime.UtcNow.ToLocalTime().AddDays(7), ArtistId = _artistId }; gig.Cancel(); _gigs.SetSource(new[] { gig }); var result = _repository.GetGigs(_artistId); result.Should().BeEmpty(); }
public void Cancel_WhenCalled_ShouldCreateNotifcationForAllAttendee() { var gig = new Gig(); gig.Attendances.Add(new Attendance { Attendee = new ApplicationUser { Id = "1" } }); gig.Cancel(); var atttendee = gig.Attendances.Select(a => a.Attendee).ToList(); atttendee[0].UserNotification.Count().Should().Be(1); }
public void GetUpcomingGigsByArtist_GigIsCanceled_ShouldNotBeReturned() { var gig = new Gig() { DateTime = DateTime.Now.AddDays(2), ArtistId = "1" }; gig.Cancel(); _mockGigs.SetSource(new[] { gig }); _mockContext.Setup(r => r.Gigs).Returns(_mockGigs.Object); var gigs = _gigRepository.GetUpcomingGigsByArtist("1"); gigs.Should().BeEmpty(); }
public void Cancel_GigIsCanceled_ShouldReturnNotFound() { var gig = new Gig(); gig.Cancel(); Task <Gig> t = Task.Factory.StartNew(() => { return(gig); }); _mockRepository.Setup(r => r.GetGigAsync(1)).Returns(t); var cancelTask = _controller.Cancel(1); cancelTask.Wait(); cancelTask.Result.Should().BeOfType <NotFoundResult>(); }
public void Cancel_GigIsCancelled_ShouldReturnNotFound() { //Arrange Gig gig = new Gig(); //for now we have changed protected Gig constructor to public gig.Cancel(); //When getGigWithAttendees(int id) is called, it will return above gig object _mockRepository.Setup(g => g.GetGigWithAttendees(1)).Returns(gig); //Act var result = _controller.Cancel(1); //Assert result.Should().BeOfType <NotFoundResult>(); }
public void GetUpcomingGigsByArtist_GigIsForTheGivenArtistAndIsInTheFuture_ShouldNotBeReturned() { var gig = new Gig { DateTime = DateTime.Now.AddDays(1), ArtistId = "1" }; gig.Cancel(); _mockGigs.SetSource(new[] { gig }); var gigs = _repository.GetUpcomingGigsByArtist(gig.ArtistId); gigs.Should().Contain(gig); }
public void Cancel_GigIsCanceled_ShouldReturnNotFound() { //arrange var gig = new Gig(); gig.Cancel(); //what I expect from act _mockRepository.Setup(r => r.GetGigForUser(_userId, 1)).Returns(gig); //act var res = _controller.Cancel(1); //assert res.Should().BeOfType <NotFoundResult>(); }
public void Cancel_WhenCalled_EachAttendeeShouldHaveANotification() { var gig = new Gig(); gig.Attendances.Add(new Attendance { Attendee = new ApplicationUser { Id = "1" } }); gig.Cancel(); var attendes = gig.GetAttendees(); attendes.ElementAt(0).UserNotifications.Count.Should().Be(1); }
public void GetUpcomingGigByArtist_GigIsCanceled_ShouldNotBeReturn() { var gig = new Gig { DateTime = DateTime.Now.AddDays(1), ArtistId = _artistId }; gig.Cancel(); _mockDbSetGigs.SetSource(new[] { gig }); _mockContext.Gigs = _mockDbSetGigs.Object; var gigs = _repository.GetGigsByArtist(gig.ArtistId); gigs.Should().BeEmpty(); }
public void GetUpcomingGigsByArtist_GigIsCanceled_ShouldNotBeReturned() { //arrange var gig = new Gig() { DateTime = DateTime.Now.AddDays(1), ArtistId = "1" }; gig.Cancel(); _mockGigs.SetSource(new [] { gig }); //act var gigs = _repository.GetUpcomingGigsByArtist(gig.ArtistId); //assert gigs.Should().BeEmpty(); }
public void Cancel_WhenCalled_EachAttendeeShouldHaveNotification() { var gig = new Gig(); gig.Attendances.Add(new Attendance { Attendee = new ApplicationUser { Id = "1" } }); gig.Cancel(); var notifications = gig.GetAttendees().First().UserNotifications; notifications.Count.Should().Be(1); notifications.First().Notification.Type.Should().Be(NotificationType.GigCancelled); }
public void Cancel_WhenCalled_AllAttendeesShouldBeNotified() { // Arrange var gig = new Gig(); var user = new ApplicationUser(); gig.Attendances.Add(new Attendance() { Attendee = user }); // Act gig.Cancel(); // Assert Assert.AreEqual(1, user.UserNotifications.Count); }
public IHttpActionResult Cancel(int id) { string userId = User.Identity.GetUserId(); Gig gig = db.Gigs.Include(x => x.Attendances.Select(y => y.Attendee)).Single(x => x.Id == id && x.ArtistId == userId); if (gig.IsCancelled) { return(NotFound()); } gig.Cancel(); db.Entry(gig).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(Ok()); }
public void GetUpcomingGigsByArtist_GigIsCancelled_ShouldNotBeReturned() { var gig = new Gig() { DateTime = DateTime.Today.AddDays(2), ArtistId = "1" }; gig.Cancel(); _mockGiggDbSet.SetSource(new List <Gig>() { gig }); var result = _repository.GetUpcomingGigsByArtist("1"); result.Should().BeEmpty(); }
public void GetUpcomingGigsByArtist_TommorrowCanceledGig_ShouldReturnEmpty() { var gig = new Gig { ID = 1, DateTime = System.DateTime.Now.AddDays(1), GenreID = 1, ArtistID = "1" }; gig.Cancel(); _mockGig.SetSource(new[] { gig }); var gigInfo = _gigRepository.GetUpcomingGigsByArtist("1"); gigInfo.Should().BeEmpty(); }
public void Cancel_WhenCalled_EachAttendentShouldHaveANotification() { Gig gig = new Gig(); gig.Attendences.Add(new Attendence() { Attendee = new ApplicationUser() { Name = "1" } }); gig.Cancel(); var attendees = gig.Attendences.ToList(); attendees[0].Attendee.UserNotifications.Count().Should().Be(1); }
public IHttpActionResult Cancel(int id) { string userId = User.Identity.GetUserId(); Gig gig = Context.Gigs .Include(g => g.Attendances.Select(a => a.Attendee)) .Single(g => g.Id == id && g.ArtistId == userId); if (gig.IsCanceled) { return(NotFound()); } gig.Cancel(); Context.SaveChanges(); return(Ok()); }
public IHttpActionResult Cancel(int id) { Gig gig = unitOfWork.Gigs.GetGigWithAttendees(id); if (gig == null || gig.IsCancelled) { return(NotFound()); } if (gig.ArtistId != User.Identity.GetUserId()) { return(Unauthorized()); } gig.Cancel(); unitOfWork.Complete(); return(Ok()); }
public void GetFutureGigsWithGenre_GigIsCancelled_ShouldNotBeReturned() { // Arrange var gig = new Gig() { DateTime = DateTime.Now.AddDays(1), ArtistId = "1" }; gig.Cancel(); _mockGigs.SetSource(new List <Gig> { gig }); // Act var gigs = _repository.GetFutureGigsWithGenre("1"); // Assert gigs.Should().BeEmpty(); }