public void QueryExecutionTest() { var id = Guid.NewGuid().ToString(); var args = new[] { "query", "-i", "create table ships_guns(guns_id int, ship_id int);", "-o", "hoge", "-n", "Fuga", "--executionid", id }; CoconaLiteApp.Create().Run <QueryToCSharp>(args); var expected = @"// ------------------------------------------------------------------------------ // <auto-generated> // Code Generated by MySQLToCsharp // </auto-generated> // ------------------------------------------------------------------------------ using System; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace Fuga { public partial class ships_gun { public int guns_id { get; set; } public int ship_id { get; set; } } } "; var msg = QueryToCSharp.Context.GetLogs(id).First(); msg.Should().Be(InternalUtils.NormalizeNewLines(expected)); }
public void FileExecutionAnnotationTest() { var dir = "file_annotation"; var id = Guid.NewGuid().ToString(); var args = new[] { "file", "-i", "test_data/simple_annotation/create_tables_simple_annotation.sql", "-o", dir, "-n", "Fuga", "--executionid", id }; CoconaLiteApp.Create().Run <QueryToCSharp>(args); var expected = @"// ------------------------------------------------------------------------------ // <auto-generated> // Code Generated by MySQLToCsharp // </auto-generated> // ------------------------------------------------------------------------------ using System; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace Fuga { public partial class quengine { public int id { get; set; } [Required] [StringLength(10)] public string class { get; set; } [Required] public byte[] data { get; set; } } } "; var msg = QueryToCSharp.Context.GetLogs(id).First(); msg.Should().Be(InternalUtils.NormalizeNewLines(expected)); }
public static Task Main(string[] args) => CoconaLiteApp.Create() .ConfigureServices(services => { services.AddJsonConfigurationService(FileConfigurationServiceRoot); }) .RunAsync <Program>(args, options => { options.TreatPublicMethodsAsCommands = false; });
static async Task Main(string[] args) { #if SENTRY || !DEBUG using var _ = SentrySdk.Init(ConfigureSentryOptions); #endif await CoconaLiteApp.Create() .ConfigureServices(services => { services.AddSingleton <IConsole, StandardConsole>(); services.AddSingleton <IKeyStore>(Web3KeyStore.DefaultKeyStore); }) .RunAsync <Program>(args); }
static void Main() { using var sentry = SentrySdk.Init(o => { o.Dsn = "https://[email protected]/6125607"; o.TracesSampleRate = 1.0; // Capture 100% of transactions }); DotEnv.Load(); var app = CoconaLiteApp.Create(); app.AddCommand(RunScraperWithExceptionHandling).WithDescription("A tool to detect new+modified postings on Vancouver's shapeyourcity.ca website. Data is stored in a local SQLite database next to the executable."); app.AddCommand("tweet", TweetWithExceptionHandling).WithDescription("Tweet a recent item."); app.Run(); }