예제 #1
0
        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);
        }
예제 #2
0
        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);
        }