Beispiel #1
0
        public void GetSeatInformation_Test()
        {
            //Arrange
            var responses = new List <TheaterRequest>()
            {
                new TheaterRequest()
                {
                    IsOk           = false,
                    PersonName     = "Smith",
                    RequestedSeats = 100,
                    RowNumber      = 1,
                    SectionNumber  = 1
                }
            };
            string responseText = "Smith Sorry, we can't handle your party.";

            Mock <ITheaterSearchHelper> mockTheaterSearchHelper = new Mock <ITheaterSearchHelper>();

            mockTheaterSearchHelper.Setup(x => x.BuildResponseMessage(It.IsAny <TheaterRequest>())).Returns(responseText);
            TheaterSeatingSearch theaterSeatingSearch = new TheaterSeatingSearch(mockTheaterSearchHelper.Object);

            //Act
            var result = theaterSeatingSearch.GetSeatInformation(responses);

            //Assert
            Assert.AreEqual(result.Count, 1);
            Assert.AreEqual(result.FirstOrDefault(), responseText);
        }
Beispiel #2
0
        public void GetTheaterLayout_Test()
        {
            //Arrange
            string layout = "5 5\r\n7 8\r\n";

            Mock <ITheaterSearchHelper> mockTheaterSearchHelper = new Mock <ITheaterSearchHelper>();
            TheaterSeatingSearch        theaterSeatingSearch    = new TheaterSeatingSearch(mockTheaterSearchHelper.Object);

            //Act
            var result = theaterSeatingSearch.GetTheaterLayout(layout);

            //Assert
            Assert.AreEqual(result.TotalSeats, 25);
        }
Beispiel #3
0
        public void GetTicketRequest_Test()
        {
            //Arrange
            string ticketRequests = "Smith 5\r\nThiru 8\r\n";

            Mock <ITheaterSearchHelper> mockTheaterSearchHelper = new Mock <ITheaterSearchHelper>();
            TheaterSeatingSearch        theaterSeatingSearch    = new TheaterSeatingSearch(mockTheaterSearchHelper.Object);

            //Act
            var result = theaterSeatingSearch.GetTicketRequests(ticketRequests);

            //Assert
            Assert.AreEqual(result.Count, 2);
        }
Beispiel #4
0
        public void ProcessTicketRequests_Test()
        {
            //Arrange
            var theaterLayout = new TheaterLayout()
            {
                UsableSeats = 10,
                TotalSeats  = 10,
                Sections    = new List <TheaterSection>()
                {
                    new TheaterSection()
                    {
                        AvailableSeats = 5,
                        RowNumber      = 1,
                        SectionNumber  = 1
                    },
                    new TheaterSection()
                    {
                        AvailableSeats = 5,
                        RowNumber      = 2,
                        SectionNumber  = 2
                    }
                }
            };

            var theaterRequest = new List <TheaterRequest>()
            {
                new TheaterRequest()
                {
                    IsOk           = false,
                    PersonName     = "Smith",
                    RequestedSeats = 5,
                    RowNumber      = 1,
                    SectionNumber  = 1
                }
            };

            Mock <ITheaterSearchHelper> mockTheaterSearchHelper = new Mock <ITheaterSearchHelper>();
            TheaterSeatingSearch        theaterSeatingSearch    = new TheaterSeatingSearch(mockTheaterSearchHelper.Object);

            //Act
            var result = theaterSeatingSearch.ProcessTicketRequests(theaterLayout, theaterRequest);

            //Assert
            Assert.AreEqual(result.Count, 1);
        }
        //Main program to read the Theater layout and Ticket Requests from user as inputs

        /** Sample input:
         *  6 6
         *  3 5 5 3
         *  4 6 6 4
         *  2 8 8 2
         *  6 6
         *
         *  Smith 2
         *  Jones 5
         *  Davis 6
         *  Wilson 100
         *  Johnson 3
         *  Williams 4
         *  Brown 8
         *  Miller 12
         * */
        public static void Main(string[] args)
        {
            List <string> inputAllLines = new List <string>();

            Console.WriteLine("Please provide the inputs (Theater Layout and Ticket Requests) and end with '#'.");

            while (true)
            {
                var input = Console.ReadLine();

                if (input == "#")
                {
                    break;
                }

                inputAllLines.Add(input);
            }

            ITheaterSearchHelper theaterSearchHelper = new TheaterSearchHelper();
            ITheaterSearch       theaterSearch       = new TheaterSeatingSearch(theaterSearchHelper);

            TheaterSeat theaterSeat = new TheaterSeat(theaterSearch);

            try
            {
                //Passing the inputs and get the theater seats
                var requests = theaterSeat.GetTheaterSeats(inputAllLines);

                Console.WriteLine("\n*****Theater Seats Allocation..*****\n");

                //Printing the output
                foreach (var request in requests)
                {
                    Console.WriteLine(request);
                }

                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("Internal Error occured" + e.StackTrace);
            }
        }