Exemplo n.º 1
0
        public void OneSuccesfulSetAndOneFailed()
        {
            string expected = "1. mediumSet:" + Environment.NewLine + "-- 1. Song1 (05:00)" + Environment.NewLine + "-- Set Successful" + Environment.NewLine +
                              "2. shortSet:" + Environment.NewLine + "-- Did not perform";

            IStage stage = new Stage();

            string firstSetName = "shortSet";
            ISet   set1         = new Short(firstSetName);

            stage.AddSet(set1);

            string songName = "Song1";
            var    duration = new TimeSpan(0, 5, 0);
            ISong  song     = new Song(songName, duration);

            string performerName = "Pesho";
            int    age           = 20;
            var    performer     = new Performer(performerName, age);
            var    guitar        = new Guitar();

            performer.AddInstrument(guitar);

            string secondSetName = "mediumSet";
            ISet   set2          = new Medium(secondSetName);

            set2.AddPerformer(performer);
            set2.AddSong(song);
            stage.AddSet(set2);

            var    setController = new SetController(stage);
            string result        = setController.PerformSets();

            Assert.That(result, Is.EqualTo(expected));
        }
Exemplo n.º 2
0
        public void InstrumentsToRepair()
        {
            Stage stage = new Stage();

            ISetController setController = new SetController(stage);
            Performer      performer     = new Performer("Ivan", 24);

            performer.AddInstrument(new Drums());
            stage.AddPerformer(performer);
            Song song = new Song("pesen", new TimeSpan(0, 3, 0));
            Set  set  = new Medium("Set1");

            set.AddPerformer(performer);
            set.AddSong(song);
            stage.AddSet(set);

            int expectedInstrumets = 1;

            setController.PerformSets();

            var instrumentsToRepair = stage.Performers
                                      .SelectMany(p => p.Instruments)
                                      .Where(i => i.Wear <= 100)
                                      .ToArray();

            Assert.That(instrumentsToRepair.Length, Is.EqualTo(expectedInstrumets));
        }
        public void Test()
        {
            //Arrange
            IStage stage = new Stage();
            ISet   set   = new Medium("testSet");

            IPerformer performer = new Performer("pencho", 3);

            performer.AddInstrument(new Guitar());

            ISong song = new Song("testSong", new System.TimeSpan(0, 0, 2));

            set.AddPerformer(performer);
            set.AddSong(song);

            stage.AddSet(set);
            this.controller = new SetController(stage);

            string expectedEnd      = "-- Set Successful";
            string expectedSongText = "-- 1. testSong (00:02)";

            //Act
            string actual = this.controller.PerformSets();

            //Assert
            Assert.IsTrue(actual.Contains(expectedEnd));
            Assert.IsTrue(actual.Contains(expectedSongText));
        }
        public void PerformSets_CannotPerform_OrderedCorrectly()
        {
            IStage stage = new Stage();

            ISet shortSet  = new Short("short");
            ISet mediumSet = new Medium("medium");
            ISet longSet   = new Long("long");

            longSet.AddSong(new Song("s1", new TimeSpan(0, 2, 0)));
            mediumSet.AddSong(new Song("s2", new TimeSpan(0, 2, 0)));
            shortSet.AddSong(new Song("s3", new TimeSpan(0, 1, 0)));

            mediumSet.AddPerformer(new Performer("penka", 123));

            stage.AddSet(shortSet);
            stage.AddSet(longSet);
            stage.AddSet(mediumSet);

            ISetController setController = new SetController(stage);

            string actualResult   = setController.PerformSets();
            string expectedResult =
                "1. medium:\r\n-- Did not perform\r\n2. long:\r\n-- Did not perform\r\n3. short:\r\n-- Did not perform";

            Assert.That(actualResult, Is.EqualTo(expectedResult));
        }
Exemplo n.º 5
0
        public void SetWithSongAndPerformer()
        {
            string expected = "1. mediumSet:" + Environment.NewLine + "-- 1. Song1 (05:00)" + Environment.NewLine + "-- Set Successful";

            string songName = "Song1";
            var    duration = new TimeSpan(0, 5, 0);
            ISong  song     = new Song(songName, duration);

            string performerName = "Pesho";
            int    age           = 20;
            var    performer     = new Performer(performerName, age);
            var    guitar        = new Guitar();

            performer.AddInstrument(guitar);

            IStage stage = new Stage();

            string setName = "mediumSet";
            ISet   set     = new Medium(setName);

            set.AddPerformer(performer);
            set.AddSong(song);
            stage.AddSet(set);

            var    setController = new SetController(stage);
            string result        = setController.PerformSets();

            Assert.That(result, Is.EqualTo(expected));
        }
