Exemplo n.º 1
0
        public void TestListPerformancesByTheatre()
        {
            Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

            IPerformanceDatabase performanceDb = new PerformanceDatabase();

            performanceDb.AddTheatre("Theatre Sofia");
            performanceDb.AddPerformance("Theatre Sofia", "Bella Donna", new DateTime(2015, 02, 24, 19, 30, 00), new TimeSpan(1, 20, 0), 10M);
            performanceDb.AddPerformance("Theatre Sofia", "Dance Show", new DateTime(2015, 02, 24, 18, 00, 00), new TimeSpan(1, 20, 0), 8.00M);
            performanceDb.AddPerformance("Theatre Sofia", "Hamlet", new DateTime(2015, 02, 23, 19, 00, 00), new TimeSpan(1, 45, 0), 12.50M);

            performanceDb.AddTheatre("Theatre 199");
            performanceDb.AddPerformance("Theatre 199", "Bella Donna", new DateTime(2015, 02, 24, 19, 30, 00), new TimeSpan(1, 20, 0), 10M);

            var actualPerformancesSofia = string.Join(
                ", ", performanceDb.ListPerformances("Theatre Sofia"));
            var expectedPerformancesSofia = "Performance(Theatre: Theatre Sofia; Title: Hamlet; StartDateTime: 23.02.2015 19:00, Duration: 01:45, Price: 12.50), Performance(Theatre: Theatre Sofia; Title: Dance Show; StartDateTime: 24.02.2015 18:00, Duration: 01:20, Price: 8.00), Performance(Theatre: Theatre Sofia; Title: Bella Donna; StartDateTime: 24.02.2015 19:30, Duration: 01:20, Price: 10.00)";

            Assert.AreEqual(expectedPerformancesSofia, actualPerformancesSofia);

            var actualPerformances199   = string.Join(", ", performanceDb.ListPerformances("Theatre 199"));
            var expectedPerformances199 = "Performance(Theatre: Theatre 199; Title: Bella Donna; StartDateTime: 24.02.2015 19:30, Duration: 01:20, Price: 10.00)";

            Assert.AreEqual(expectedPerformances199, actualPerformances199);
        }
 public void TestAddOverlappingPerformancesShouldThrowException()
 {
     IPerformanceDatabase performanceDb = new PerformanceDatabase();
     performanceDb.AddTheatre("Theatre Sofia");
     performanceDb.AddPerformance("Theatre Sofia", "Dances", new DateTime(2015, 2, 2, 19, 00, 00), new TimeSpan(1, 40, 0), 12.50M);
     performanceDb.AddPerformance("Theatre Sofia", "Hamlet", new DateTime(2015, 2, 2, 20, 00, 00), new TimeSpan(1, 30, 0), 14.50M);
 }
        public void TestAddOverlappingPerformancesFirstAllDayShouldThrowException()
        {
            IPerformanceDatabase performanceDb = new PerformanceDatabase();

            performanceDb.AddTheatre("Theatre Sofia");
            performanceDb.AddPerformance("Theatre Sofia", "All Day Event", new DateTime(2015, 2, 2, 9, 00, 00), new TimeSpan(14, 00, 0), 12.50M);
            performanceDb.AddPerformance("Theatre Sofia", "Hamlet", new DateTime(2015, 2, 2, 19, 00, 00), new TimeSpan(1, 30, 0), 12.50M);
        }
        public void TestAddingOverlappingPerformanceStartToEndShouldThrowException()
        {
            Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            IPerformanceDatabase database = new PerformanceDatabase();

            database.AddTheatre("Theatre");
            database.AddTheatre("Theatre2");
            database.AddPerformance("Theatre", "Title", new DateTime(2015, 1, 1, 19, 0, 0), new TimeSpan(1, 30, 0), 15.5m);
            database.AddPerformance("Theatre", "Title", new DateTime(2015, 1, 1, 20, 00, 0), new TimeSpan(1, 30, 0), 15.5m);
        }
