public void PerforSetsTest() { IStage stage = new Stage(); ISetController setController = new SetController(stage); ISet set = new Short("Set1"); ISet set2 = new Short("Set2"); stage.AddSet(set); stage.AddSet(set2); IPerformer performer = new Performer("Pesho", 23); IInstrument guitar = new Guitar(); stage.AddPerformer(performer); set.AddPerformer(performer); performer.AddInstrument(guitar); ISong song = new Song("Song1", new System.TimeSpan(0, 5, 0)); stage.AddSong(song); set.AddSong(song); string expectedResult = "1. Set1:" + "\r\n" + "-- 1. Song1 (05:00)" + "\r\n" + "-- Set Successful" + "\r\n" + "2. Set2:" + "\r\n" + "-- Did not perform"; string actualResult = setController.PerformSets(); Assert.That(actualResult, Is.EqualTo(expectedResult).NoClip); Assert.That(guitar.Wear, Is.EqualTo(40)); }
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")); }
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)); }
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)); }
public void Test() { var set1 = new Long("Set1"); var set2 = new Long("Set2"); var song1 = new Song("Song1", new System.TimeSpan(00, 01, 00)); var song2 = new Song("Song1", new System.TimeSpan(00, 02, 00)); var song3 = new Song("Song1", new System.TimeSpan(00, 03, 00)); var ivan = new Performer("Ivan", 23); var gosho = new Performer("Gosho", 21); var maria = new Performer("Maria", 18); var instuments = new IInstrument[] { new Guitar() }; var instuments2 = new IInstrument[] { new Microphone() }; var instuments3 = new IInstrument[] { new Drums() }; ivan.AddInstrument(new Guitar()); gosho.AddInstrument(new Microphone()); maria.AddInstrument(new Drums()); set1.AddPerformer(ivan); set1.AddPerformer(gosho); set1.AddPerformer(maria); set1.AddSong(song1); set1.AddSong(song2); set1.AddSong(song3); var stage = new Stage(); stage.AddSet(set1); stage.AddSet(set2); var sc = new SetController(stage); var actual = sc.PerformSets(); var sb = new StringBuilder(); sb.AppendLine($"1. Set1:"); sb.AppendLine($"-- 1. Song1 (01:00)"); sb.AppendLine($"-- 2. Song1 (02:00)"); sb.AppendLine($"-- 3. Song1 (03:00)"); sb.AppendLine($"-- Set Successful"); sb.AppendLine($"2. Set2:"); sb.AppendLine($"-- Did not perform"); var expected = sb.ToString().TrimEnd(); Assert.That(actual, Is.EqualTo(expected)); }
public void Test() { var stage = new Stage(); var setController = new SetController(stage); var set = new Short("TestSet"); var set2 = new Short("TestSet2"); stage.AddSet(set); stage.AddSet(set2); // SignUpPerformer Gosho 21 Guitar Microphone // SignUpPerformer Pesho 23 Drums // SignUpPerformer Ivan 20 Microphone var performer = new Performer("Gosho", 21); var performer2 = new Performer("Pesho", 23); var performer3 = new Performer("Ivan", 20); var performer4 = new Performer("Ivancho", 20); //RegisterSong SongName 03:00 //RegisterSong SongName2 02:00 //RegisterSong SongName4 00:01 var song = new Song("SongName", new TimeSpan(0, 3, 0)); var song2 = new Song("SongName2", new TimeSpan(0, 2, 0)); var song3 = new Song("SongName3", new TimeSpan(0, 10, 0)); var song4 = new Song("SongName4", new TimeSpan(0, 0, 1)); set.AddPerformer(performer); set.AddPerformer(performer2); set.AddPerformer(performer3); set.AddPerformer(performer4); //AddSongToSet SongName TestSet //AddSongToSet SongName2 TestSet //AddSongToSet SongName3 TestSet //AddSongToSet SongName4 TestSet set.AddSong(song); set2.AddSong(song2); set.AddSong(song3); set.AddSong(song4); stage.AddPerformer(performer); var expected = "1. TestSet: -- Did not perform 2. TestSet2: -- Did not perform"; var actual = setController.PerformSets(); Assert.AreEqual(expected, actual); }
public void WearDownWorks() { ISet set = new Short("izpulnenie"); ISong song = new Song("despacito", new TimeSpan(0, 02, 01)); set.AddSong(song); IPerformer performer = new Performer("ivan", 15); IInstrument instrument = new Drums(); performer.AddInstrument(instrument); set.AddPerformer(performer); IStage stage = new Stage(); stage.AddSet(set); ISetController setController = new SetController(stage); var expected = 80; setController.PerformSets(); var actual = instrument.Wear; Assert.AreEqual(expected, actual); }
public void WearShouldBeDifferent() { IStage stage = new Stage(); ISetController setController = new SetController(stage); IPerformer performer = new Performer("Niki", 18); performer.AddInstrument(new Guitar()); double instrumentWearBefore = performer.Instruments.First().Wear; ISet set = new Short("short1"); set.AddSong(new Song("Pesna", new TimeSpan(0, 1, 10))); set.AddPerformer(performer); stage.AddSet(set); setController.PerformSets(); FieldInfo listField = typeof(Performer).GetFields(BindingFlags.NonPublic | BindingFlags.Instance) .FirstOrDefault(p => p.Name == "instruments"); List <IInstrument> insturments = (List <IInstrument>)listField.GetValue(performer); double instrumentWearAfter = insturments[0].Wear; Assert.That(instrumentWearAfter, Is.Not.EqualTo(instrumentWearBefore)); }
public void PerformSets_CanPerform_InstrumentWearsDown() { IStage stage = new Stage(); ISet set = new Long("short"); set.AddSong(new Song("s2", new TimeSpan(0, 1, 0))); IPerformer performer = new Performer("pesho", 100); IInstrument instrument = new Drums(); performer.AddInstrument(instrument); set.AddPerformer(performer); stage.AddSet(set); ISetController setController = new SetController(stage); setController.PerformSets(); double actualResult = instrument.Wear; double expectedResult = 80; Assert.That(actualResult, Is.EqualTo(expectedResult)); }
public void PerformSetShouldDecreaseInstrumentWear() { IStage stage = new Stage(); ISetController setController = new SetController(stage); ISet set = new Short("Set1"); IPerformer performer = new Performer("Pesho", 18); IInstrument instrument = new Guitar(); performer.AddInstrument(instrument); set.AddPerformer(performer); ISong song = new Song("Zaz - Ututudu", new TimeSpan(0, 2, 32)); set.AddSong(song); stage.AddSet(set); double instrumentWearBeforePerforming = instrument.Wear; setController.PerformSets(); double instrumentWearAfterPerforming = instrument.Wear; Assert.That(instrumentWearAfterPerforming, Is.Not.EqualTo(instrumentWearBeforePerforming)); }
public void SetControllerShouldWearDownInstruments() { Performer performer = new Performer("Ivo", 26); IInstrument instrument = new Guitar(); performer.AddInstrument(instrument); ISet set = new Short("ShortSet"); set.AddPerformer(performer); ISong song = new Song("Chico loco", new TimeSpan(0, 2, 30)); set.AddSong(song); var stage = new Stage(); stage.AddPerformer(performer); stage.AddSong(song); stage.AddSet(set); var setController = new SetController(stage); var instrumentWearBefore = instrument.Wear; setController.PerformSets(); var instrumentWearAfter = instrument.Wear; Assert.AreNotEqual(instrumentWearAfter, instrumentWearBefore); }
public void TestRegisterSetWithSongs() { IPerformer performer = new Performer("Pesho", 20); IInstrument instrument = new AKG(); performer.AddInstrument(instrument); TimeSpan span = new TimeSpan(0, 0, 5, 5, 0); ISong song = new Song("AAA", span); ISet shortSet = new Short("shortSet"); shortSet.AddSong(song); shortSet.AddPerformer(performer); IStage testStage = new Stage(); testStage.AddSet(shortSet); SetController testController = new SetController(testStage); string result = testController.PerformSets(); Assert.That(result, Is.EqualTo("1. shortSet:\r\n-- 1. AAA (05:05)\r\n-- Set Successful")); }
public void PerformSets_WearDownTest() { IStage stage = new Stage(); ISetController controller = new SetController(stage); ISet set = new Short("Set1"); stage.AddSet(set); IPerformer performer = new Performer("Sonny", 22); IInstrument guitar = new Guitar(); performer.AddInstrument(guitar); set.AddPerformer(performer); ISong song = new Song("Song", new TimeSpan(0, 3, 24)); set.AddSong(song); var wearBeforeWearDown = guitar.Wear; controller.PerformSets(); var afterWearDownWear = guitar.Wear; Assert.That(wearBeforeWearDown, Is.Not.EqualTo(afterWearDownWear)); }
public void TestCanPerformReturnsTrue() { IStage stage = new Stage(); ISet set = new Short("Shorty"); stage.AddSet(set); IPerformer perf = new Performer("HrupHrupAzSumTup", 22); perf.AddInstrument(new Guitar()); stage.AddPerformer(perf); ISong song = new Song("hrup", new System.TimeSpan(0, 5, 0)); stage.AddSong(song); set.AddSong(song); set.AddPerformer(perf); ISetController setController = new SetController(stage); setController.PerformSets(); Assert.That(() => stage.Sets.First().CanPerform(), Is.EqualTo(true)); }
public void TestPerformanceSuccessful() { IStage stage = new Stage(); ISet set = new Short("Shorty"); stage.AddSet(set); IPerformer perf = new Performer("HrupHrupAzSumTup", 22); perf.AddInstrument(new Guitar()); stage.AddPerformer(perf); ISong song = new Song("hrup", new System.TimeSpan(0, 5, 0)); stage.AddSong(song); set.AddSong(song); set.AddPerformer(perf); ISetController setController = new SetController(stage); setController.PerformSets(); Assert.That(() => setController.PerformSets(), Is.EqualTo("1. Shorty:\r\n" + "-- 1. hrup (05:00)\r\n" + "-- Set Successful")); }
public void TestInstrumentWearsDownAfterPerformance() { IStage stage = new Stage(); ISet set = new Short("Shorty"); stage.AddSet(set); IPerformer perf = new Performer("HrupHrupAzSumTup", 22); perf.AddInstrument(new Guitar()); stage.AddPerformer(perf); ISong song = new Song("hrup", new System.TimeSpan(0, 5, 0)); stage.AddSong(song); set.AddSong(song); set.AddPerformer(perf); ISetController setController = new SetController(stage); setController.PerformSets(); Assert.That(perf.Instruments.First().Wear, Is.EqualTo(40)); }
public void TestWithBrokenInstrument() { //Arrange string expected = "-- Did not perform"; IStage stage = new Stage(); ISet set = new Long("testSet"); IPerformer performer = new Performer("pencho", 3); performer.AddInstrument(new Microphone()); ISong song = new Song("testSong", new System.TimeSpan(0, 1, 2)); set.AddPerformer(performer); set.AddSong(song); stage.AddSet(set); this.controller = new SetController(stage); this.controller.PerformSets(); this.controller.PerformSets(); //Act string actual = this.controller.PerformSets(); //Assert Assert.IsTrue(actual.Contains(expected)); }
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 PerformCommandReturnsSuccessResult() { IStage stage = new Stage(); ISet set = new Short("Set1"); TimeSpan duration = TimeSpan.FromSeconds((1 * 60) + 2); ISong song = new Song("Song1", duration); IPerformer performer = new Performer("Gosho", 20); performer.AddInstrument(new Guitar()); set.AddPerformer(performer); set.AddSong(song); stage.AddSong(song); stage.AddSet(set); stage.AddSong(song); stage.AddPerformer(performer); ISetController setController = new SetController(stage); string actual = "1. Set1:\r\n-- 1. Song1 (01:02)\r\n-- Set Successful"; string expected = setController.PerformSets(); Assert.AreEqual(actual, expected); }
public void TestWhetherTheControllerGivesCorrectOutput() { var set1 = new Short("set1"); var performer = new Performer("Bat nasko", 30); var instrument = new Guitar(); performer.AddInstrument(instrument); var song = new Song("name", new TimeSpan(0, 0, 10, 0)); var stage = new Stage(); set1.AddPerformer(performer); set1.AddSong(song); stage.AddSet(set1); stage.AddPerformer(performer); stage.AddSong(song); var controller = new SetController(stage); var stringOutput = controller.PerformSets(); var expectedResult = "1. set1:\r\n-- 1. name (10:00)\r\n-- Set Successful"; Assert.AreEqual(expectedResult, stringOutput); }
public void TestInstrumentsGetBroken() { IStage stage = new Stage(); ISet set = new Short("Set1"); TimeSpan duration = TimeSpan.FromSeconds((1 * 60) + 2); ISong song = new Song("Song1", duration); IPerformer performer = new Performer("Gosho", 20); IInstrument instrument = new Guitar(); instrument.WearDown(); instrument.WearDown(); performer.AddInstrument(instrument); set.AddPerformer(performer); set.AddSong(song); stage.AddSong(song); stage.AddSet(set); stage.AddSong(song); stage.AddPerformer(performer); ISetController setController = new SetController(stage); string actual = "1. Set1:\r\n-- Did not perform"; string expected = setController.PerformSets(); Assert.AreEqual(actual, expected); }
public void TestWhetherTheControllerFailsToPerform() { var set1 = new Short("set1"); var performer = new Performer("Woah", 39); var instrument = new Microphone(); performer.AddInstrument(instrument); var song = new Song("WoahButSong", new TimeSpan(0, 0, 5, 0)); var stage = new Stage(); set1.AddPerformer(performer); set1.AddSong(song); stage.AddSet(set1); stage.AddPerformer(performer); stage.AddSong(song); var controller = new SetController(stage); controller.PerformSets(); controller.PerformSets(); var stringOutput = controller.PerformSets(); var expectedResult = "1. set1:\r\n-- Did not perform"; Assert.AreEqual(expectedResult, stringOutput); }
public void TestControllerDidNotPerformSetWithBrokenInstruments() { var set1 = new Short("set1"); var performer = new Performer("Danny", 38); var instrument = new Microphone(); performer.AddInstrument(instrument); var song = new Song("name", new TimeSpan(0, 0, 5, 0)); var stage = new Stage(); set1.AddPerformer(performer); set1.AddSong(song); stage.AddSet(set1); stage.AddPerformer(performer); stage.AddSong(song); var controller = new SetController(stage); controller.PerformSets(); controller.PerformSets(); var stringOutput = controller.PerformSets(); var expected = "1. set1:" + Environment.NewLine + "-- Did not perform"; Assert.AreEqual(expected, stringOutput); }
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 SetControllerShouldReturnSuccessMessage() { var stage = new Stage(); var performer = new Performer("Ivo", 26); IInstrument instrument = new Guitar(); performer.AddInstrument(instrument); stage.AddPerformer(performer); // ISong song = new Song("Chico loco", new TimeSpan(0, 2, 30)); stage.AddSong(song); // ISet set = new Short("ShortSet"); stage.AddSet(set); var setController = new SetController(stage); var actualResult = setController.PerformSets(); var expectedResult = "1. ShortSet:\r\n-- Did not perform"; Assert.AreEqual(expectedResult, actualResult); }
public void Test2() { var stage = new Stage(); stage.AddSet(new Medium(nameof(Medium))); var songName = "song1"; var mediumSet = nameof(Medium); var performer = new Performer("performer", 22); var guitar = new Guitar(); performer.AddInstrument(guitar); var song = new Song(songName, new System.TimeSpan(0, 2, 22)); stage.AddSong(song); var set = stage.GetSet(mediumSet); set.AddSong(song); set.AddSong(song); set.AddSong(song); set.AddSong(song); set.AddSong(song); set.AddPerformer(performer); var setController = new SetController(stage); var result = setController.PerformSets().Split(System.Environment.NewLine); }
public void PerfrormSets_ShouldDecrease_InstrumentWear() { //Arrange IStage stage = new Stage(); ISetController setController = new SetController(stage); ISet set = new Short("Set1"); IPerformer performer = new Performer("Gaga", 29); ISong song = new Song("Song", new TimeSpan(0, 2, 30)); IInstrument instrument = new Guitar(); //Act performer.AddInstrument(instrument); set.AddPerformer(performer); set.AddSong(song); stage.AddSet(set); double instrumentWearBefore = instrument.Wear; setController.PerformSets(); double instrumentWearAfter = instrument.Wear; //Assert Assert.That(instrumentWearAfter, Is.Not.EqualTo(instrumentWearBefore)); }
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)); }
public void PerformSetsShouldWearDownInstrument() { Stage stage = new Stage(); SetController setController = new SetController(stage); Set set = new Short("WestSet"); IPerformer performer = new Performer("Name", 18); Song song = new Song("SongName", new TimeSpan(0, 2, 30)); Instrument instrument = new Microphone(); performer.AddInstrument(instrument); set.AddSong(song); set.AddPerformer(performer); stage.AddSet(set); stage.AddPerformer(performer); setController.PerformSets(); var currPerformer = stage.GetPerformer("Name"); var instruments = currPerformer.Instruments; var actual = instruments.First().Wear; var expected = 20; Assert.AreEqual(expected, actual); }
public void Test() { IStage stage = new Stage(); ISetController setController = new SetController(stage); //IInstrument instrument = new Guitar(); IPerformer performer = new Performer("Gosho", 24); //performer.AddInstrument(instrument); stage.AddPerformer(performer); ISong song = new Song("Rocks down", new TimeSpan(0, 0, 0, 55)); stage.AddSong(song); ISet set = new Long("Set1"); set.AddPerformer(performer); set.AddSong(song); stage.AddSet(set); string result = setController.PerformSets(); Assert.AreEqual("1. Set1:\r\n-- Did not perform", result); }