public async Task Repository_GetAll_Should_Return_All_Records() { // Arrange var configurationHelper = new ConfigurationHelper(); var dbContext = new DatabaseContext(configurationHelper); var session = SessionFixture.Create(); var sample1 = SampleFixture.Create(); sample1.Session = session; var sample2 = SampleFixture.Create(); sample2.Session = session; await dbContext.Samples.AddRangeAsync(sample1, sample2); await dbContext.SaveChangesAsync(); var playerRepository = new SampleRepository(new DatabaseContext(configurationHelper)); // Act var result = await playerRepository.GetAll(); // Assert result.Should().NotBeNull(); result.Should().HaveCount(2); result[0].Session.Should().BeNull(); result[1].Session.Should().BeNull(); result.Should().ContainEquivalentOf(sample1, c => c.Excluding(x => x.Session)); result.Should().ContainEquivalentOf(sample2, c => c.Excluding(x => x.Session)); }
public ActionResult List(int page = 1) { int pageSize = 10; int pageNumber = page; SampleRepository r = new SampleRepository(); var sampleList = r.GetAll(); var model = sampleList.ToPagedList(pageNumber, pageSize); return(View(model)); }
public void GetAll_AfterRequestToEmptySampleRepository_ShouldReturnDefault() { //Arrange var sampleRepo = new SampleRepository(_context); //Act var samples = sampleRepo.GetAll(); //Assert Assert.That(samples, Is.Not.Null); Assert.That(samples, Has.Exactly(0).Items); }
// GET: Dasboard public ActionResult Index(int page = 1) { int pageSize = 10; int pageNumber = page; List <SampleModel> listSamples = new List <SampleModel>(); SampleRepository s = new SampleRepository(); listSamples = s.GetAll(); var model = listSamples.ToPagedList(pageNumber, pageSize); return(View(model)); }
/// <summary> /// Gets all the Sample Models /// </summary> /// <param name="includeInactives">determines if method retrieves inactive sample models</param> /// <returns></returns> public IEnumerable <SampleModel> GetAll(bool includeInactives = false) { return(_sampleRepository.GetAll(includeInactives)); }