Exemplo n.º 5
0
        public void TestAddPerformanceWithAnIncorrectTheaterName_ShouldThrowAnException()
        {
            // Arange
            var date     = new DateTime(2000, 10, 10, 10, 30, 30);
            var duration = new TimeSpan(0, 2, 0, 0);

            // Act
            database.AddPerformance("Test", "TestPerformance", date, duration, 10m);

            // Assert
        }
        public void TestAddSeveralPerformancesShouldListPerformancesCorrectly()
        {
            IPerformanceDatabase performanceDb = new PerformanceDatabase();
            performanceDb.AddTheatre("Theatre Sofia");
            performanceDb.AddTheatre("Theatre 199");

            performanceDb.AddPerformance("Theatre Sofia", "Hamlet", new DateTime(2015, 02, 23, 19, 00, 00), new TimeSpan(1, 45, 0), 12.50M);
            performanceDb.AddPerformance("Theatre Sofia", "Bella Donna", new DateTime(2015, 02, 24, 19, 30, 00), new TimeSpan(1, 20, 0), 10M);
            performanceDb.AddPerformance("Theatre Sofia", "Dance Show", new DateTime(2015, 02, 24, 18, 00, 00), new TimeSpan(1, 20, 0), 8.00M);
            performanceDb.AddPerformance("Theatre 199", "Bella Donna", new DateTime(2015, 02, 24, 19, 30, 00), new TimeSpan(1, 20, 0), 10M);

            string actualPerformances = string.Join(", ", performanceDb.ListAllPerformances());

            string expectedPerformances = "Performance(Theatre: Theatre 199; Title: Bella Donna; StartDateTime: 24.02.2015 19:30, Duration: 01:20, Price: 10.00), Performance(Theatre: Theatre Sofia; Title: Hamlet; StartDateTime: 23.02.2015 19:00, Duration: 01:45, Price: 12.50), Performance(Theatre: Theatre Sofia; Title: Dance Show; StartDateTime: 24.02.2015 18:00, Duration: 01:20, Price: 8.00), Performance(Theatre: Theatre Sofia; Title: Bella Donna; StartDateTime: 24.02.2015 19:30, Duration: 01:20, Price: 10.00)";
            Assert.AreEqual(expectedPerformances, actualPerformances);
        }
        public void TestPrintPerformancesForTheatreShouldReturnCorrectly()
        {
            Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            IPerformanceDatabase database = new PerformanceDatabase();

            database.AddTheatre("First Theatre");
            database.AddPerformance("First Theatre", "Title1", new DateTime(2015, 01, 01, 18, 30, 00), new TimeSpan(01, 00, 00), 15m);
            database.AddPerformance("First Theatre", "Title2", new DateTime(2015, 01, 01, 20, 00, 00), new TimeSpan(01, 00, 00), 15m);

            database.AddTheatre("Second Theatre");
            database.AddPerformance("Second Theatre", "Title1", new DateTime(2015, 01, 01, 18, 30, 00), new TimeSpan(01, 00, 00), 15m);

            var actualPerformances = string.Join(", ", database.ListPerformances("Second Theatre"));
            var expected           = "Performance(Theatre: Second Theatre, Title: Title1, Date: 01.01.2015 18:30, Duration: 01:00, Price: 15.00)";

            Assert.AreEqual(actualPerformances, expected);
        }
