public RemoveCharactersViewModel() { _fromPos = "0"; _toPos = "0"; _strategy = new RemoveCharactersStrategy(0, true, 0, true); DisplayName = "Remove Characters"; }
public void TestRemoveCharactersStrategy() { var row = TestContext.DataRow; // extract csv data string name = row["Name"].ToString(); string extension = row["Extension"].ToString(); int from = Int32.Parse(row["From"].ToString()); int to = Int32.Parse(row["To"].ToString()); bool fromLeft = row["FromLeft"].ToString() == "Y"; bool toLeft = row["ToLeft"].ToString() == "Y"; string expected = row["Expected"].ToString(); string behaviour = row["Behaviour"].ToString(); NameExtensionHelper helper; switch (behaviour) { case "N": helper = NameExtensionHelper.CreateNameExtensionHelper(NameExtensionBehaviour.NameOnly); break; case "X": helper = NameExtensionHelper.CreateNameExtensionHelper(NameExtensionBehaviour.ExtensionOnly); break; default: // Normally use "B" in csv file helper = NameExtensionHelper.CreateNameExtensionHelper(NameExtensionBehaviour.BothNameExtension); break; } RemoveCharactersStrategy strategy = new RemoveCharactersStrategy(from, fromLeft, to, toLeft); IFileMetaData file = CreateFileMetaData(name + "." + extension); string result = strategy.RenameFile(file, 0, helper); Assert.AreEqual(expected, result); }