public void ShouldFormatString() { var conf = new NamingRuleConfiguration { Parameters = new[] { "Testing{0}" } }; this.NamingRule.Execute("FormatNaming", conf).Should().Be("TestingFormatNaming"); }
public void ShouldSeparateWithMultipleChars() { var conf = new NamingRuleConfiguration { Parameters = new[] { "xx" } }; this.NamingRule.Execute("SeparateWordsNaming", conf).Should().Be("SeparatexxWordsxxNaming"); }
public void ShouldFailWithInvalidParameters(string[] param) { var conf = new NamingRuleConfiguration { Parameters = param }; this.NamingRule.Invoking(x => x.Execute("Name", conf)).Should().Throw <Exception>().WithMessage("Format rule has only 1 argument, the format string."); }
public void ShouldReplaceString() { var conf = new NamingRuleConfiguration { Parameters = new[] { "REPLACE", "ReplaceNaming" } }; this.NamingRule.Execute("TestingREPLACE", conf).Should().Be("TestingReplaceNaming"); }
public void ShouldSeparateWithDash() { var conf = new NamingRuleConfiguration { Parameters = new[] { "-" } }; this.NamingRule.Execute("SeparateWordsNaming", conf).Should().Be("Separate-Words-Naming"); }
public void ShouldFailWithInvalidParameters(string[] param) { var conf = new NamingRuleConfiguration { Parameters = new[] { "FirstParam", "SecondParam" } }; Action execute = () => this.NamingRule.Execute("Name", conf); execute.Should().Throw <Exception>().WithMessage("Lower Case rule does not have parameters."); }
public void ShouldFailWithInvalidParameters(string[] param) { var conf = new NamingRuleConfiguration { Parameters = param }; Action execute = () => this.NamingRule.Execute("Name", conf); execute.Should().Throw <Exception>().WithMessage("Replace rule Has only 2 arguments, the string to be replaced, and the value to replace for."); }
public string Execute(string name, NamingRuleConfiguration configuration) { if (configuration.Parameters.Length != 1) { throw new Exception("Format rule has only 1 argument, the format string."); } return(string.Format(configuration.Parameters[0], name)); }
public string Execute(string name, NamingRuleConfiguration configuration) { if (configuration.Parameters.Length != 0) { throw new Exception("Upper Case rule does not have parameters."); } return(name.ToUpperInvariant()); }
public void ShouldFailWithInvalidParameters(string[] param) { var conf = new NamingRuleConfiguration { Parameters = param }; Action execute = () => this.NamingRule.Execute("Name", conf); execute.Should().Throw <Exception>().WithMessage("Separate Words rule has only 1 argument, the separator string."); }
public string Execute(string name, NamingRuleConfiguration configuration) { if (configuration.Parameters.Length != 2) { throw new Exception("Replace rule Has only 2 arguments, the string to be replaced, and the value to replace for."); } return(name.Replace(configuration.Parameters[0], configuration.Parameters[1])); }
public string Execute(string name, NamingRuleConfiguration configuration) { if (configuration.Parameters.Length != 1) { throw new Exception("Separate Words rule has only 1 argument, the separator string."); } var separator = configuration.Parameters[0]; var result = string.Empty; for (var index = 0; index < name.Length; index++) { var c = name[index]; if (char.IsUpper(c) && index != 0) { result += separator; } result += c; } return(result); }