Exemplo n.º 8
0
        public void TestAddPerformance_ShouldStorePerformanceToRepository()
        {
            IPerformanceDatabase performanceDatabase = new PerformanceDatabase();

            performanceDatabase.AddTheatre("Theatre 199");

            const string PerformanceStartTimeFormat = "dd.MM.yyyy HH:mm";

            string   theatreName1     = "Theatre 199";
            string   performanceName1 = "Duende";
            DateTime startDateTime1   = DateTime.ParseExact("20.01.2015 20:00", PerformanceStartTimeFormat,
                                                            CultureInfo.InvariantCulture);
            TimeSpan duration1    = TimeSpan.Parse("1:30");
            decimal  ticketPrice1 = 14.50m;

            string   theatreName2     = "Theatre 199";
            string   performanceName2 = "Hamlet";
            DateTime startDateTime2   = DateTime.ParseExact("21.01.2015 20:00", PerformanceStartTimeFormat,
                                                            CultureInfo.InvariantCulture);
            TimeSpan duration2    = TimeSpan.Parse("1:30");
            decimal  ticketPrice2 = 14.50m;

            performanceDatabase.AddPerformance(theatreName1, performanceName1, startDateTime1, duration1, ticketPrice1);
            performanceDatabase.AddPerformance(theatreName2, performanceName2, startDateTime2, duration2, ticketPrice2);

            var performancesList = performanceDatabase.ListPerformances("Theatre 199");

            IPerformance expectedResult1 = new Performance(
                theatreName1, performanceName1, startDateTime1, duration1, ticketPrice1);
            IPerformance expectedResult2 = new Performance(
                theatreName2, performanceName2, startDateTime2, duration2, ticketPrice2);
            var expectedResultsList = new List <IPerformance>();

            expectedResultsList.Add(expectedResult1);
            expectedResultsList.Add(expectedResult2);

            int index = 0;

            foreach (var performance in performancesList)
            {
                Assert.AreEqual(performance.ToString(), expectedResultsList[index].ToString(),
                                "AddPerformance() does not add performance.");
                index++;
            }
        }
        public void TestAddSeveralPerformancesShouldListPerformancesCorrectly()
        {
            IPerformanceDatabase performanceDb = new PerformanceDatabase();

            performanceDb.AddTheatre("Theatre Sofia");
            performanceDb.AddTheatre("Theatre 199");

            performanceDb.AddPerformance("Theatre Sofia", "Hamlet", new DateTime(2015, 02, 23, 19, 00, 00), new TimeSpan(1, 45, 0), 12.50M);
            performanceDb.AddPerformance("Theatre Sofia", "Bella Donna", new DateTime(2015, 02, 24, 19, 30, 00), new TimeSpan(1, 20, 0), 10M);
            performanceDb.AddPerformance("Theatre Sofia", "Dance Show", new DateTime(2015, 02, 24, 18, 00, 00), new TimeSpan(1, 20, 0), 8.00M);
            performanceDb.AddPerformance("Theatre 199", "Bella Donna", new DateTime(2015, 02, 24, 19, 30, 00), new TimeSpan(1, 20, 0), 10M);

            string actualPerformances = string.Join(", ", performanceDb.ListAllPerformances());

            string expectedPerformances = "Performance(Theatre: Theatre 199; Title: Bella Donna; StartDateTime: 24.02.2015 19:30, Duration: 01:20, Price: 10.00), Performance(Theatre: Theatre Sofia; Title: Hamlet; StartDateTime: 23.02.2015 19:00, Duration: 01:45, Price: 12.50), Performance(Theatre: Theatre Sofia; Title: Dance Show; StartDateTime: 24.02.2015 18:00, Duration: 01:20, Price: 8.00), Performance(Theatre: Theatre Sofia; Title: Bella Donna; StartDateTime: 24.02.2015 19:30, Duration: 01:20, Price: 10.00)";

            Assert.AreEqual(expectedPerformances, actualPerformances);
        }
