public void RegisterSetTest() { ISet set = new Short("Set1"); IStage stage = new Stage(); int hours1 = 0; int minutes1 = 1; int seconds1 = 2; TimeSpan songDuration1 = new TimeSpan(hours1, minutes1, seconds1); ISong song = new Song("Song1", songDuration1); int hours2 = 0; int minutes2 = 1; int seconds2 = 2; TimeSpan songDuration2 = new TimeSpan(hours2, minutes2, seconds2); ISong song2 = new Song("Song2", songDuration2); IPerformer performer1 = new Performer("Gosho", 24); Drums drum = new Drums(); performer1.AddInstrument(drum); IPerformer performer2 = new Performer("Pesho", 19); Guitar guitar = new Guitar(); Drums drum2 = new Drums(); performer2.AddInstrument(guitar); set.AddPerformer(performer1); set.AddPerformer(performer2); set.AddSong(song); set.AddSong(song2); stage.AddSet(set); stage.AddSong(song); stage.AddSong(song2); stage.AddPerformer(performer1); stage.AddPerformer(performer2); SetController setController = new SetController(stage); string expected = "1. Set1:" + Environment.NewLine + "-- 1. Song1 (01:02)" + Environment.NewLine + "-- 2. Song2 (01:02)" + Environment.NewLine + "-- Set Successful"; string actual = setController.PerformSets(); 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 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 InstrumentsWearDown() { IStage stage = new Stage(); ISet set = new Short("Short"); ISong song = new Song("Song1", new TimeSpan(0, 1, 2)); IPerformer performer = new Performer("Ivan", 20); performer.AddInstrument(new Guitar()); set.AddSong(song); set.AddPerformer(performer); stage.AddSet(set); SetController setController = new SetController(stage); setController.PerformSets(); int expectedResult = 40; Assert.That(performer.Instruments.First().Wear, Is.EqualTo(expectedResult)); }
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 TestSetPerform() { var set = new Short("Set1"); var instrumentGuitar = new Guitar(); var instrumentDrums = new Drums(); var performer = new Performer("Ivan", 23); var song1 = new Song("Song1", new TimeSpan(0, 1, 1)); this.stage.AddSet(set); performer.AddInstrument(instrumentGuitar); performer.AddInstrument(instrumentDrums); set.AddPerformer(performer); set.AddSong(song1); var actual = this.setController.PerformSets(); var expected = $@"1. Set1: -- 1. Song1 (01:01) -- Set Successful"; var actualInstrumentWear = instrumentGuitar.Wear; var expectedInstrumentWear = 40; Assert.That(actual, Is.EqualTo(expected)); Assert.That(actualInstrumentWear, Is.EqualTo(expectedInstrumentWear)); }
public void InstrumentsWearTest() { ISet set = new Short("Set1"); this.stage.AddSet(set); ISong song = new Song("Song1", new System.TimeSpan(0, 5, 0)); this.stage.AddSong(song); set.AddSong(song); IPerformer performer = new Performer("Gosho", 20); performer.AddInstrument(new Guitar()); this.stage.AddPerformer(performer); set.AddPerformer(performer); this.setController.PerformSets(); FieldInfo instrumentsInfo = typeof(Performer).GetFields(BindingFlags.NonPublic | BindingFlags.Instance) .First(f => f.FieldType == typeof(List <IInstrument>)); List <IInstrument> instruments = ((List <IInstrument>)instrumentsInfo.GetValue(performer)).Take(1).ToList(); IInstrument instrument = instruments[0]; Assert.That(instrument.Wear, Is.EqualTo(40)); }
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 SetControllerPerformsSetsInTheCorrectOrder() { var set1 = new Short("Set1"); var set2 = new Medium("Set2"); var performer1 = new Performer("Ivan", 20); var performer2 = new Performer("Gosho", 24); var performer3 = new Performer("Pesho", 19); var guitar = new Guitar(); var drums = new Drums(); var microphone = new Microphone(); var song1 = new Song("Song1", new TimeSpan(0, 1, 2)); performer1.AddInstrument(guitar); performer2.AddInstrument(drums); performer3.AddInstrument(microphone); this.stage.AddPerformer(performer1); this.stage.AddPerformer(performer2); this.stage.AddPerformer(performer3); this.stage.AddSong(song1); set1.AddSong(song1); set1.AddPerformer(performer2); set1.AddPerformer(performer3); this.stage.AddSet(set1); this.stage.AddSet(set2); Assert.That(setController.PerformSets(), Is.EqualTo(this.PerformSets())); }
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 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 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 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 PerformSetsShouldWearDownInstrument() { // Arrange ISet set1 = new Short("Set1"); this.stage.AddSet(set1); IPerformer performer = new Performer("Ivan", 20); IInstrument instrument = new Guitar(); performer.AddInstrument(instrument); this.stage.AddPerformer(performer); set1.AddPerformer(performer); ISong song = new Song("Song1", new TimeSpan(0, 1, 2)); set1.AddSong(song); // Act string result = this.setController.PerformSets(); // Assert double actualWear = instrument.Wear; Assert.That(actualWear, Is.EqualTo(40)); }
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 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 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 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 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 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 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 TestMessageWhenSetIsSuccessful() { IInstrument instrument = new Guitar(); IPerformer performer = new Performer("Ivan", 20); performer.AddInstrument(instrument); ISong song = new Song("Song1", new TimeSpan(0, 1, 2)); this.stage.AddSong(song); ISet set = new Short("Set1"); set.AddPerformer(performer); set.AddSong(song); this.stage.AddSet(set); string actual = this.setController.PerformSets().Trim(); string expected = "1. Set1:" + Environment.NewLine + "-- 1. Song1 (01:02)" + Environment.NewLine + "-- Set Successful"; Assert.That(actual, Is.EqualTo(expected)); }
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 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 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 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 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 TestPerformSetsSetThrowsError() { 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(52, 7, 5)); ISong song3 = new Song("NewSong3", new TimeSpan(1, 1, 5)); ISong song4 = new Song("NewSong4", new TimeSpan(5, 5, 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); Assert.Throws <InvalidOperationException>(() => { shortSet.AddSong(song2); }); }
public void AddPerformer_WithoutInstrumunet_SouldNotPerform() { ISet set = new Short("Seta"); IPerformer performer = new Performer("Hasan", 12); ISong song = new Song("", new System.TimeSpan(00, 01, 20)); set.AddPerformer(performer); set.AddSong(song); this.stage.AddSet(set); var expected = "1. Seta:\r\n-- Did not perform"; var actual = this.controller.PerformSets(); Assert.That(actual, Is.EqualTo(expected)); }