Пример #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 TestPrintPerformancesOfNonExsistentTheatreShouldThrowException()
        {
            Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            IPerformanceDatabase database = new PerformanceDatabase();

            database.ListPerformances("Test");
        }
Пример #3
0
        public void TestListPerformances_NoPerformances_ShouldThrowException()
        {
            IPerformanceDatabase performanceDatabase = new PerformanceDatabase();

            performanceDatabase.AddTheatre("Theatre 199");

            performanceDatabase.ListPerformances("Theatre 199");
        }
        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);
        }
Пример #5
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++;
            }
        }
Пример #6
0
        public void TestAddPerformance_ShouldAddAPerformanceToTheSpecifiedTheatre()
        {
            // Arange
            string  theatreName         = "Test Theatre";
            string  performanceName     = "TestPerformance";
            var     date                = new DateTime(2000, 10, 10, 10, 30, 30);
            var     duration            = new TimeSpan(0, 2, 0, 0);
            decimal price               = 10m;
            var     expectedPerformance = new Performance(performanceName, theatreName, date, duration, price);

            // Act
            database.AddTheatre(theatreName);
            database.AddPerformance(theatreName, performanceName, date, duration, price);
            var result = database.ListPerformances(theatreName).First();

            // Assert
            Assert.AreEqual(
                expectedPerformance.Date,
                result.Date,
                "AddPerformanceMethod saved and incorrect performance.");
            Assert.AreEqual(
                expectedPerformance.Name,
                result.Name,
                "AddPerformanceMethod saved and incorrect performance.");
            Assert.AreEqual(
                expectedPerformance.Duration,
                result.Duration,
                "AddPerformanceMethod saved and incorrect performance.");
            Assert.AreEqual(
                expectedPerformance.Price,
                result.Price,
                "AddPerformanceMethod saved and incorrect performance.");
            Assert.AreEqual(
                expectedPerformance.Theater,
                theatreName,
                "AddPerformanceMethod saved and incorrect performance.");
        }
        public void TestListPerformancesInvalidTheatreShouldThrowException()
        {
            IPerformanceDatabase performanceDb = new PerformanceDatabase();

            performanceDb.ListPerformances("Theatre Sofia");
        }
 public void TestListPerformancesInvalidTheatreShouldThrowException()
 {
     IPerformanceDatabase performanceDb = new PerformanceDatabase();
     performanceDb.ListPerformances("Theatre Sofia");
 }
        public void TestListPerformancesByTheatre()
        {
            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);
        }