static void Main(string[] args) { var options = new Options(); if (args.Length > 0 && CommandLine.Parser.Default.ParseArguments(args, options)) { var connection = options.ToConnection(); using (var scope = new AutofacBootstrapper(connection)) { try { var result = scope.Resolve <IImporter>().Import(connection); var profile = scope.Resolve <IProfiler>().Profile(result, options.Limit); System.Console.Out.WriteLine("Name,Type,Position,Count,Min Value,Max Value,Min Length,Max Length"); foreach (var field in profile) { System.Console.Out.WriteLine($"{field.Field.Name},{field.Field.Type},{field.Field.Index - 3},{field.Count},\"{field.MinValue}\",\"{field.MaxValue}\",{field.MinLength},{field.MaxLength}"); } Environment.ExitCode = 0; } catch (Exception ex) { System.Console.Error.WriteLine(ex.Message); Environment.ExitCode = 1; } } } else { System.Console.Error.WriteLine(options.GetUsage()); Environment.ExitCode = 1; } }
public void TestExporter() { var file = Path.GetTempFileName(); File.WriteAllText(file, @"t1,t2,t3,t4 Monday,10,1.1,1/1/2014 Tuesday,11,2.2,2/1/2014 Wednesday,12,3.3,3/1/2014 Wednesday,12,3.3,3/1/2014 Thursday,13,4.4,4/1/2014 Friday,14,5.5,5/1/2014 Saturday,15,6.6,6/1/2014"); File.Delete(Output); var connection = new Connection { Name = "input", Provider = "file", File = file }; using (var scope = new AutofacBootstrapper(connection)) { var result = scope.Resolve <IImporter>().Import(connection); var profile = scope.Resolve <IProfiler>().Profile(result, 30); var builder = new StringBuilder(); builder.AppendLine("Name,Type,Position,Count,Min Value,Max Value,Min Length,Max Length"); foreach (var field in profile) { builder.AppendLine($"{field.Field.Name},{field.Field.Type},{field.Field.Index},{field.Count},\"{field.MinValue}\",\"{field.MaxValue}\",{field.MinLength},{field.MaxLength}"); } File.WriteAllText(Output, builder.ToString()); } Assert.IsTrue(File.Exists(Output)); }
// [Ignore("Depends on NorthWind database on local SQL Server.")] public void TestProfilerDatabase() { var connection = new Connection { Name = "input", Provider = "sqlserver", Database = "Northwind", Table = "Customers" }; using (var scope = new AutofacBootstrapper(connection)) { var result = scope.Resolve <IImporter>().Import(connection); var profile = scope.Resolve <IProfiler>().Profile(result, 30); Assert.NotNull(result); Assert.NotNull(profile); } }
public BaseController() { _viewRenderService = AutofacBootstrapper.Resolve <IViewRenderService>(); }
public void TestProfiler() { File.WriteAllText(@"c:\Temp\Data\temp.txt", @"t1,t2,t3,t4 Monday,10,1.1,1/1/2014 Tuesday,11,2.2,2/1/2014 Wednesday,12,3.3,3/1/2014 Wednesday,12,3.3,3/1/2014 Thursday,13,4.4,4/1/2014 Friday,14,5.5,5/1/2014 Saturday,15,6.6,6/1/2014"); var connection = new Connection { Name = "input", Provider = "file", File = @"c:\Temp\Data\temp.txt", Types = new List <TflType> { new TflType("byte"), new TflType("single"), new TflType("datetime") } }; using (var scope = new AutofacBootstrapper(connection)) { var result = scope.Resolve <IImporter>().Import(connection); var profile = scope.Resolve <IProfiler>().Profile(result, 30).ToList(); Assert.AreEqual(",", result.Connection.Delimiter); Assert.AreEqual(4, result.Fields.Count); Assert.AreEqual(7, result.Rows.Count()); var t1 = profile.First(fp => fp.Field.Name == "t1"); var t2 = profile.First(fp => fp.Field.Name == "t2"); var t3 = profile.First(fp => fp.Field.Name == "t3"); var t4 = profile.First(fp => fp.Field.Name == "t4"); Assert.AreEqual(4, profile.Count); Assert.AreEqual("string", t1.Field.Type); Assert.AreEqual("byte", t2.Field.Type); Assert.AreEqual("single", t3.Field.Type); Assert.AreEqual("datetime", t4.Field.Type); // account for system fields Assert.AreEqual(4, t1.Field.Index); Assert.AreEqual(5, t2.Field.Index); Assert.AreEqual(6, t3.Field.Index); Assert.AreEqual(7, t4.Field.Index); Assert.AreEqual("Friday", t1.MinValue); Assert.AreEqual(10, t2.MinValue); Assert.AreEqual(1.1f, t3.MinValue); Assert.AreEqual(new DateTime(2014, 1, 1, 0, 0, 0, DateTimeKind.Local), t4.MinValue); Assert.AreEqual("Wednesday", t1.MaxValue); Assert.AreEqual(15, t2.MaxValue); Assert.AreEqual(6.6f, t3.MaxValue); Assert.AreEqual(new DateTime(2014, 6, 1, 0, 0, 0, DateTimeKind.Local), t4.MaxValue); Assert.AreEqual(6, t1.MinLength); Assert.AreEqual(2, t2.MinLength); Assert.AreEqual(3, t3.MinLength); Assert.AreEqual(20, t4.MinLength); Assert.AreEqual(9, t1.MaxLength); Assert.AreEqual(2, t2.MaxLength); Assert.AreEqual(3, t3.MaxLength); Assert.AreEqual(20, t4.MaxLength); Assert.AreEqual(6, t1.Count); Assert.AreEqual(6, t2.Count); Assert.AreEqual(6, t3.Count); Assert.AreEqual(6, t4.Count); } }