Beispiel #1
0
        public void CalculatePriceTestWith6StudentTickets()
        {
            Movie movie = new Movie("Movie test");

            MovieScreening movieScreening = new MovieScreening(movie, new DateTime(2019, 1, 1), 5);

            Order o = new Order(1, true);

            MovieTicket ticket1 = new MovieTicket(movieScreening, false, 1, 1);
            MovieTicket ticket2 = new MovieTicket(movieScreening, false, 2, 1);
            MovieTicket ticket3 = new MovieTicket(movieScreening, false, 3, 1);
            MovieTicket ticket4 = new MovieTicket(movieScreening, false, 4, 1);
            MovieTicket ticket5 = new MovieTicket(movieScreening, false, 5, 1);
            MovieTicket ticket6 = new MovieTicket(movieScreening, false, 6, 1);

            o.AddSeatReservation(ticket1);
            o.AddSeatReservation(ticket2);
            o.AddSeatReservation(ticket3);
            o.AddSeatReservation(ticket4);
            o.AddSeatReservation(ticket5);
            o.AddSeatReservation(ticket6);

            var expected = 13.5;

            var actual = o.CalculatePrice();

            Assert.AreEqual(expected, actual);
        }
Beispiel #2
0
 public MovieTicket(MovieScreening movieScreening, TicketType type, int seatRow, int seatNumber)
 {
     this.MovieScreening = movieScreening;
     this.Type           = type;
     this.SeatRow        = seatRow;
     this.SeatNumber     = seatNumber;
     this.Price          = movieScreening.PricePerSeat;
 }
Beispiel #3
0
        public void Find_movie_screening_one()
        {
            IMovieScreeningRepository repository = new StubMovieScreeningRepository();

            MovieScreening movieScreening = repository.FindMovieScreeningById("1");

            Check.That(movieScreening).IsNotNull();
            Check.That(movieScreening.Rows.Count).IsEqualTo(2);
        }
Beispiel #4
0
        public async Task <ActionResult <MovieScreening> > PostMovieScreening(MovieScreening movieScreening)
        {
            movieScreening.movie = dataContext.Movies.Where(movie => movie.movieID == movieScreening.movie.movieID).FirstOrDefault();
            movieScreening.hall  = dataContext.Halls.Where(hall => hall.hallID == movieScreening.hall.hallID).FirstOrDefault();
            dataContext.MovieScreenings.Add(movieScreening);
            await dataContext.SaveChangesAsync();

            ////return CreatedAtAction("GetTodoItem", new { id = todoItem.Id }, todoItem);
            //return CreatedAtAction(nameof(Get), new { movieID = movie.movieID }, movie);
            return(movieScreening);
        }
        public MovieScreening FindMovieScreening(uint movieScreeningId)
        {
            var movieScreening = MovieScreening.CreateFrom(movieScreeningId, 5, 5);

            movieScreening.ReserveSeats(new ReserveSeats(movieScreeningId, 5));
            movieScreening.ReserveSeats(new ReserveSeats(movieScreeningId, 5));
            movieScreening.ReserveSeats(new ReserveSeats(movieScreeningId, 5));
            movieScreening.ReserveSeats(new ReserveSeats(movieScreeningId, 5));
            movieScreening.ReserveSeats(new ReserveSeats(movieScreeningId, 5));
            return(movieScreening);
        }
Beispiel #6
0
 public MovieTicket(
     MovieScreening movieScreening,
     bool isPremiumTicket,
     int seatRow,
     int seatNr)
 {
     _movieScreening  = movieScreening;
     _isPremiumTicket = isPremiumTicket;
     _seatRow         = seatRow;
     _seatNr          = seatNr;
 }
        public void singleOrderStudentWeekendUnitTest()
        {
            MovieScreening movieScreening = new MovieScreening(starWarsMovie, new DateTime(2021, 02, 13), defaultPrice);
            MovieTicket    movieTicket    = new MovieTicket(movieScreening, false, 1, 1);

            Order order = new Order(1, true);

            order.addSeatReservation(movieTicket);

            Assert.AreEqual(5, order.calculatePrice());
        }
        public void multipleOrdersNonStudentMidWeekUnitTest()
        {
            MovieScreening movieScreening = new MovieScreening(starWarsMovie, new DateTime(2021, 02, 04), defaultPrice);

            Order order = new Order(1, false);

            order.addSeatReservation(new MovieTicket(movieScreening, false, 1, 1));
            order.addSeatReservation(new MovieTicket(movieScreening, false, 1, 2));
            order.addSeatReservation(new MovieTicket(movieScreening, false, 1, 3));
            order.addSeatReservation(new MovieTicket(movieScreening, false, 1, 4));

            Assert.AreEqual(10, order.calculatePrice());
        }
        public void multipleOrdersStudentPremiumWeekendUnitTest()
        {
            MovieScreening movieScreening = new MovieScreening(starWarsMovie, new DateTime(2021, 02, 13), defaultPrice);

            Order order = new Order(1, true);

            order.addSeatReservation(new MovieTicket(movieScreening, true, 1, 1));
            order.addSeatReservation(new MovieTicket(movieScreening, true, 1, 2));
            order.addSeatReservation(new MovieTicket(movieScreening, true, 1, 3));
            order.addSeatReservation(new MovieTicket(movieScreening, true, 1, 4));

            Assert.AreEqual(28, order.calculatePrice());
        }
        public void FullPriceInWeekend()
        {
            //arrange
            //create a movie that is in the weekend
            var         sample = new MovieScreening(new Movie("Sjaak wordt geslagen op zijn kaak"), DateTime.Parse("Jan 29, 2021"), 14.0);
            MovieTicket ticket = new MovieTicket(sample, false, 5, 28);
            Order       order  = new Order(1, false);

            //act
            order.AddSeatReservation(ticket);
            //assert
            Assert.AreEqual(order.CalculatePrice(), ticket.GetPrice()); //assume that the price is equal as it should be full price.
        }