Exemplo n.º 6
0
        public void SetCountInreases()
        {
            IStage         stage         = new Stage();
            IInstrument    guitar        = new Guitar();
            IInstrument    drums         = new Drums();
            ISet           set2          = new Medium("Settadfkhshdk");
            ISong          song2         = new Song("Nothing", new TimeSpan(0, 3, 0));
            ISet           set1          = new Short("Set1");
            ISong          song1         = new Song("Something", new System.TimeSpan(0, 2, 0));
            IPerformer     performer1    = new Performer("Stavri", 12);
            IPerformer     performer2    = new Performer("Genadi", 13);
            ISetController setController = new SetController(stage);

            performer2.AddInstrument(drums);
            performer1.AddInstrument(guitar);
            set1.AddPerformer(performer1);
            set1.AddSong(song1);
            set2.AddPerformer(performer2);
            set2.AddSong(song2);
            stage.AddSet(set1);
            stage.AddSet(set2);

            var result = setController.PerformSets();

            Assert.That(result.Contains("1. Settadfkhshdk"));
        }
Exemplo n.º 7
0
        public void ValidatePerformSetsMethod()
        {
            var set1       = new Short("Set1");
            var set2       = new Medium("Set2");
            var set3       = new Medium("Set3");
            var song1      = new Song("Song1", new TimeSpan(0, 10, 0));
            var song2      = new Song("Song2", new TimeSpan(0, 15, 0));
            var performer1 = new Performer("Performer1", 22);
            var performer2 = new Performer("Performer2", 22);
            var instrument = new Microphone();

            performer1.AddInstrument(instrument);
            performer2.AddInstrument(instrument);
            set1.AddSong(song1);
            set1.AddPerformer(performer1);
            set2.AddSong(song2);
            set2.AddPerformer(performer1);
            set3.AddSong(song2);
            set3.AddPerformer(performer1);
            set3.AddPerformer(performer2);
            stage.AddSet(set1);
            stage.AddSet(set2);
            stage.AddSet(set3);

            var    setController  = new SetController(stage);
            string result         = setController.PerformSets();
            string expectedResult = "1. Set3:\r\n-- 1. Song2 (15:00)\r\n-- Set Successful\r\n2. Set2:\r\n-- Did not perform\r\n3. Set1:\r\n-- Did not perform";

            Assert.That(result, Is.EqualTo(expectedResult));
        }
        public void TestOrderMultipleSong()
        {
            //Arrange
            string expectedEnd = "1. set:\r\n-- 1. firstSong (00:01)\r\n-- 2. secondSong (00:02)\r\n-- 3. thurdSong (00:03)\r\n-- Set Successful\r\n2. secondSet:\r\n-- Did not perform";

            IStage stage = new Stage();
            ISet   set   = new Medium("set");

            IPerformer performer = new Performer("pencho", 3);

            performer.AddInstrument(new Guitar());

            ISong firstSong  = new Song("firstSong", new System.TimeSpan(0, 0, 1));
            ISong secondSong = new Song("secondSong", new System.TimeSpan(0, 0, 2));
            ISong thurdSong  = new Song("thurdSong", new System.TimeSpan(0, 0, 3));

            set.AddPerformer(performer);
            set.AddSong(firstSong);
            set.AddSong(secondSong);
            set.AddSong(thurdSong);

            ISet       secondSet       = new Long("secondSet");
            IPerformer secondPerformer = new Performer("Mincho", 20);

            performer.AddInstrument(new Microphone());
            ISong secondPerformerFirstSong  = new Song("secondFirstSong", new System.TimeSpan(0, 0, 1));
            ISong secondPerformerSecondSong = new Song("secondSecondSong", new System.TimeSpan(0, 0, 2));

            secondSet.AddPerformer(secondPerformer);
            secondSet.AddSong(secondPerformerFirstSong);
            secondSet.AddSong(secondPerformerSecondSong);

            stage.AddSet(set);
            stage.AddSet(secondSet);
            this.controller = new SetController(stage);

            //Act
            string actual = this.controller.PerformSets();

            //Assert
            Assert.IsTrue(actual.Contains(expectedEnd));
        }
