public void ValidSelect() { using var db = new SampleDb(); var data = db.Employees.SelectAll(); Assert.NotEmpty(data); }
public async void SelectAllAsync() { using var db = new SampleDb(); var employee = await db.Employees.SelectAllAsync(); Assert.Equal(5, employee.Count()); }
public async void ExistInvalid() { using var db = new SampleDb(); var result = await db.Definition.TableExistsAsync <Thing>(); result.Should <bool>().Be(false); }
public async void ExistValid() { using var db = new SampleDb(); var result = await db.Definition.TableExistsAsync <Employee>(); result.Should <bool>().Be(true); }
public async void CountAllAsync() { using var db = new SampleDb(); var employees = await db.CountAllAsync(typeof(Employee)); employees.Should <int>().BeGreaterThan(0); }
public async void CreateTable() { using var db = new SampleDb(); var result = await db.Definition.CreateTableAsync <Thing>(); result.Should <int>().Be(-1); }
public void SelectAll() { using var db = new SampleDb(); var employees = db.Employees.SelectAll(); Assert.Equal(5, employees.Count()); }
public async void DropTable() { using var db = new SampleDb(); await db.Definition.DropTableAsync <Employee>(); var result = await Utils.ExistsEmployees(); result.Should <bool>().Be(false); }
public async void InsertAsync() { var fixture = new Fixture(); using var db = new SampleDb(); var employee = fixture.Create <Employee>(); await db.Employees.InsertAsync(employee, false); Assert.NotEqual(0, employee.EmployeeId); }
public async void InsertManyAsync() { var fixture = new Fixture(); using var db = new SampleDb(); var employees = fixture.CreateMany <Employee>(5); await db.Employees.InsertManyAsync(employees, false); employees.Count().Should().Be(5); }
public async void SelectSingleAsync() { using var db = new SampleDb(); var employee = new Employee() { EmployeeId = 1 }; var employees = await db.SelectSingleAsync(employee); Assert.NotEqual(0, employee.FullName.Length); }
public void ValidUpdate() { using var db = new SampleDb(); var toUpdate = db.Employees.SelectAll().FirstOrDefault(); var newValue = new Random().Next(100); toUpdate.Children = newValue; db.Update(toUpdate); Assert.True(toUpdate.Children == newValue); }
public void InsertUpdate() { var fixture = new Fixture(); using var db = new SampleDb(); var employee = fixture.Build <Employee>() .Without(x => x.Reads) .Create(); db.Employees.Insert(employee, true); employee.Reads.Should().BeGreaterThan(0); }
/** * This method should be changed to read the user without using the library */ public static Employee?SelectEmployee(int employeeId) { var employee = new Employee { EmployeeId = employeeId }; using var db = new SampleDb(); var result = db.Employees.SelectSingle(employee); return(result ? employee : null); }
public void ValidInsert() { using var db = new SampleDb(); var data = new Employee() { FullName = "José Correa", EmailAddress = "*****@*****.**", Children = 0, DateOfBirth = new DateTime(1995, 6, 12) }; var result = db.Employees.Insert(data, false); Assert.True(data.EmployeeId != 0); }
public async void DeleteAsync() { using (var db = new SampleDb()) { var employee = new Employee() { EmployeeId = 1 }; await db.Employees.DeleteAsync(employee); } var newData = Utils.SelectEmployee(1); Assert.Null(newData); }
public async void UpdateAsync() { var fixture = new Fixture(); var employee = fixture.Build <Employee>() .With(x => x.EmployeeId, 1) .Create(); using (var db = new SampleDb()) { await db.Employees.UpdateAsync(employee); } var newValue = Utils.SelectEmployee(1); newValue.FullName.Should().Be(employee.FullName); newValue.EmailAddress.Should().Be(employee.EmailAddress); newValue.DateOfBirth.Should().BeCloseTo(employee.DateOfBirth); newValue.Children.Should().Be(employee.Children); newValue.Reads.Should().Be(employee.Reads); }
public async void CreateTableStringKey() { using var db = new SampleDb(); await Assert.ThrowsAsync <SqlException> (() => db.Definition.CreateTableAsync <ThingStringKey>()); }
public async void DropInvalidTable() { using var db = new SampleDb(); await Assert.ThrowsAsync <SqlException>( () => db.Definition.DropTableAsync <Thing>()); }
public void ValidConnection() { using var db = new SampleDb(); Assert.True(db.Connection?.State == System.Data.ConnectionState.Open); }