Beispiel #11
0
        public void CalculatePriceTestWithZeroTickets()
        {
            //arrange
            Movie          movie          = new Movie("Movie test");
            MovieScreening movieScreening = new MovieScreening(movie, DateTime.Now, 5);
            Order          o        = new Order(1, true);
            var            expected = 0;

            //act
            var actual = o.CalculatePrice();

            //assert
            Assert.AreEqual(expected, actual);
        }
        public void Should_CalculatePrice_ForStudentTickets()
        {
            Movie          movie          = new Movie("The movie");
            MovieScreening movieScreening = new MovieScreening(movie, new DateTime(2019, 1, 31), 2.00);
            MovieTicket    movieTicket    = new MovieTicket(movieScreening, TicketType.Student, 1, 1);
            Order          order          = new Order(1);

            order.AddSeatReservation(movieTicket);
            order.AddSeatReservation(movieTicket);
            order.AddSeatReservation(movieTicket);

            double actual = order.CalculatePrice();

            Assert.Equal(4, actual);
        }
        public void Should_CalculatePrice_ForNormalTickets()
        {
            Movie          movie          = new Movie("The movie");
            MovieScreening movieScreening = new MovieScreening(movie, DateTime.Now, 2.00);
            MovieTicket    movieTicket    = new MovieTicket(movieScreening, TicketType.Normal, 1, 1);
            MovieTicket    movieTicket1   = new MovieTicket(movieScreening, TicketType.Normal, 1, 1);
            MovieTicket    movieTicket2   = new MovieTicket(movieScreening, TicketType.Normal, 1, 1);
            Order          order          = new Order(1);

            order.AddSeatReservation(movieTicket);
            order.AddSeatReservation(movieTicket1);
            order.AddSeatReservation(movieTicket2);

            double actual = order.CalculatePrice();

            Assert.Equal(6, actual);
        }
        public void Should_CalculatePrice_ForGroupTicketsDuringWeekends()
        {
            Movie          movie          = new Movie("The movie");
            MovieScreening movieScreening = new MovieScreening(movie, new DateTime(2019, 2, 1), 2.00);
            MovieTicket    movieTicket    = new MovieTicket(movieScreening, TicketType.Normal, 1, 1);
            Order          order          = new Order(1);

            order.AddSeatReservation(movieTicket);
            order.AddSeatReservation(movieTicket);
            order.AddSeatReservation(movieTicket);
            order.AddSeatReservation(movieTicket);
            order.AddSeatReservation(movieTicket);
            order.AddSeatReservation(movieTicket);

            double actual = order.CalculatePrice();

            Assert.Equal(12, actual);
        }