Exemplo n.º 9
0
        public void Test()
        {
            var stage = new Stage();

            var setController = new SetController(stage);

            var performer = new Performer("Jikata", 49);

            var song = new Song("Generation", new TimeSpan(0, 5, 0));

            var guitar = new Guitar();

            performer.AddInstrument(guitar);

            var set = new Medium("MediumSet");

            set.AddPerformer(performer);
            set.AddSong(song);

            stage.AddSet(set);

            var actualResult = setController.PerformSets();
            var expected     = "1. MediumSet:" + Environment.NewLine +
                               "-- 1. Generation (05:00)" + Environment.NewLine +
                               "-- Set Successful";

            var actualResultWear = guitar.Wear;
            var expectedWear     = 40;

            Assert.AreEqual(expectedWear, actualResultWear);
            Assert.AreEqual(expected, actualResult);


            var nullController = new SetController(null);

            Assert.That(() => nullController.PerformSets(), Throws.Exception);

            setController.PerformSets();
            var resultFromlast         = setController.PerformSets();
            var wearAfterSecondPerform = guitar.Wear;

            var expectedWeardown       = 0;
            var expectedResultFromLast = "1. MediumSet:\r\n-- Did not perform";

            Assert.AreEqual(expectedResultFromLast, resultFromlast);
            Assert.AreEqual(expectedWeardown, wearAfterSecondPerform);
        }
Exemplo n.º 10
0
        public void PerformWithOneSongShouldExecuteProperly()
        {
            ISet        set        = new Medium("setIsLit");
            IPerformer  performer  = new Performer("Goshaka", 13);
            ISong       song       = new Song("Tribute", new TimeSpan(0, 2, 30));
            IInstrument instrument = new Guitar();

            performer.AddInstrument(instrument);
            set.AddSong(song);
            set.AddPerformer(performer);

            stage.AddSet(set);
            string actualResult   = setController.PerformSets();
            string expectedResult = "1. setIsLit:\r\n-- 1. Tribute (02:30)\r\n-- Set Successful";

            Assert.That(actualResult, Is.EqualTo(expectedResult));
        }
        public void PerformSets_CanPerform_OrderedCorrectly()
        {
            IStage stage = new Stage();

            ISet shortSet  = new Short("short");
            ISet mediumSet = new Medium("medium");
            ISet longSet   = new Long("long");

            longSet.AddSong(new Song("s1", new TimeSpan(0, 2, 0)));
            mediumSet.AddSong(new Song("s2", new TimeSpan(0, 2, 0)));
            shortSet.AddSong(new Song("s3", new TimeSpan(0, 1, 0)));

            IPerformer medPerformer1 = new Performer("penka", 123);

            medPerformer1.AddInstrument(new Guitar());

            IPerformer medPerformer2 = new Performer("ivan", 23);

            medPerformer2.AddInstrument(new Guitar());
            medPerformer2.AddInstrument(new Drums());

            IPerformer shortPerformer = new Performer("pesho", 32);

            shortPerformer.AddInstrument(new Microphone());

            IPerformer longPerformer = new Performer("georgi", 211);

            longPerformer.AddInstrument(new Drums());

            longSet.AddPerformer(longPerformer);
            mediumSet.AddPerformer(medPerformer1);
            mediumSet.AddPerformer(medPerformer2);
            shortSet.AddPerformer(shortPerformer);

            stage.AddSet(shortSet);
            stage.AddSet(longSet);
            stage.AddSet(mediumSet);

            ISetController setController = new SetController(stage);

            string actualResult   = setController.PerformSets();
            string expectedResult =
                "1. medium:\r\n-- 1. s2 (02:00)\r\n-- Set Successful\r\n2. long:\r\n-- 1. s1 (02:00)\r\n-- Set Successful\r\n3. short:\r\n-- 1. s3 (01:00)\r\n-- Set Successful";

            Assert.That(actualResult, Is.EqualTo(expectedResult));
        }
Exemplo n.º 12
0
        public void WearDownShouldBeIncluded()
        {
            ISet        set        = new Medium("setIsLit");
            IPerformer  performer  = new Performer("Goshaka", 13);
            ISong       song       = new Song("Tribute", new TimeSpan(0, 2, 30));
            IInstrument instrument = new Guitar();

            performer.AddInstrument(instrument);
            set.AddSong(song);
            set.AddPerformer(performer);

            stage.AddSet(set);
            setController.PerformSets();
            setController.PerformSets();
            string actualResult   = setController.PerformSets();
            string expectedResult = "1. setIsLit:\r\n-- Did not perform";

            Assert.That(actualResult, Is.EqualTo(expectedResult));
        }
Exemplo n.º 13
0
        public void Test7()
        {
            try
            {
                IStage stage = new Stage();
                ISet   set   = new Medium("MediumSet");
                set.AddSong(new Song("newSong", new System.TimeSpan(0, 5, 0)));

                Performer peso = new Performer("Pesho", 50);
                set.AddPerformer(peso);
                stage.AddSet(set);
                SetController setController = new SetController(stage);
                string        result        = setController.PerformSets();
                Assert.That(!result.Contains("-- Set Successful"));
            }
            catch
            {
                Assert.Fail();
            }
        }
