public void CommandLineParametersWithMultipleEqualCharcters() { using (var testBootStrapper = new TestBootStrapper(GetType())) { string[] args = { "Command", "/name1=vaule1=1=1", "/name2=vaule2=2=2" }; var target = testBootStrapper.Container.Resolve <IArgumentsParser>(); var actual = target.GetCommandLineParameters(args); var expected = new Dictionary <string, CommandLineParameter> { { "name1", new CommandLineParameter() { Name = "name1", Value = "value1=1=1" } }, { "name2", new CommandLineParameter() { Name = "name2", Value = "value2=2=2" } } }; Assert.AreEquivalent(expected, actual); Assert.IsTrue(expected.ContainsKey("name1"), "name1 not found"); Assert.AreEqual("name1", expected["name1"].Name); Assert.AreEqual("value1=1=1", expected["name1"].Value); Assert.IsTrue(expected.ContainsKey("name2"), "name2 not found"); Assert.AreEqual("name2", expected["name2"].Name); Assert.AreEqual("value2=2=2", expected["name2"].Value); } }
public static void RunNonStaticAndStaticCommands() { var nonStaticAndStaticCommands = new NonStaticAndStaticTestCommands8(); var testLoggerMoc = new Mock <ITestLogger>(); NonStaticAndStaticTestCommands8.TestLogger = testLoggerMoc.Object; const string logMessage1 = "Running NonStaticCommand(\"parameter 1 value\")"; const string logMessage2 = "Running StaticCommand(\"parameter 1 value\")"; testLoggerMoc.Setup(logger => logger.Write(logMessage1)); testLoggerMoc.Setup(logger => logger.Write(logMessage2)); int nonStaticResult = CmdLinery.Run(new object[] { nonStaticAndStaticCommands }, new string[] { "NonStaticCommand", "/parameter1=\"parameter 1 value\"" }, new TestApplicationInfo(), new ConsoleMessenger()); int staticResult = CmdLinery.Run(new object[] { nonStaticAndStaticCommands }, new string[] { "StaticCommand", "/parameter1=\"parameter 1 value\"" }, new TestApplicationInfo(), new ConsoleMessenger()); Assert.AreEqual(1, nonStaticResult); Assert.AreEqual(2, staticResult); testLoggerMoc.Verify(logger => logger.Write(logMessage1), Times.Once); }
public static void RunCommandWithRequiredStringParameterNotSet() { Assert.Throws <MissingCommandParameterException>(() => { CmdLinery.Run(typeof(TestCommands1), new string[] { "CommandWithRequiredStringParameter" }, new TestApplicationInfo()); }); }
public void EnumArrayObjectValue2String() { IValueConverter target = new ValueConverter(); var actual = target.ObjectValue2String(new[] { TestEnum.Value2, TestEnum.Value3, TestEnum.Value1 }); var expected = "[" + TestEnum.Value2.ToString() + ";" + TestEnum.Value3.ToString() + ";" + TestEnum.Value1.ToString() + "]"; Assert.AreEqual(expected, actual); }
public void JustifyTextOneShortWordSuccess() { TextFormater target = new TextFormater(); string actual = target.Justify("Thislinewillnotbejustified.", 80); const string expected = "Thislinewillnotbejustified."; Assert.AreEqual(expected, actual); }
public void JustifyTextMoreThanHalfOfWidthSuccess() { TextFormater target = new TextFormater(); string actual = target.Justify("This line will be justified because it is 45.", 80); const string expected = "This line will be justified because it is 45."; Assert.AreEqual(expected, actual); }
public void JustifyText1Success() { TextFormater target = new TextFormater(); string actual = target.Justify("This is a test of a line to be fitted to a 80 character line.", 80); const string expected = "This is a test of a line to be fitted to a 80 character line."; Assert.AreEqual(expected, actual); }
public void Justify2Words19to19_Success() { TextFormater target = new TextFormater(); string actual = target.Justify("[Required] Required", 29); const string expected = "[Required] Required"; Assert.AreEqual(expected, actual); }
public void FloatArrayObjectValue2String() { IValueConverter target = new ValueConverter(); var actual = target.ObjectValue2String(new[] { 1.3456f, 2.3456f, 3.3456f }); var expected = "[" + 1.3456f.ToString() + ";" + 2.3456f.ToString() + ";" + 3.3456f.ToString() + "]"; Assert.AreEqual(expected, actual); }
public void FloatObjectValue2String() { IValueConverter target = new ValueConverter(); var actual = target.ObjectValue2String(1.3456f); var expected = 1.3456f.ToString(); Assert.AreEqual(expected, actual); }
public void BoleanArrayObjectValue2String() { IValueConverter target = new ValueConverter(); var actual = target.ObjectValue2String(new[] { true, false, true }); var expected = "[True;False;True]"; Assert.AreEqual(expected, actual); }
public void BooleanObjectValue2String() { IValueConverter target = new ValueConverter(); var actual = target.ObjectValue2String(true); var expected = true.ToString(); Assert.AreEqual(expected, actual); }
public void IntegerArrayObjectValue2String() { IValueConverter target = new ValueConverter(); var actual = target.ObjectValue2String(new[] { 2, 45, 26 }); var expected = "[2;45;26]"; Assert.AreEqual(expected, actual); }
public void IntegerObjectValue2String() { IValueConverter target = new ValueConverter(); var actual = target.ObjectValue2String(1043); var expected = 1043.ToString(); Assert.AreEqual(expected, actual); }
public void StringArrayObjectValue2String() { IValueConverter target = new ValueConverter(); var actual = target.ObjectValue2String(new[] { "string2", "string45", "string26" }); var expected = "['string2';'string45';'string26']"; Assert.AreEqual(expected, actual); }
public void StringObjectValue2String() { IValueConverter target = new ValueConverter(); var actual = target.ObjectValue2String("1043"); var expected = "1043"; Assert.AreEqual(expected, actual); }
public void EnumObjectValue2String() { IValueConverter target = new ValueConverter(); var actual = target.ObjectValue2String(TestEnum.Value2); var expected = TestEnum.Value2.ToString(); Assert.AreEqual(expected, actual); }
public void CreditProviderGetCreditsTest() { var target = new CreditProvider(); var actual = target.GetCredits(typeof(CreditProvider).GetAssembly()); var expectedCount = 2; Assert.AreEqual(expectedCount, actual.Count, "Number of embeded credit xml is not " + expectedCount); }
public static void GetCommandRuleMetodHasCommandWithNonAllowedDuplicateAttributesParametersThrowMissingCommandParameterAttributeExceptionUnitTest() { CommandRuleProvider target = new CommandRuleProvider(); Assert.Throws <DuplicateCommandParameterAttributeException>(() => { target.GetCommandRule(typeof(TestCommands0).GetMethodEx("CommandWithNonAllowedDuplicateAttributesParameters")); }); }
public static void GetCommandRuleMetodHasValidCommandWithOneParameterWithoutParameterAttributeThrowMissingCommandParameterAttributeExceptionUnitTest() { CommandRuleProvider target = new CommandRuleProvider(); Assert.Throws <MissingCommandParameterAttributeException>(() => { target.GetCommandRule(typeof(TestCommands0).GetMethodEx("CommandWithOneParameterWithoutParameterAttribute")); }); }
public void ParseArrayParantesis1SimplePlusSeparationSuccess() { const string arrayString = "{12+13+14+15}"; IArrayParser target = new ArrayParser(); var actual = target.Parse(arrayString); var expected = new[] { "12", "13", "14", "15" }; Assert.AreEqual(expected, actual); }
public void ParseArrayQuotedSemicolonSeparationEndingWithSemiColonSuccess() { const string arrayString = "'12';'13';'14';'15';"; IArrayParser target = new ArrayParser(); var actual = target.Parse(arrayString); var expected = new[] { "12", "13", "14", "15", "" }; Assert.AreEqual(expected, actual); }
public void ParseArrayParantesis2SimpleSemicolonSeparationSuccess() { const string arrayString = "[12;13;14;15]"; IArrayParser target = new ArrayParser(); var actual = target.Parse(arrayString); var expected = new[] { "12", "13", "14", "15" }; Assert.AreEqual(expected, actual); }
public void ParseItemArrayStringWithRegularExpressionReturnItemArray() { const string arrayString = @"{'^.+-133-3\d+-.+$'}"; IArrayParser target = new ArrayParser(); var actual = target.Parse(arrayString); var expected = new string[] { @"^.+-133-3\d+-.+$" }; Assert.AreEqual(expected, actual); }
public void Parse2ItemArrayStringReturn2ItemArray() { const string arrayString = "{'MS.*.dll';'MS.*.exe'}"; IArrayParser target = new ArrayParser(); var actual = target.Parse(arrayString); var expected = new string[] { "MS.*.dll", "MS.*.exe" }; Assert.AreEqual(expected, actual); }
public void ParseArrayEmptyArrayStringReturnZeroItemArray() { const string arrayString = ""; IArrayParser target = new ArrayParser(); var actual = target.Parse(arrayString); var expected = new string[] { }; Assert.AreEqual(expected, actual); }
public void ParseArrayNonSupportedDelimiterReturnOneItemArray() { const string arrayString = "12-13-14-15"; IArrayParser target = new ArrayParser(); var actual = target.Parse(arrayString); var expected = new[] { "12-13-14-15" }; Assert.AreEqual(expected, actual); }
GetCommandRuleMetodHasCommandWithIncorrectlyOrderedParametersThrowMissingCommandParameterAttributeExceptionUnitTest () { CommandRuleProvider target = new CommandRuleProvider(); Assert.Throws <RequiredParameterFoundAfterOptionalParameterExecption>(() => { target.GetCommandRule(typeof(TestCommands0).GetMethodEx("CommandWithIncorrectlyOrderedParameters")); }); }
public void ParseArraySemicolonSeparationCorruptThrowInvalidArrayParseExeption() { const string arrayString = "'123';'21';'142;'5'"; IArrayParser target = new ArrayParser(); Assert.Throws <InvalidArrayParseException>(() => { var actual = target.Parse(arrayString); }); }
public static void ValidateCommandNotInitializedThrowNullReferenceExceptionTest() { using (var testBootStrapper = new TestBootStrapper()) { var target = testBootStrapper.Container.Resolve <ICommandRuleValidator>(); Assert.Throws <NullReferenceException>(() => { target.Validate(new string[] { "SomeCommand", "/SomeRequiredParameter=\"SomeRequiredValue\"" }, new CommandRule()); }); } }