public static string Apply(string input, string command) { switch (command) { case nameof(DiacriticsCommand): return(DiacriticsCommand.DiacriticsLogic(input, ToggleMode.Apply)); case nameof(DoubleCommand): return(DoubleCommand.DoubleLogic(input, ToggleMode.Apply)); case nameof(InvertCaseCommand): return(InvertCaseCommand.InvertCaseLogic(input)); case nameof(PaddingCommand): return(PaddingCommand.PaddingLogic(input, ToggleMode.Apply)); case nameof(ReverseCommand): return(ReverseCommand.ReverseLogic(input)); case nameof(SurroundCommand): return(SurroundCommand.SurroundLogic(input, ToggleMode.Apply)); default: return(input); } }
public void AddPadding_WhereAlreadyHasSurrounds() { var origin = "Original String"; var withSurrounds = SurroundCommand.SurroundLogic(origin, ToggleMode.Apply); var withPadding = PaddingCommand.PaddingLogic(withSurrounds, ToggleMode.Apply); Assert.AreEqual("[! O-r-i-g-i-n-a-l S-t-r-i-n-g !]", withPadding); }
public void CallingApplyMultipleTimesHasNoEffect() { var origin = "Original String"; var once = SurroundCommand.SurroundLogic(origin, ToggleMode.Apply); var twice = SurroundCommand.SurroundLogic(origin, ToggleMode.Apply); twice = SurroundCommand.SurroundLogic(twice, ToggleMode.Apply); Assert.AreEqual(once, twice); }
public void CanAddAndRemoveToggleActionsInDifferentOrder() { var origin = "Original String"; var modifiedStep1 = SurroundCommand.SurroundLogic(origin, ToggleMode.Apply); var modifiedStep2 = DiacriticsCommand.DiacriticsLogic(modifiedStep1, ToggleMode.Apply); var modifiedStep3 = DoubleCommand.DoubleLogic(modifiedStep2, ToggleMode.Apply); var modifiedStep4 = ReverseCommand.ReverseLogic(modifiedStep3); var modifiedStep5 = PaddingCommand.PaddingLogic(modifiedStep4, ToggleMode.Apply); var modifiedStep6 = InvertCaseCommand.InvertCaseLogic(modifiedStep5); var modifiedStep7 = DiacriticsCommand.DiacriticsLogic(modifiedStep6, ToggleMode.Reverse); var modifiedStep8 = SurroundCommand.SurroundLogic(modifiedStep7, ToggleMode.Reverse); var modifiedStep9 = DoubleCommand.DoubleLogic(modifiedStep8, ToggleMode.Reverse); var modifiedStep10 = ReverseCommand.ReverseLogic(modifiedStep9); var modifiedStep11 = InvertCaseCommand.InvertCaseLogic(modifiedStep10); var finalResult = PaddingCommand.PaddingLogic(modifiedStep11, ToggleMode.Reverse); Assert.AreEqual(origin, finalResult); }
public void CanHandleNull() { var actual = SurroundCommand.SurroundLogic(null, ToggleMode.Apply); Assert.AreEqual(null, actual); }
public void DoNotAddIfThere() { var actual = SurroundCommand.SurroundLogic("[! abc !]", ToggleMode.Apply); Assert.AreEqual("[! abc !]", actual); }
public void AlreadyHasAtEnd() { var actual = SurroundCommand.SurroundLogic("abc !]", ToggleMode.Apply); Assert.AreEqual("[! abc !] !]", actual); }
public void DoNotRemoveIfNotThere() { var actual = SurroundCommand.SurroundLogic("abc", ToggleMode.Reverse); Assert.AreEqual("abc", actual); }
public void HasBoth() { var actual = SurroundCommand.SurroundLogic("[! abc !]", ToggleMode.Reverse); Assert.AreEqual("abc", actual); }
public void HasNone() { var actual = SurroundCommand.SurroundLogic("abc", ToggleMode.Apply); Assert.AreEqual("[! abc !]", actual); }
public void CanHandleToggleModeNotSet() { var actual = SurroundCommand.SurroundLogic("Something", ToggleMode.NotSet); Assert.AreEqual("Something", actual); }
public void CanHandleWhiteSpace() { var actual = SurroundCommand.SurroundLogic(" ", ToggleMode.Apply); Assert.AreEqual(" ", actual); }
public void CanHandleEmptyString() { var actual = SurroundCommand.SurroundLogic(string.Empty, ToggleMode.Apply); Assert.AreEqual(string.Empty, actual); }