/// <summary> /// Adds an instance of the given type between every list of elements /// in the list. Does not add any new elements to the immediate start of end. /// </summary> protected List<IMorseBlock> AddSeparatorsToList(IEnumerable<List<IMorseBlock>> list, IMorseBlock separator) { var newList = new List<IMorseBlock>(); foreach (var item in list) { newList.AddRange(item); newList.Add(separator); } newList.RemoveAt(newList.Count - 1); return newList; }
private void AddFrame(Settings settings, IMorseBlock block) { AddFrame() .WithRepeated(settings.RepeatMessage) .WithFrameLength(block.Length * settings.UnitLength); if (settings.LightsEnabled) { WithLightSection(GetLightSection(block.Enabled, settings.Colour)); } if (settings.RumblesEnabled) { WithRumbleSection(GetRumbleSection(block.Enabled, settings.Rumble)); } }
public void AddFrameFromMorseBlock_AddsExpectedFrame(IMorseBlock block) { var frames = frameBuilder.AddFrames(settings, new List<IMorseBlock>() { block }) .Build(); var colour = block.Enabled ? settings.Colour : DefaultLights.Off; var rumble = block.Enabled ? settings.Rumble : DefaultRumbles.Off; Assert.AreEqual(1, frames.Count); var frame = frames.Single(); Assert.IsNull(frame.FanSection); Assert.IsNotNull(frame.LightSection); Assert.IsNotNull(frame.RumbleSection); Assert.AreEqual(block.Length * settings.UnitLength, frame.Length); Assert.AreEqual(colour, frame.LightSection.GetComponentSectionInDirection(eDirection.North)); Assert.AreEqual(rumble, frame.RumbleSection.Rumbles.Single()); }
public new List<IMorseBlock> AddSeparatorsToList(IEnumerable<List<IMorseBlock>> list, IMorseBlock separator) { return base.AddSeparatorsToList(list, separator); }