public async Task InsertListTransactionRollbackNoComputedAsync() { var p = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Alice", LastName = "Jones" }; var q = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Raj", LastName = "Padilla" }; var r = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Lidia", LastName = "Bain" }; using (var db = GetSqlDatabase()) { using (var t = db.GetTransaction()) { Assert.True(await db.InsertListAsync(new List <PersonUniqueIdentifier> { p, q, r })); t.Dispose(); } Assert.Null(await db.GetAsync <PersonUniqueIdentifier>(p.GuidId)); } }
public async Task InsertListTransactionNoComputedThrowsExceptionAsync() { Skip.If(GetProvider() == Provider.SQLite, "Sqlite doesn't enforce size limit"); var p = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Alice", LastName = "Jones" }; var q = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "a".PadRight(101, 'a'), LastName = "Padilla" }; var r = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Lidia", LastName = "Bain" }; using (var db = GetSqlDatabase()) { using (var t = db.GetTransaction()) { await Assert.ThrowsAnyAsync <Exception>(() => db.InsertListAsync(new List <PersonUniqueIdentifier> { p, q, r })); } Assert.Null(await db.GetAsync <PersonUniqueIdentifier>(p.GuidId)); } }
public void InsertListTransactionNoComputed() { var p = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Alice", LastName = "Jones" }; var q = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Raj", LastName = "Padilla" }; var r = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Lidia", LastName = "Bain" }; using (var db = GetSqlDatabase()) { using (var t = db.GetTransaction()) { Assert.True(db.InsertList(new List <PersonUniqueIdentifier> { p, q, r })); t.Complete(); } var gp = db.Get <PersonUniqueIdentifier>(p.GuidId); Assert.Equal(p.FirstName, gp.FirstName); Assert.Equal(p.LastName, gp.LastName); } }
public async Task UpdateListNoComputedPartialAsync() { using (var db = GetSqlDatabase()) { var p = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Alice", LastName = "Jones" }; var q = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Raj", LastName = "Padilla" }; var r = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Lidia", LastName = "Bain" }; var lst = new List <PersonUniqueIdentifier> { p, q, r }; Assert.True(await db.InsertListAsync(lst)); p.FirstName = "Emily"; p.LastName = "Swank"; q.FirstName = "Jim"; r.FirstName = "Laura"; Assert.True(await db.UpdateListAsync(lst, new[] { "LastName" })); var gp = await db.GetAsync <PersonUniqueIdentifier>(p.GuidId); Assert.Equal("Alice", gp.FirstName); Assert.Equal("Swank", gp.LastName); Assert.Equal(p.LastName, gp.LastName); } }
public async Task UpdateListNoComputedThrowsExceptionAsync() { Skip.If(GetProvider() == Provider.SQLite, "Sqlite doesn't enforce size limit"); using (var db = GetSqlDatabase()) { var p = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Alice", LastName = "Jones" }; var q = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Raj", LastName = "Padilla" }; var r = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Lidia", LastName = "Bain" }; var lst = new List <PersonUniqueIdentifier> { p, q, r }; Assert.True(await db.InsertListAsync(lst)); p.FirstName = "Emily"; q.FirstName = "a".PadRight(101, 'a'); r.FirstName = "Laura"; await Assert.ThrowsAnyAsync <Exception>(() => db.UpdateListAsync(lst)); var gp = await db.GetAsync <PersonUniqueIdentifier>(p.GuidId); Assert.Equal("Alice", gp.FirstName); Assert.Equal(p.LastName, gp.LastName); } }
public void UpdateListNoComputed() { using (var db = GetSqlDatabase()) { var p = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Alice", LastName = "Jones" }; var q = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Raj", LastName = "Padilla" }; var r = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Lidia", LastName = "Bain" }; var lst = new List <PersonUniqueIdentifier> { p, q, r }; Assert.True(db.InsertList(lst)); p.FirstName = "Emily"; q.FirstName = "Jim"; r.FirstName = "Laura"; Assert.True(db.UpdateList(lst)); var gp = db.Get <PersonUniqueIdentifier>(p.GuidId); Assert.Equal("Emily", gp.FirstName); Assert.Equal(p.LastName, gp.LastName); } }
public void InsertUniqueIdentifier() { using (var db = GetSqlDatabase()) { var p = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Alice", LastName = "Jones" }; Assert.True(db.Insert(p)); var gp = db.Get <PersonUniqueIdentifier>(p.GuidId); Assert.Equal(p.FirstName, gp.FirstName); Assert.Equal(p.LastName, gp.LastName); } }
public async Task InsertUniqueIdentifierAsync() { using (var db = GetSqlDatabase()) { var p = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Alice", LastName = "Jones" }; Assert.True(await db.InsertAsync(p)); var gp = await db.GetAsync <PersonUniqueIdentifier>(p.GuidId); Assert.Equal(p.FirstName, gp.FirstName); Assert.Equal(p.LastName, gp.LastName); } }
public async Task UpsertListTransactionNoComputedAsync() { using (var db = GetSqlDatabase()) { var p = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Alice", LastName = "Jones" }; var q = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Raj", LastName = "Padilla" }; var r = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Lidia", LastName = "Bain" }; var s = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Derren", LastName = "Southern" }; var lst = new List <PersonUniqueIdentifier> { p, q, r }; Assert.True(await db.UpsertListAsync(lst)); using (var t = db.GetTransaction()) { p.FirstName = "Emily"; q.FirstName = "Jim"; r.FirstName = "Laura"; lst.Add(s); Assert.True(await db.UpsertListAsync(lst)); t.Complete(); } var gp = await db.GetAsync <PersonUniqueIdentifier>(p.GuidId); Assert.Equal("Emily", gp.FirstName); Assert.Equal(p.LastName, gp.LastName); var gs = await db.GetAsync <PersonUniqueIdentifier>(s.GuidId); Assert.Equal("Derren", gs.FirstName); Assert.Equal("Southern", gs.LastName); } }
public void UpsertListTransactionNoComputedThrowsException() { Skip.If(GetProvider() == Provider.SQLite, "Sqlite doesn't enforce size limit"); var p = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Alice", LastName = "Jones" }; var q = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Raj", LastName = "Padilla" }; var r = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Lidia", LastName = "Bain" }; var s = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Derren", LastName = "Southern" }; var lst = new List <PersonUniqueIdentifier> { p, q, r }; using (var db = GetSqlDatabase()) { Assert.True(db.UpsertList(lst)); using (var t = db.GetTransaction()) { p.FirstName = "Emily"; q.FirstName = "a".PadRight(101, 'a'); r.FirstName = "Laura"; lst.Add(s); Assert.ThrowsAny <Exception>(() => db.UpsertList(lst)); } var gp = db.Get <PersonUniqueIdentifier>(p.GuidId); Assert.Equal("Alice", gp.FirstName); Assert.Equal(p.LastName, gp.LastName); var gs = db.Get <PersonUniqueIdentifier>(s.GuidId); Assert.Null(gs); } }
public void UpsertListTransactionRollbackNoComputed() { var p = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Alice", LastName = "Jones" }; var q = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Raj", LastName = "Padilla" }; var r = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Lidia", LastName = "Bain" }; var s = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Derren", LastName = "Southern" }; var lst = new List <PersonUniqueIdentifier> { p, q, r }; using (var db = GetSqlDatabase()) { Assert.True(db.UpsertList(lst)); using (var t = db.GetTransaction()) { p.FirstName = "Emily"; q.FirstName = "Jim"; r.FirstName = "Laura"; lst.Add(s); Assert.True(db.UpsertList(lst)); t.Dispose(); } var gp = db.Get <PersonUniqueIdentifier>(p.GuidId); Assert.Equal("Alice", gp.FirstName); Assert.Equal(p.LastName, gp.LastName); var gs = db.Get <PersonUniqueIdentifier>(s.GuidId); Assert.Null(gs); } }
public void UpsertListNoComputedPartial() { using (var db = GetSqlDatabase()) { var p = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Alice", LastName = "Jones" }; var q = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Raj", LastName = "Padilla" }; var r = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Lidia", LastName = "Bain" }; var s = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Derren", LastName = "Southern" }; var lst = new List <PersonUniqueIdentifier> { p, q, r }; Assert.True(db.UpsertList(lst)); p.FirstName = "Emily"; p.LastName = "Swank"; q.FirstName = "Jim"; r.FirstName = "Laura"; lst.Add(s); Assert.True(db.UpsertList(lst, new[] { "LastName" })); var gp = db.Get <PersonUniqueIdentifier>(p.GuidId); Assert.Equal("Alice", gp.FirstName); Assert.Equal("Swank", gp.LastName); var gs = db.Get <PersonUniqueIdentifier>(s.GuidId); Assert.Equal("Derren", gs.FirstName); Assert.Equal("Southern", gs.LastName); } }
public void DeleteUniqueIdentifierEntity() { using (var db = GetSqlDatabase()) { var pOther = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "OtherAlice", LastName = "OtherJones" }; var p = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Alice", LastName = "Jones" }; Assert.True(db.Insert(p)); Assert.True(db.Insert(pOther)); Assert.True(db.Delete(p)); var gp = db.Get(p); var gpOther = db.Get(pOther); Assert.Null(gp); Assert.NotNull(gpOther); } }
public async Task DeleteUniqueIdentifierEntityAsync() { using (var db = GetSqlDatabase()) { var pOther = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "OtherAliceAsync", LastName = "OtherJones" }; var p = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "AliceAsync", LastName = "Jones" }; Assert.True(await db.InsertAsync(p)); Assert.True(await db.InsertAsync(pOther)); Assert.True(await db.DeleteAsync(p)); var gp = await db.GetAsync(p); var gpOther = await db.GetAsync(pOther); Assert.Null(gp); Assert.NotNull(gpOther); } }
public async Task InsertListNoComputedAsync() { using (var db = GetSqlDatabase()) { var p = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Alice", LastName = "Jones" }; var q = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Raj", LastName = "Padilla" }; var r = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Lidia", LastName = "Bain" }; Assert.True(await db.InsertListAsync(new List <PersonUniqueIdentifier> { p, q, r })); //Assert.True(p.IdentityId > 0); var gp = await db.GetAsync <PersonUniqueIdentifier>(p.GuidId); Assert.Equal(p.FirstName, gp.FirstName); Assert.Equal(p.LastName, gp.LastName); } }
public async Task UpdateListTransactionRollbackNoComputedAsync() { var p = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Alice", LastName = "Jones" }; var q = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Raj", LastName = "Padilla" }; var r = new PersonUniqueIdentifier { GuidId = Guid.NewGuid(), FirstName = "Lidia", LastName = "Bain" }; var lst = new List <PersonUniqueIdentifier> { p, q, r }; using (var db = GetSqlDatabase()) { Assert.True(await db.InsertListAsync(lst)); using (var t = db.GetTransaction()) { p.FirstName = "Emily"; q.FirstName = "Jim"; r.FirstName = "Laura"; Assert.True(await db.UpdateListAsync(lst)); t.Dispose(); } var gp = await db.GetAsync <PersonUniqueIdentifier>(p.GuidId); Assert.Equal("Alice", gp.FirstName); Assert.Equal(p.LastName, gp.LastName); } }