Exemplo n.º 14
0
        public void Test5()
        {
            try
            {
                IStage stage = new Stage();
                ISet   set   = new Medium("MediumSet");
                set.AddSong(new Song("newSong", new System.TimeSpan(0, 5, 0)));

                Performer peso = new Performer("Pesho", 50);
                peso.AddInstrument(new Drums());
                set.AddPerformer(peso);
                stage.AddSet(set);
                SetController setController = new SetController(stage);
                string        result        = setController.PerformSets();
                Assert.That(result.Contains("(05:00)"));
            }
            catch
            {
                Assert.Fail();
            }
        }
Exemplo n.º 15
0
        public void SetPerform()
        {
            Stage stage = new Stage();

            ISetController setController = new SetController(stage);
            Performer      performer     = new Performer("Ivan", 24);

            performer.AddInstrument(new Drums());
            stage.AddPerformer(performer);
            Song song = new Song("pesen", new TimeSpan(0, 3, 0));
            Set  set  = new Medium("Set1");

            set.AddPerformer(performer);
            set.AddSong(song);
            stage.AddSet(set);

            string result = setController.PerformSets();

            string expectedOutput = "1. Set1:\r\n-- 1. pesen (03:00)\r\n-- Set Successful";

            Assert.That(result, Is.EqualTo(expectedOutput));
        }
Exemplo n.º 16
0
        public void Test8()
        {
            try
            {
                IStage stage = new Stage();
                ISet   set   = new Medium("MediumSet");
                set.AddSong(new Song("newSong", new System.TimeSpan(0, 5, 0)));

                Performer  peso   = new Performer("Pesho", 50);
                Instrument guitar = new Guitar();
                peso.AddInstrument(guitar);
                set.AddPerformer(peso);
                stage.AddSet(set);
                SetController setController = new SetController(stage);
                string        result        = setController.PerformSets();
                Assert.That(guitar.Wear == 40);
            }
            catch
            {
                Assert.Fail();
            }
        }
Exemplo n.º 17
0
        public void TestPerformSetsSetSuccessfulMultipeSetsInstrumentsPerformersAndSongs()
        {
            ISet shortSet  = new Short("shortSet");
            ISet longSet   = new Long("longSet");
            ISet mediumSet = new Medium("mediumSet");

            IInstrument drum       = new Drums();
            IInstrument guitar     = new Guitar();
            IInstrument microphone = new Microphone();

            IPerformer nakov = new Performer("Nakov", 10);
            IPerformer vladi = new Performer("Vladi", 10);
            IPerformer bojo  = new Performer("Bojo", 10);

            nakov.AddInstrument(drum);
            nakov.AddInstrument(guitar);
            nakov.AddInstrument(microphone);

            vladi.AddInstrument(guitar);
            vladi.AddInstrument(drum);

            bojo.AddInstrument(microphone);

            ISong song  = new Song("NewSong", new TimeSpan(0, 5, 5));
            ISong song2 = new Song("NewSong2", new TimeSpan(0, 7, 5));
            ISong song3 = new Song("NewSong3", new TimeSpan(0, 1, 5));
            ISong song4 = new Song("NewSong4", new TimeSpan(0, 0, 5));

            shortSet.AddPerformer(bojo);
            shortSet.AddPerformer(nakov);
            shortSet.AddPerformer(vladi);

            mediumSet.AddPerformer(vladi);
            mediumSet.AddPerformer(nakov);
            mediumSet.AddPerformer(bojo);

            longSet.AddPerformer(vladi);
            longSet.AddPerformer(bojo);
            longSet.AddPerformer(nakov);


            shortSet.AddSong(song);
            shortSet.AddSong(song2);
            shortSet.AddSong(song3);
            shortSet.AddSong(song4);

            mediumSet.AddSong(song);
            mediumSet.AddSong(song2);
            mediumSet.AddSong(song3);
            mediumSet.AddSong(song4);

            longSet.AddSong(song);
            longSet.AddSong(song2);
            longSet.AddSong(song3);
            longSet.AddSong(song4);

            stage.AddSet(shortSet);
            stage.AddSet(mediumSet);
            stage.AddSet(longSet);

            stage.AddPerformer(nakov);
            stage.AddPerformer(bojo);
            stage.AddPerformer(vladi);

            stage.AddSong(song);
            stage.AddSong(song2);
            stage.AddSong(song3);
            stage.AddSong(song4);

            string result = setController.PerformSets();

            Assert.AreNotEqual(result, "1. shortSet:\r\n-- 1. NewSong (05:05)\r\n-- Set Successful\r\n2. mediumSet:\r\n-- Did not perform\r\n3. longSet:\r\n-- Did not perform");
        }