public async Task CanUseGuidsAsNames() { var tableName = Guid.NewGuid().ToString("N"); var typeName = Guid.NewGuid().ToString("N"); var procName = Guid.NewGuid().ToString("N"); var helper = new UpsertHelper <SomeModel>(ConnectionString, tableName: tableName, procName: procName, typeName: typeName); helper.DropSchema(dropType: true, dropTable: true, dropProcedure: true); helper.CreateSchema(); await helper.UpsertAsync(new[] { new SomeModel { Id = 123, Text = "nummer 123" } }); var rows = helper.LoadAll().ToList(); Assert.That(rows.Count, Is.EqualTo(1)); var row = rows.First(); Assert.That(row.Id, Is.EqualTo(123)); Assert.That(row.Text, Is.EqualTo("nummer 123")); await using var connection = await OpenSqlConnection(); var schemas = connection.GetSchemas().ToList(); Assert.That(schemas, Contains.Item("dbo")); Assert.That(connection.GetTableNames(schema: "dbo"), Contains.Item(tableName)); Assert.That(connection.GetTableDataTypeNames(schema: "dbo"), Contains.Item(typeName)); Assert.That(connection.GetSprocNames(schema: "dbo"), Contains.Item(procName)); }
public async Task ItWorks() { var helper = new UpsertHelper <SomeClassWithDateTimeOffset>(ConnectionString); helper.DropSchema(dropType: true, dropTable: true, dropProcedure: true); helper.CreateSchema(); var now = DateTimeOffset.Now; await helper.UpsertAsync(new[] { new SomeClassWithDateTimeOffset { Id = "1", Time = now }, new SomeClassWithDateTimeOffset { Id = "2", Time = now }, new SomeClassWithDateTimeOffset { Id = "3", Time = now }, }); var all = helper.LoadAll(); Assert.That(all.Count(), Is.EqualTo(3)); }
public async Task ItWorks() { var helper = new UpsertHelper <SomeClassWithDecimal>(ConnectionString); helper.DropSchema(dropType: true, dropTable: true, dropProcedure: true); helper.CreateSchema(); await helper.UpsertAsync(new[] { new SomeClassWithDecimal { Decimal = 1.1m, Id = Guid.NewGuid().ToString() }, new SomeClassWithDecimal { Decimal = 1.12m, Id = Guid.NewGuid().ToString() }, new SomeClassWithDecimal { Decimal = 1.123m, Id = Guid.NewGuid().ToString() }, new SomeClassWithDecimal { Decimal = 1.1234m, Id = Guid.NewGuid().ToString() }, new SomeClassWithDecimal { Decimal = 1.12345m, Id = Guid.NewGuid().ToString() }, new SomeClassWithDecimal { Decimal = 1.123456m, Id = Guid.NewGuid().ToString() }, new SomeClassWithDecimal { Decimal = 1.1234567m, Id = Guid.NewGuid().ToString() }, new SomeClassWithDecimal { Decimal = 1.12345678m, Id = Guid.NewGuid().ToString() }, new SomeClassWithDecimal { Decimal = 1.123456789m, Id = Guid.NewGuid().ToString() }, new SomeClassWithDecimal { Decimal = 1.1234567891m, Id = Guid.NewGuid().ToString() }, }); var all = helper.LoadAll().OrderBy(d => d.Decimal).ToList(); Assert.That(all.Select(a => a.Decimal), Is.EqualTo(new[] { 1.1m, 1.12m, 1.123m, 1.1234m, 1.12345m, 1.123456m, 1.1234567m, 1.12345678m, 1.123456789m, 1.1234567891m, })); }
public async Task ItWorks() { await _upsertHelper.UpsertAsync(new[] { new CurrencyCrossRates(new Date(2017, 1, 17), "EUR", "USD", 5.5m), }); var rows = _upsertHelper.LoadAll().ToList(); }
public async Task CanRoundtripThisBadBoy() { var helper = new UpsertHelper <SomeKindOfLine>(ConnectionString); helper.DropSchema(dropProcedure: true, dropTable: true, dropType: true); helper.CreateSchema(); await helper.UpsertAsync(new[] { new SomeKindOfLine(123, 789, 505, TimeZoneInfo.Local) }); var roundtripped = helper.LoadAll().ToList(); Assert.That(roundtripped.Count, Is.EqualTo(1)); var line = roundtripped.First(); Assert.That(line.SecondId, Is.EqualTo(789)); Assert.That(line.FirstId, Is.EqualTo(123)); Assert.That(line.DecimalNumber, Is.EqualTo(505)); Assert.That(line.Timezone, Is.EqualTo(TimeZoneInfo.Local)); }