Exemplo n.º 10
0
        public void TestAddPerformance_OverlappingPerformances_ShouldThrow()
        {
            IPerformanceDatabase performanceDatabase = new PerformanceDatabase();

            const string PerformanceStartTimeFormat = "dd.MM.yyyy HH:mm";

            string   theatreName1     = "Theatre 199";
            string   performanceName1 = "Duende";
            DateTime startDateTime1   = DateTime.ParseExact("20.01.2015 20:00", PerformanceStartTimeFormat,
                                                            CultureInfo.InvariantCulture);
            TimeSpan duration1    = TimeSpan.Parse("1:30");
            decimal  ticketPrice1 = 14.50m;

            performanceDatabase.AddPerformance(theatreName1, performanceName1, startDateTime1, duration1, ticketPrice1);

            string   theatreName2     = "Theatre 199";
            string   performanceName2 = "Hamlet";
            DateTime startDateTime2   = DateTime.ParseExact("20.01.2015 21:29", PerformanceStartTimeFormat,
                                                            CultureInfo.InvariantCulture);
            TimeSpan duration2    = TimeSpan.Parse("1:30");
            decimal  ticketPrice2 = 14.50m;

            performanceDatabase.AddPerformance(theatreName2, performanceName2, startDateTime2, duration2, ticketPrice2);

            string   theatreName3     = "Theatre 199";
            string   performanceName3 = "Don Juan";
            DateTime startDateTime3   = DateTime.ParseExact("20.01.2015 19:10", PerformanceStartTimeFormat,
                                                            CultureInfo.InvariantCulture);
            TimeSpan duration3    = TimeSpan.Parse("1:30");
            decimal  ticketPrice3 = 14.50m;

            performanceDatabase.AddPerformance(theatreName3, performanceName3, startDateTime3, duration3, ticketPrice3);

            string   theatreName4     = "Theatre 199";
            string   performanceName4 = "Don Pedro";
            DateTime startDateTime4   = DateTime.ParseExact("20.01.2015 20:10", PerformanceStartTimeFormat,
                                                            CultureInfo.InvariantCulture);
            TimeSpan duration4    = TimeSpan.Parse("1:00");
            decimal  ticketPrice4 = 14.50m;

            performanceDatabase.AddPerformance(theatreName4, performanceName4, startDateTime4, duration4, ticketPrice4);
        }
        public void TestAddingMultiplePerformancesShouldReturnListCorrectrly()
        {
            Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            IPerformanceDatabase database = new PerformanceDatabase();

            database.AddTheatre("Theatre");
            database.AddTheatre("Theatre2");
            database.AddTheatre("Theatre3");
            database.AddPerformance("Theatre", "Title", new DateTime(2015, 1, 1, 19, 0, 0), new TimeSpan(1, 30, 0), 15.5m);
            database.AddPerformance("Theatre2", "Title2", new DateTime(2015, 1, 2, 19, 0, 0), new TimeSpan(1, 30, 0), 15.5m);
            database.AddPerformance("Theatre3", "Title3", new DateTime(2015, 1, 3, 19, 0, 0), new TimeSpan(1, 30, 0), 15.5m);
            string actaulPerformances = string.Join(", ", database.ListAllPerformances());

            string expectedPerformances =
                "Performance(Theatre: Theatre, Title: Title, Date: 01.01.2015 19:00, Duration: 01:30, Price: 15.50)"
                + ", Performance(Theatre: Theatre2, Title: Title2, Date: 02.01.2015 19:00, Duration: 01:30, Price: 15.50)"
                + ", Performance(Theatre: Theatre3, Title: Title3, Date: 03.01.2015 19:00, Duration: 01:30, Price: 15.50)";

            Assert.AreEqual(actaulPerformances, expectedPerformances);
        }
        public void TestAddSinglePerformanceShouldListPerformancesCorrectly()
        {
            IPerformanceDatabase performanceDb = new PerformanceDatabase();

            performanceDb.AddTheatre("Theatre Sofia");

            performanceDb.AddPerformance("Theatre Sofia", "Hamlet", new DateTime(2015, 02, 23, 19, 00, 00), new TimeSpan(1, 45, 0), 12.50M);
            string actualPerformances = string.Join(", ", performanceDb.ListAllPerformances());

            string expectedPerformances = "Performance(Theatre: Theatre Sofia; Title: Hamlet; StartDateTime: 23.02.2015 19:00, Duration: 01:45, Price: 12.50)";

            Assert.AreEqual(expectedPerformances, actualPerformances);
        }
