public async Task SelectAsyncContains(DatabaseDriver database) { using (var con = database.GetConnection()) { var products = await con.SelectAsync <Product>(p => p.Name.Contains("Anton")); Assert.Equal(4, products.Count()); } }
public void Get(DatabaseDriver database) { using (var con = database.GetConnection()) { var product = con.Get <Product>(1); Assert.NotNull(product); Assert.NotEmpty(product.Name); } }
public async Task SelectAsyncEqual(DatabaseDriver database) { using (var con = database.GetConnection()) { var products = await con.SelectAsync <Product>(p => p.CategoryId == 1); Assert.Equal(10, products.Count()); } }
public void Project(DatabaseDriver database) { using (var con = database.GetConnection()) { var p = con.Project <ProductSmall>(1); Assert.NotEqual(0, p.Id); Assert.NotNull(p.Name); } }
public async Task SelectAndStatementAsync(DatabaseDriver database) { using var con = database.GetConnection(); var id = await InsertLeadAsync(con); var leads = await con.SelectAsync <Lead>(p => p.Data !.FirstName == "Foo" && p.Data.LastName == "Bar" && p.Email == "*****@*****.**"); Assert.NotEmpty(leads); }
public void OrStatement(DatabaseDriver database) { using var con = database.GetConnection(); var id = InsertLead(con); Assert.True(con.DeleteMultiple <Lead>(p => p.Data !.FirstName == "Foo" && p.Data.LastName == "Bar" || p.Email == "*****@*****.**")); var leads = con.Select <Lead>(p => p.Data !.FirstName == "Foo" && p.Data.LastName == "Bar" || p.Email == "*****@*****.**"); Assert.Empty(leads); }
public async Task SingleStatementAsync(DatabaseDriver database) { using var con = database.GetConnection(); var id = await InsertLeadAsync(con); Assert.True(await con.DeleteMultipleAsync <Lead>(p => p.Data !.Email == "*****@*****.**")); var leads = await con.SelectAsync <Lead>(p => p.Data !.Email == "*****@*****.**"); Assert.Empty(leads); }
public void SingleStatement(DatabaseDriver database) { using var con = database.GetConnection(); var id = InsertLead(con); Assert.True(con.DeleteMultiple <Lead>(p => p.Data !.Email == "*****@*****.**")); var leads = con.Select <Lead>(p => p.Data !.Email == "*****@*****.**"); Assert.Empty(leads); }
public void SelectAsyncContainsVariable(DatabaseDriver database) { var productName = "Anton"; using (var con = database.GetConnection()) { Action action = () => con.SelectAsync <Product>(p => p.Name.Contains(productName)); action.Should().Throw <InvalidCastException>(); } }
public async Task GetAllAsync(DatabaseDriver database) { using (var con = database.GetConnection()) { var products = await con.GetAllAsync <Product>(); Assert.NotEmpty(products); Assert.All(products, p => Assert.NotEmpty(p.Name)); } }
public void SelectAsyncEndsWith(DatabaseDriver database) { var productName = "2"; using (var con = database.GetConnection()) { Action action = () => con.SelectAsync <Product>(p => p.Name.EndsWith(productName)); action.Should().Throw <InvalidCastException>(); } }
public async Task GetAsync(DatabaseDriver database) { using (var con = database.GetConnection()) { var product = await con.GetAsync <Product>(1); Assert.NotNull(product); Assert.NotEmpty(product.Name); } }
public async Task ProjectAsync(DatabaseDriver database) { using (var con = database.GetConnection()) { var p = await con.ProjectAsync <ProductSmall>(1); Assert.NotEqual(0, p.Id); Assert.NotNull(p.Name); } }
public void ProjectPagedAll(DatabaseDriver database) { using (var con = database.GetConnection()) { var ps = con.ProjectPaged <ProductSmall>(pageNumber: 1, pageSize: 5); Assert.NotEmpty(ps); Assert.All(ps, p => { Assert.NotEqual(0, p.Id); Assert.NotNull(p.Name); }); } }
public async Task ProjectAllAsync(DatabaseDriver database) { using (var con = database.GetConnection()) { var ps = await con.ProjectAllAsync <ProductSmall>(); Assert.NotEmpty(ps); Assert.All(ps, p => { Assert.NotEqual(0, p.Id); Assert.NotNull(p.Name); }); } }
public void Fetches_FirstPage(DatabaseDriver database) { using (var con = database.GetConnection()) { var paged = con.GetPaged <Product>(1, 5).ToArray(); Assert.Equal(5, paged.Length); Assert.Collection(paged, p => Assert.Equal("Chai", p.Name), p => Assert.Equal("Chang", p.Name), p => Assert.Equal("Aniseed Syrup", p.Name), p => Assert.Equal("Chef Anton's Cajun Seasoning", p.Name), p => Assert.Equal("Chef Anton's Gumbo Mix", p.Name)); } }
public void Update(DatabaseDriver database) { using (var con = database.GetConnection()) { var product = con.Get <Product>(1); Assert.NotNull(product); product.Name = "Test"; con.Update(product); var newProduct = con.Get <Product>(1); Assert.Equal("Test", newProduct.Name); } }
public void Insert(DatabaseDriver database) { using (var con = database.GetConnection()) { var id = Convert.ToInt32(con.Insert(new Product { Name = "blah" })); var product = con.Get <Product>(id); product.Should().NotBeNull(); product.Name.Should().Be("blah"); product.Id.Should().Be(id); } }
public async Task InsertAsync(DatabaseDriver database) { using (var con = database.GetConnection()) { var id = Convert.ToInt32(await con.InsertAsync(new Product { Name = "blah" })); var product = await con.GetAsync <Product>(id); product.Should().NotBeNull(); product.Name.Should().Be("blah"); product.Id.Should().Be(id); } }
public void SelectSingleStatement(DatabaseDriver database) { using var con = database.GetConnection(); // Arrange var lead = InsertLead(con); // Act lead.Data !.FirstName = "Bar"; con.Update(lead); // Assert var updatedLead = con.Get <Lead>(lead.Id); Assert.Equal("Bar", updatedLead.Data?.FirstName); }
public void Delete(DatabaseDriver database) { using (var con = database.GetConnection()) { var id = Convert.ToInt32(con.Insert(new Product { Name = "blah" })); var product = con.Get <Product>(id); Assert.NotNull(product); Assert.Equal("blah", product.Name); Assert.Equal(id, product.Id); con.Delete(product); Assert.Null(con.Get <Product>(id)); } }
public async Task UpdateAsync(DatabaseDriver database) { using (var con = database.GetConnection()) { var product = await con.GetAsync <Product>(1); Assert.NotNull(product); product.Name = "Test"; con.Update(product); var newProduct = await con.GetAsync <Product>(1); Assert.Equal("Test", newProduct.Name); } }
public async Task GetAsync(DatabaseDriver database) { using (var con = database.GetConnection()) { var product = await con.GetAsync <Product, Category, Product>((p, c) => { p.Category = c; return(p); }, 1); Assert.NotNull(product); Assert.NotEmpty(product.Name); Assert.NotNull(product.Category); Assert.NotNull(product.Category.Name); } }
public async Task SelectSingleStatementAsync(DatabaseDriver database) { using var con = database.GetConnection(); // Arrange var lead = await InsertLeadAsync(con); // Act lead.Data !.FirstName = "Bar"; con.Update(lead); // Assert var updatedLead = con.Get <Lead>(lead.Id); Assert.NotNull(updatedLead); Assert.Equal("Bar", updatedLead !.Data?.FirstName); }
public async Task DeleteAsync(DatabaseDriver database) { using (var con = database.GetConnection()) { var id = Convert.ToInt32(await con.InsertAsync(new Product { Name = "blah" })); var product = await con.GetAsync <Product>(id); Assert.NotNull(product); Assert.Equal("blah", product.Name); Assert.Equal(id, product.Id); await con.DeleteAsync(product); Assert.Null(await con.GetAsync <Product>(id)); } }
public void InsertAll(DatabaseDriver database) { using (var con = database.GetConnection()) { var ps = new List <Foo> { new Foo { Name = "blah" }, new Foo { Name = "blah" }, new Foo { Name = "blah" }, }; con.InsertAll(ps); var blahs = con.Select <Foo>(p => p.Name == "blah"); blahs.Count().Should().Be(3); } }
public async Task DeleteMultipleAsyncLike(DatabaseDriver database) { using (var con = database.GetConnection()) { var ps = new List <Product> { new Product { Name = "blah" }, new Product { Name = "blah" }, new Product { Name = "blah" }, }; await con.InsertAllAsync(ps); Assert.Equal(3, (await con.SelectAsync <Product>(p => p.Name == "blah")).Count()); con.DeleteMultiple <Product>(p => p.Name.Contains("bla")); } }
public async Task InsertAllAsync(DatabaseDriver database) { using (var con = database.GetConnection()) { var ps = new List <Bar> { new Bar { Name = "blah" }, new Bar { Name = "blah" }, new Bar { Name = "blah" }, }; await con.InsertAllAsync(ps); var blahs = await con.SelectAsync <Bar>(p => p.Name == "blah"); blahs.Count().Should().Be(3); } }
public void DeleteMultiple(DatabaseDriver database) { using (var con = database.GetConnection()) { var ps = new List <Product> { new Product { Name = "blah" }, new Product { Name = "blah" }, new Product { Name = "blah" }, }; con.InsertAll(ps); Assert.Equal(3, con.Select <Product>(p => p.Name == "blah").Count()); con.DeleteMultiple <Product>(p => p.Name == "blah"); } }
public async Task SelectSingleStatementAsync(DatabaseDriver database) { using var con = database.GetConnection(); var lead = await InsertLeadAsync(con); }