public void TestRuleReadWriterWriteWithExportAll() { var parsed = new Args { ServerName = "WRK-003", DbName = "BizTalkRuleEngineDb", Mode = Mode.ExportAll, IsOverwrite = true, Path = @"C:\Users\v.michailov\RealProjects\biztalkutilites\inputData" }; Assert.AreEqual(false, File.Exists(@"..\..\..\inputData\Policy.Test-1.0.xml")); Assert.AreEqual(false, File.Exists(@"..\..\..\inputData\Policy.Test-1.1.xml")); Assert.AreEqual(false, File.Exists(@"..\..\..\inputData\PolicyAA-1.0.xml")); Assert.AreEqual(false, File.Exists(@"..\..\..\inputData\voc1-1.0.xml")); Assert.AreEqual(false, File.Exists(@"..\..\..\inputData\voc2-1.0.xml")); RuleReadWriter.Write(parsed.ServerName, parsed.DbName, parsed.RuleNames, parsed.Path, TODO); var timeBefore1 = File.GetLastAccessTime(@"..\..\..\inputData\Policy.Test-1.0.xml"); var timeBefore2 = File.GetLastAccessTime(@"..\..\..\inputData\voc2-1.0.xml"); RuleReadWriter.Write(parsed.ServerName, parsed.DbName, parsed.RuleNames, parsed.Path, TODO); var timeAfter1 = File.GetLastAccessTime(@"..\..\..\inputData\Policy.Test-1.0.xml"); var timeAfter2 = File.GetLastAccessTime(@"..\..\..\inputData\voc2-1.0.xml"); Assert.AreNotEqual(timeBefore1.Millisecond, timeAfter1.Millisecond); Assert.AreNotEqual(timeBefore2.Millisecond, timeAfter2.Millisecond); Assert.AreEqual(true, File.Exists(@"..\..\..\inputData\Policy.Test-1.0.xml")); Assert.AreEqual(true, File.Exists(@"..\..\..\inputData\Policy.Test-1.1.xml")); Assert.AreEqual(true, File.Exists(@"..\..\..\inputData\PolicyAA-1.0.xml")); Assert.AreEqual(true, File.Exists(@"..\..\..\inputData\voc1-1.0.xml")); Assert.AreEqual(true, File.Exists(@"..\..\..\inputData\voc2-1.0.xml")); }
public void TestRuleReadWriterWriteWithExportAllOverwriteFalse() { BreRecord.Error += str => //СОБЫТИЕ НАСТУПАЕТ при попытке перезаписи { throw new IOException(); }; var parsed = new Args { ServerName = "WRK-003", DbName = "BizTalkRuleEngineDb", Mode = Mode.ExportAll, IsOverwrite = false, //изменен флаг перезаписи Path = @"C:\Users\v.michailov\RealProjects\biztalkutilites\inputData" }; Assert.AreEqual(false, File.Exists(@"..\..\..\inputData\Policy.Test-1.0.xml")); Assert.AreEqual(false, File.Exists(@"..\..\..\inputData\Policy.Test-1.1.xml")); Assert.AreEqual(false, File.Exists(@"..\..\..\inputData\PolicyAA-1.0.xml")); Assert.AreEqual(false, File.Exists(@"..\..\..\inputData\voc1-1.0.xml")); Assert.AreEqual(false, File.Exists(@"..\..\..\inputData\voc2-1.0.xml")); RuleReadWriter.Write(parsed.ServerName, parsed.DbName, parsed.RuleNames, parsed.Path, TODO); Assert.AreEqual(true, File.Exists(@"..\..\..\inputData\Policy.Test-1.0.xml")); Assert.AreEqual(true, File.Exists(@"..\..\..\inputData\Policy.Test-1.1.xml")); Assert.AreEqual(true, File.Exists(@"..\..\..\inputData\PolicyAA-1.0.xml")); Assert.AreEqual(true, File.Exists(@"..\..\..\inputData\voc1-1.0.xml")); Assert.AreEqual(true, File.Exists(@"..\..\..\inputData\voc2-1.0.xml")); RuleReadWriter.Write(parsed.ServerName, parsed.DbName, parsed.RuleNames, parsed.Path, TODO); }
public void TestCommandLineParserWithShortCommand() { var args = new[] { "--m", "export-list", "--d", "WRK-003", "--f", @"..\..\..\inputData", "--r", "voc1", "--n", "BizTalkRuleEngineDb", "--w" }; var result = CmdParser.Parse(args); RuleReadWriter.Write(result.ServerName, result.DbName, result.RuleNames, result.Path, TODO); Assert.AreEqual(result.IsSuccess, true); File.Delete(@"..\..\..\inputData\voc1-1.0.xml"); }
private static void Main(string[] args) { var files = new List <BreRecord>(); RuleReadWriter.Error += ShowMsqError; var parseArgs = CmdParser.Parse(args); if (!parseArgs.IsSuccess) { foreach (var error in parseArgs.Errors) { switch (error.Tag) { case ErrorType.UnknownOptionError: foreach (var err in parseArgs.Errors) { if (!(err is LogicErrorType)) { continue; } Console.WriteLine("отсутствует --rule-names"); Console.ReadLine(); } break; case ErrorType.BadFormatTokenError: Console.WriteLine("Ошибка имени значения ключа --mode"); Console.ReadLine(); break; case ErrorType.BadVerbSelectedError: Console.WriteLine("не указан путь"); Console.ReadLine(); break; default: throw new Exception("Неизвестная ошибка"); } } } switch (parseArgs.Mode) { case Mode.ExportAll: files = RuleReadWriter.CreateFileForWriteAll(parseArgs.ServerName, parseArgs.DbName); RuleReadWriter.Write(parseArgs.ServerName, parseArgs.DbName, files, parseArgs.Path, parseArgs.IsOverwrite); break; case Mode.ExportList: foreach (var name in parseArgs.RuleNames) { var fileList = RuleReadWriter.CreateFileForWriteList(parseArgs.ServerName, parseArgs.DbName, RuleReadWriter.CreateRecord(name)); foreach (var file in fileList) { files.Add(file); } } RuleReadWriter.Write(parseArgs.ServerName, parseArgs.DbName, files, parseArgs.Path, parseArgs.IsOverwrite); break; case Mode.ImportAll: RuleReadWriter.Read(parseArgs.ServerName, parseArgs.DbName, RuleReadWriter.CreateFileForReadAll(parseArgs.Path)); break; case Mode.ImportList: foreach (var name in parseArgs.RuleNames) { files.Add(RuleReadWriter.CreateFileForReadList(name)); } RuleReadWriter.Read(parseArgs.ServerName, parseArgs.DbName, files); break; case Mode.ShowList: foreach (var name in parseArgs.RuleNames) { files.Add(RuleReadWriter.CreateRecord(name)); } RuleEngineDb.ShowListRuleAndVocab(files, parseArgs.IsDependecy); break; case Mode.ShowAll: RuleEngineDb.ShowAllRuleAndVocab(parseArgs.IsDependecy); break; } }