public void CanMakeBookingAt_ParticipantCanMakeLegalBooking() { //Arrange var mock = new Mock <IDataAccess>(); mock.Setup(D => D.Retrieve <Concert>()).Returns(new List <Concert>()); mock.Setup(D => D.Retrieve <Venue>()).Returns(new List <Venue>()); var mockFestivalManager = new Mock <IFestivalManager>(); Participant participant = new Participant(new Ticket("test"), mock.Object); List <Concert> concertsList = new List <Concert>() { new Concert(mock.Object) { Start = new DateTime(2020, 10, 10, 20, 30, 00), End = new DateTime(2020, 10, 10, 21, 30, 00), Bookings = new List <Booking>() { new Booking(mock.Object) { Participant = participant, ID = 0 } } }, new Concert(mock.Object) { Start = new DateTime(2020, 10, 10, 21, 30, 00), End = new DateTime(2020, 10, 10, 22, 30, 00), Bookings = new List <Booking>() { new Booking(mock.Object) { Participant = participant, ID = 1 } } } }; Calendar calendar = new Calendar(mock.Object); calendar.AddConcert(concertsList[0]); calendar.AddConcert(concertsList[1]); mockFestivalManager.SetupGet(m => m.Calendar).Returns(calendar); Concert concert = new Concert(mock.Object) { Start = new DateTime(2020, 10, 10, 19, 30, 00), End = new DateTime(2020, 10, 10, 20, 25, 00) }; bool expected = true; //Act bool result = participant.CanMakeBookingAt(concert, mockFestivalManager.Object); //Assert Assert.Equal(expected, result); }
public void CanMakeBookingAt_ParticipantCannotMakeBookingWhenOverlap_WhenConcertExpandsOvernight(string inputStart, string inputEnd, bool expected) { //Arrange var mock = new Mock <IDataAccess>(); mock.Setup(D => D.Retrieve <Concert>()).Returns(new List <Concert>()); mock.Setup(D => D.Retrieve <Venue>()).Returns(new List <Venue>()); var mockFestivalManager = new Mock <IFestivalManager>(); Participant participant = new Participant(new Ticket("test"), mock.Object); List <Concert> concertsList = new List <Concert>() { new Concert(mock.Object) { Start = new DateTime(2020, 10, 10, 20, 30, 00), End = new DateTime(2020, 10, 10, 21, 30, 00), Bookings = new List <Booking>() { new Booking(mock.Object) { Participant = participant, ID = 0 } } }, new Concert(mock.Object) { Start = new DateTime(2020, 10, 10, 23, 30, 00), End = new DateTime(2020, 10, 11, 00, 30, 00), Bookings = new List <Booking>() { new Booking(mock.Object) { Participant = participant, ID = 1 } } } }; Calendar calendar = new Calendar(mock.Object); calendar.AddConcert(concertsList[0]); calendar.AddConcert(concertsList[1]); mockFestivalManager.SetupGet(m => m.Calendar).Returns(calendar); Concert concert = new Concert(mock.Object) { Start = DateTime.Parse(inputStart), End = DateTime.Parse(inputEnd) }; //Act bool result = participant.CanMakeBookingAt(concert, mockFestivalManager.Object); //Assert Assert.Equal(expected, result); }
public void GetParticipantBookings_FindTheBookings() { //Arrange var mock = new Mock <IDataAccess>(); mock.Setup(D => D.Retrieve <Concert>()).Returns(new List <Concert>()); mock.Setup(D => D.Retrieve <Venue>()).Returns(new List <Venue>()); var mockFestivalManager = new Mock <IFestivalManager>(); Participant participant = new Participant(new Ticket("test"), mock.Object); List <Concert> concertsList = new List <Concert>() { new Concert(mock.Object) { Bookings = new List <Booking>() { new Booking(mock.Object) { Participant = participant, ID = 0 } } }, new Concert(mock.Object) { Bookings = new List <Booking>() { new Booking(mock.Object) { Participant = participant, ID = 1 } } }, new Concert(mock.Object) { Bookings = new List <Booking>() } }; Calendar calendar = new Calendar(mock.Object); calendar.AddConcert(concertsList[0]); calendar.AddConcert(concertsList[1]); mockFestivalManager.SetupGet(m => m.Calendar).Returns(calendar); int expected = 2; //Act int result = participant.GetParticipantBookings(mockFestivalManager.Object).Count; //Assert Assert.Equal(expected, result); }
public void AddConcert_AddsTheCorrectVenueBasedOnGivenVenueName() { //Arrange var mock = new Mock <IDataAccess>(); mock.Setup(D => D.Retrieve <Concert>()).Returns(new List <Concert>()); mock.Setup(D => D.Retrieve <Venue>()).Returns( new List <Venue>() { new Venue(mock.Object) { Name = "test1" }, new Venue(mock.Object) { Name = "test2" } }); Concert concert = GetEmptyConcert(); Calendar calendar = new Calendar(mock.Object); string expected = "test1"; //Act calendar.AddConcert(concert, "test1"); string result = calendar.GetConcerts()[0].Venue?.Name; //Assert Assert.Equal(expected, result); }
public void AddConcert_AddsAConcertToACalendar() { //Arrange var mock = new Mock <IDataAccess>(); mock.Setup(D => D.Retrieve <Concert>()).Returns(new List <Concert>()); mock.Setup(D => D.Retrieve <Venue>()).Returns(new List <Venue>()); Calendar calendar = new Calendar(mock.Object); Concert concert = GetEmptyConcert(); int expected = 1; //Act calendar.AddConcert(concert); int result = calendar.GetConcerts().Count; //Assert Assert.Equal(expected, result); }