public virtual void TestStructureGenerator() { StructureGenerator sg = new StructureGenerator(); string[] args = new string[] { "-maxDepth", "2", "-minWidth", "1", "-maxWidth", "2" , "-numOfFiles", "2", "-avgFileSize", "1", "-outDir", OutDir.GetAbsolutePath(), "-seed", "1" }; int MaxDepth = 1; int MinWidth = 3; int MaxWidth = 5; int NumOfFiles = 7; int AvgFileSize = 9; int Seed = 13; try { // successful case NUnit.Framework.Assert.AreEqual(0, sg.Run(args)); BufferedReader @in = new BufferedReader(new FileReader(DirStructureFile)); NUnit.Framework.Assert.AreEqual(DirStructureFirstLine, @in.ReadLine()); NUnit.Framework.Assert.AreEqual(DirStructureSecondLine, @in.ReadLine()); NUnit.Framework.Assert.AreEqual(null, @in.ReadLine()); @in.Close(); @in = new BufferedReader(new FileReader(FileStructureFile)); NUnit.Framework.Assert.AreEqual(FileStructureFirstLine, @in.ReadLine()); NUnit.Framework.Assert.AreEqual(FileStructureSecondLine, @in.ReadLine()); NUnit.Framework.Assert.AreEqual(null, @in.ReadLine()); @in.Close(); string oldArg = args[MaxDepth]; args[MaxDepth] = "0"; NUnit.Framework.Assert.AreEqual(-1, sg.Run(args)); args[MaxDepth] = oldArg; oldArg = args[MinWidth]; args[MinWidth] = "-1"; NUnit.Framework.Assert.AreEqual(-1, sg.Run(args)); args[MinWidth] = oldArg; oldArg = args[MaxWidth]; args[MaxWidth] = "-1"; NUnit.Framework.Assert.AreEqual(-1, sg.Run(args)); args[MaxWidth] = oldArg; oldArg = args[NumOfFiles]; args[NumOfFiles] = "-1"; NUnit.Framework.Assert.AreEqual(-1, sg.Run(args)); args[NumOfFiles] = oldArg; oldArg = args[NumOfFiles]; args[NumOfFiles] = "-1"; NUnit.Framework.Assert.AreEqual(-1, sg.Run(args)); args[NumOfFiles] = oldArg; oldArg = args[AvgFileSize]; args[AvgFileSize] = "-1"; NUnit.Framework.Assert.AreEqual(-1, sg.Run(args)); args[AvgFileSize] = oldArg; oldArg = args[Seed]; args[Seed] = "34.d4"; NUnit.Framework.Assert.AreEqual(-1, sg.Run(args)); args[Seed] = oldArg; } finally { DirStructureFile.Delete(); FileStructureFile.Delete(); } }
/// <summary>Main program</summary> /// <param name="args">Command line arguments</param> /// <exception cref="System.Exception"/> public static void Main(string[] args) { StructureGenerator sg = new StructureGenerator(); System.Environment.Exit(sg.Run(args)); }