Exemplo n.º 13
0
        public void TestAddPerformance_NonExistingTheatre_ShouldThrow()
        {
            IPerformanceDatabase performanceDatabase = new PerformanceDatabase();

            const string PerformanceStartTimeFormat = "dd.MM.yyyy HH:mm";

            string   theatreName     = "Theatre 199";
            string   performanceName = "Duende";
            DateTime startDateTime   = DateTime.ParseExact("20.01.2015 20:00", PerformanceStartTimeFormat,
                                                           CultureInfo.InvariantCulture);
            TimeSpan duration    = TimeSpan.Parse("1:30");
            decimal  ticketPrice = 14.50m;

            performanceDatabase.AddPerformance(theatreName, performanceName, startDateTime, duration, ticketPrice);
        }
        public void TestListPerformancesByTheatre()
        {
            Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

            IPerformanceDatabase performanceDb = new PerformanceDatabase();

            performanceDb.AddTheatre("Theatre Sofia");
            performanceDb.AddPerformance("Theatre Sofia", "Bella Donna", new DateTime(2015, 02, 24, 19, 30, 00), new TimeSpan(1, 20, 0), 10M);
            performanceDb.AddPerformance("Theatre Sofia", "Dance Show", new DateTime(2015, 02, 24, 18, 00, 00), new TimeSpan(1, 20, 0), 8.00M);
            performanceDb.AddPerformance("Theatre Sofia", "Hamlet", new DateTime(2015, 02, 23, 19, 00, 00), new TimeSpan(1, 45, 0), 12.50M);

            performanceDb.AddTheatre("Theatre 199");
            performanceDb.AddPerformance("Theatre 199", "Bella Donna", new DateTime(2015, 02, 24, 19, 30, 00), new TimeSpan(1, 20, 0), 10M);

            var actualPerformancesSofia = string.Join(
                ", ", performanceDb.ListPerformances("Theatre Sofia"));
            var expectedPerformancesSofia = "Performance(Theatre: Theatre Sofia; Title: Hamlet; StartDateTime: 23.02.2015 19:00, Duration: 01:45, Price: 12.50), Performance(Theatre: Theatre Sofia; Title: Dance Show; StartDateTime: 24.02.2015 18:00, Duration: 01:20, Price: 8.00), Performance(Theatre: Theatre Sofia; Title: Bella Donna; StartDateTime: 24.02.2015 19:30, Duration: 01:20, Price: 10.00)";
            Assert.AreEqual(expectedPerformancesSofia, actualPerformancesSofia);

            var actualPerformances199 = string.Join(", ", performanceDb.ListPerformances("Theatre 199"));
            var expectedPerformances199 = "Performance(Theatre: Theatre 199; Title: Bella Donna; StartDateTime: 24.02.2015 19:30, Duration: 01:20, Price: 10.00)";
            Assert.AreEqual(expectedPerformances199, actualPerformances199);
        }
        public void TestAddPerformanceNonExistingTheatreShouldThrowException()
        {
            IPerformanceDatabase performanceDb = new PerformanceDatabase();

            performanceDb.AddPerformance("Theatre Sofia", "Hamlet", new DateTime(2015, 02, 23, 19, 00, 00), new TimeSpan(1, 45, 0), 12.50M);
        }
        public void TestAddSinglePerformanceShouldListPerformancesCorrectly()
        {
            IPerformanceDatabase performanceDb = new PerformanceDatabase();
            performanceDb.AddTheatre("Theatre Sofia");

            performanceDb.AddPerformance("Theatre Sofia", "Hamlet", new DateTime(2015, 02, 23, 19, 00, 00), new TimeSpan(1, 45, 0), 12.50M);
            string actualPerformances = string.Join(", ", performanceDb.ListAllPerformances());

            string expectedPerformances = "Performance(Theatre: Theatre Sofia; Title: Hamlet; StartDateTime: 23.02.2015 19:00, Duration: 01:45, Price: 12.50)";
            Assert.AreEqual(expectedPerformances, actualPerformances);
        }
        public void TestAddPerformanceNonExistingTheatreShouldThrowException()
        {
            IPerformanceDatabase performanceDb = new PerformanceDatabase();

            performanceDb.AddPerformance("Theatre Sofia", "Hamlet", new DateTime(2015, 02, 23, 19, 00, 00), new TimeSpan(1, 45, 0), 12.50M);
        }