public async Task CreateAndReadBack(IEmployeeClassificationAsynchronousRepository <TModel> repository) { if (repository == null) { throw new ArgumentNullException("repository", "repository is null."); } var newRecord = new TModel(); newRecord.EmployeeClassificationName = "Test " + DateTime.Now.Ticks; var newKey = await repository.CreateAsync(newRecord); Assert.True(newKey >= 1000); //keys under 1000 were not generated by the database var echo = await repository.GetByKeyAsync(newKey); Assert.Equal(newKey, echo.EmployeeClassificationKey); Assert.Equal(newRecord.EmployeeClassificationName, echo.EmployeeClassificationName); var search = await repository.FindByNameAsync(newRecord.EmployeeClassificationName); Assert.Equal(newKey, search.EmployeeClassificationKey); Assert.Equal(newRecord.EmployeeClassificationName, search.EmployeeClassificationName); }
public async Task GetAll(IEmployeeClassificationAsynchronousRepository <TModel> repository) { if (repository == null) { throw new ArgumentNullException("repository", "repository is null."); } var all = await repository.GetAllAsync(); Assert.NotNull(all); Assert.NotEmpty(all); }
public async Task GetByKey(IEmployeeClassificationAsynchronousRepository <TModel> repository) { if (repository == null) { throw new ArgumentNullException("repository", "repository is null."); } var ec1 = await repository.GetByKeyAsync(1); var ec2 = await repository.GetByKeyAsync(2); var ec3 = await repository.GetByKeyAsync(3); Assert.Equal(1, ec1.EmployeeClassificationKey); Assert.Equal(2, ec2.EmployeeClassificationKey); Assert.Equal(3, ec3.EmployeeClassificationKey); }
public async Task CreateAndDelete(IEmployeeClassificationAsynchronousRepository <TModel> repository) { if (repository == null) { throw new ArgumentNullException("repository", "repository is null."); } var newRecord = new TModel(); newRecord.EmployeeClassificationName = "Test " + DateTime.Now.Ticks; var newKey = await repository.CreateAsync(newRecord); Assert.True(newKey >= 1000); //keys under 1000 were not generated by the database await repository.DeleteAsync(newKey); var all = await repository.GetAllAsync(); Assert.False(all.Any(ec => ec.EmployeeClassificationKey == newKey)); }