Beispiel #15
0
        public void CalculatePriceTestWithOnePremiumTicketForStudent()
        {
            //arrange
            Movie          movie          = new Movie("Movie test");
            MovieScreening movieScreening = new MovieScreening(movie, new DateTime(2019, 1, 1), 5);
            Order          o        = new Order(1, true);
            var            expected = 6.30;

            MovieTicket ticket1 = new MovieTicket(movieScreening, true, 1, 1);


            o.AddSeatReservation(ticket1);

            //act
            var actual = o.CalculatePrice();

            //assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #16
0
        public void CalculatePriceTestFreeTicketOnFriday()
        {
            //arrange
            Movie          movie          = new Movie("Movie test");
            MovieScreening movieScreening = new MovieScreening(movie, new DateTime(2019, 1, 6), 5);
            Order          o        = new Order(1, false);
            var            expected = 10;

            MovieTicket ticket1 = new MovieTicket(movieScreening, false, 1, 1);
            MovieTicket ticket2 = new MovieTicket(movieScreening, false, 1, 1);


            o.AddSeatReservation(ticket1);
            o.AddSeatReservation(ticket2);

            //act
            var actual = o.CalculatePrice();

            //assert
            Assert.AreEqual(expected, actual);
        }
        public void TenPercentDiscountInWeekendWhenExceedingSixTicketsEdgeCaseScenario()
        {
            //arrange
            var         sample1 = new MovieScreening(new Movie("Sjaak wordt geslagen op zijn kaak"), DateTime.Parse("Jan 29, 2021"), 14.0);
            MovieTicket ticket1 = new MovieTicket(sample1, false, 5, 28);
            MovieTicket ticket2 = new MovieTicket(sample1, false, 5, 28);
            MovieTicket ticket3 = new MovieTicket(sample1, false, 5, 28);
            MovieTicket ticket4 = new MovieTicket(sample1, false, 5, 28);
            MovieTicket ticket5 = new MovieTicket(sample1, false, 5, 28);
            MovieTicket ticket6 = new MovieTicket(sample1, false, 5, 28);
            Order       order   = new Order(1, false);

            //act
            order.AddSeatReservation(ticket1);
            order.AddSeatReservation(ticket2);
            order.AddSeatReservation(ticket3);
            order.AddSeatReservation(ticket4);
            order.AddSeatReservation(ticket5);
            order.AddSeatReservation(ticket6);
            //assert
            Assert.AreEqual(Math.Round(order.CalculatePrice()), (Math.Round(ticket1.GetPrice() * 6 * 0.9))); //10% discount assumed
            //expected result is that there is already discount, as from 6 tickets upward the discount should already be applied. Issues such as these edge cases are common fault scenarios which is why I included an edge case for it. (Even though it is technically the same test as the one listed above. -Vincent
        }
Beispiel #18
0
        public Form1()
        {
            InitializeComponent();

            // Goede code niks mis mee
            try
            {
                Movie          movie     = new Movie("Film");
                MovieScreening screening = new MovieScreening(movie, DateTime.Now, 10);
                _order = new Order(1, true);
                _order.AddTicket(new MovieTicket(screening, true, 1, 1));
                _order.AddTicket(new MovieTicket(screening, true, 1, 2));
                _order.AddTicket(new MovieTicket(screening, true, 1, 3));
                _order.AddTicket(new MovieTicket(screening, true, 1, 4));
                _order.AddTicket(new MovieTicket(screening, true, 1, 5));
                _order.AddTicket(new MovieTicket(screening, true, 1, 6));
            }
            catch
            {
                MessageBox.Show("Er is een fout opgetreden", "Failed successfully", MessageBoxButtons.AbortRetryIgnore,
                                MessageBoxIcon.Question);
            }
        }
        public void TenPercentDiscountInWeekendWhenExceedingSixTickets()
        {
            //arrange
            var         sample1 = new MovieScreening(new Movie("Sjaak wordt geslagen op zijn kaak"), DateTime.Parse("Jan 29, 2021"), 14.0);
            MovieTicket ticket1 = new MovieTicket(sample1, false, 5, 28);
            MovieTicket ticket2 = new MovieTicket(sample1, false, 5, 28);
            MovieTicket ticket3 = new MovieTicket(sample1, false, 5, 28);
            MovieTicket ticket4 = new MovieTicket(sample1, false, 5, 28);
            MovieTicket ticket5 = new MovieTicket(sample1, false, 5, 28);
            MovieTicket ticket6 = new MovieTicket(sample1, false, 5, 28);
            MovieTicket ticket7 = new MovieTicket(sample1, false, 5, 28);
            Order       order   = new Order(1, false);

            //act
            order.AddSeatReservation(ticket1);
            order.AddSeatReservation(ticket2);
            order.AddSeatReservation(ticket3);
            order.AddSeatReservation(ticket4);
            order.AddSeatReservation(ticket5);
            order.AddSeatReservation(ticket6);
            order.AddSeatReservation(ticket7);
            //assert
            Assert.AreEqual(Math.Round(order.CalculatePrice()), (Math.Round(ticket1.GetPrice() * 7 * 0.9))); //10% discount assumed
        }
Beispiel #20
0
        public SeatsAllocated AllocateSeats(AllocateSeats allocateSeats)
        {
            MovieScreening movieScreening = _screeningRepository.FindMovieScreeningById(allocateSeats.ShowId);

            return(null);
        }
 public MovieScreening FindMovieScreening(uint movieScreeningId)
 {
     return(MovieScreening.CreateFrom(movieScreeningId, 5, 5));
 }