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