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 TestAddDuplicateTheatresShouldThrowException()
        {
            IPerformanceDatabase performanceDb = new PerformanceDatabase();

            performanceDb.AddTheatre("Theatre 199");
            performanceDb.AddTheatre("Theatre 199");
        }
        public void TestAddDuplicateShouldThrowException()
        {
            IPerformanceDatabase database = new PerformanceDatabase();

            database.AddTheatre("Art Theatre");
            database.AddTheatre("Theatre 199");
            database.AddTheatre("Theatre 199");
        }
        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 ListTheatres_NonEmptyList_ShouldReturnAllTheaters()
        {
            var db = new PerformanceDatabase();

            db.AddTheatre("Othelo");
            db.AddTheatre("Romemo and Juliet");

            var results = db.ListTheatres();

            Assert.AreEqual(2, results.Count());
        }
Exemplo n.º 6
0
        public void TestAddSeveralTheatresShouldListTheatresCorrectly()
        {
            IPerformanceDatabase performanceDb = new PerformanceDatabase();
            performanceDb.AddTheatre("Theatre 199");
            performanceDb.AddTheatre("Theatre Sofia");
            performanceDb.AddTheatre("Art Theatre");

            var expectedTheatres = new[] { "Art Theatre", "Theatre 199", "Theatre Sofia" };
            var actualTheatres = performanceDb.ListTheatres().ToList();

            CollectionAssert.AreEqual(expectedTheatres, actualTheatres);
        }
        public void TestAddSeveralTheatresShouldListTheatresCorrectly()
        {
            IPerformanceDatabase performanceDb = new PerformanceDatabase();

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

            var expectedTheatres = new[] { "Art Theatre", "Theatre 199", "Theatre Sofia" };
            var actualTheatres   = performanceDb.ListTheatres().ToList();

            CollectionAssert.AreEqual(expectedTheatres, actualTheatres);
        }
        public void TestAddTheatreReturnsListsTheatresCorrectrlyOrdered()
        {
            IPerformanceDatabase database = new PerformanceDatabase();

            database.AddTheatre("Art Theatre");
            database.AddTheatre("Bart Theatre");
            database.AddTheatre("Theatre 199");

            var expectedTheatres = new[] { "Art Theatre", "Bart Theatre", "Theatre 199" };
            var actualTheatres   = database.ListTheatres().ToList();

            CollectionAssert.AreEqual(expectedTheatres, actualTheatres);
        }
Exemplo n.º 9
0
        public void TestListTheatres_ShouldReturnListOfTheatres()
        {
            IPerformanceDatabase performanceDatabase = new PerformanceDatabase();

            performanceDatabase.AddTheatre("Ivan Vazov");
            performanceDatabase.AddTheatre("Theatre 199");

            List <string> testList = new List <string>();

            testList.Add("Ivan Vazov");
            testList.Add("Theatre 199");

            List <string> expectedList = performanceDatabase.ListTheatres().ToList();

            CollectionAssert.AreEqual(testList, expectedList, "ListTheatres() does not retrieve theatres properly.");
        }
 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 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 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 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.º 14
0
        public void TestListPerformances_NoPerformances_ShouldThrowException()
        {
            IPerformanceDatabase performanceDatabase = new PerformanceDatabase();

            performanceDatabase.AddTheatre("Theatre 199");

            performanceDatabase.ListPerformances("Theatre 199");
        }
        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.º 16
0
        public void TestAddSeveralTheatresWithDuplicatesShouldListTheatresCorrectly()
        {
            IPerformanceDatabase performanceDb = new PerformanceDatabase();
            performanceDb.AddTheatre("Theatre 199");
            performanceDb.AddTheatre("Theatre Sofia");
            try
            {
                performanceDb.AddTheatre("Theatre 199");
            }
            catch (DuplicateTheatreException)
            {
                // Do nothing -> this exception is expected
            }

            var expectedTheatres = new[] { "Theatre 199", "Theatre Sofia" };
            var actualTheatres = performanceDb.ListTheatres().ToList();

            CollectionAssert.AreEqual(expectedTheatres, actualTheatres);
        }
Exemplo n.º 17
0
        public void TestAddSeveralTheatresWithDuplicateShouldListTheatresCorrectly()
        {
            IPerformanceDatabase performanceDb = new PerformanceDatabase();

            performanceDb.AddTheatre("Theatre 199");
            performanceDb.AddTheatre("Theatre Sofia");
            try
            {
                performanceDb.AddTheatre("Theatre 199");
            }
            catch (DuplicateTheatreException)
            {
                // Do nothing -> this exception is expected
            }

            var expectedTheatres = new[] { "Theatre 199", "Theatre Sofia" };
            var actualTheatres   = performanceDb.ListTheatres().ToList();

            CollectionAssert.AreEqual(expectedTheatres, actualTheatres);
        }
        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 TestAddDuplicateTheatresShouldListTheatresCorrectrly()
        {
            IPerformanceDatabase database = new PerformanceDatabase();

            database.AddTheatre("Art Theatre");
            database.AddTheatre("Theatre 199");

            try
            {
                database.AddTheatre("Theatre 199");
            }
            catch (Exception)
            {
            }

            var expectedTheatres = new[] { "Art Theatre", "Theatre 199" };
            var actualTheatres   = database.ListTheatres().ToList();

            CollectionAssert.AreEqual(expectedTheatres, actualTheatres);
        }
        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.º 21
0
        public void TestListTheatresWithOneEntryInTheDatabase_ShouldReturnACollectionOfStrings()
        {
            // Arange
            var database = new PerformanceDatabase();

            // Act
            database.AddTheatre("Theatre Sofia");
            var result = database.ListTheatres() as ICollection;

            // Assert
            CollectionAssert.AllItemsAreInstancesOfType(
                result,
                typeof(string),
                "ListTheatres method returned a collection of a wrong type.");
        }
Exemplo n.º 22
0
        public void AddTheatre_TwoTimes_ShouldReturnCountEqualsTwo()
        {
            var db = new PerformanceDatabase();

            db.AddTheatre("Othelo");
            db.AddTheatre("Romemo and Juliet");

            var actualResult = db.ListTheatres();

            List <string> expectedResult = new List <string>();

            expectedResult.Add("Othelo");
            expectedResult.Add("Romemo and Juliet");
            string b = expectedResult[0];

            int count = 0;

            foreach (var theatre in actualResult)
            {
                string expectedName = expectedResult[count];
                Assert.AreEqual(theatre, expectedName);
                count++;
            }
        }
Exemplo n.º 23
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++;
            }
        }
Exemplo n.º 24
0
        public void TestListTheatresWithOneEntryInTheDatabase_ShouldReturnACollectionOfOneElement()
        {
            // Arange
            var expectedResult = 1;

            // Act
            database.AddTheatre("Theatre Sofia");
            var result = database.ListTheatres() as ICollection;

            // Assert
            Assert.AreEqual(expectedResult, result.Count, "ListTheatres method returned a collection of a wrong size.");
        }
        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.º 26
0
 public void TestAddDuplicateTheatresShouldThrowException()
 {
     IPerformanceDatabase performanceDb = new PerformanceDatabase();
     performanceDb.AddTheatre("Theatre 199");
     performanceDb.AddTheatre("Theatre 199");
 }
        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);
        }