public void RemoveSetting() { var logger = new Mock <ILogger <CasesRepository> >(); var options = new DbContextOptionsBuilder <CacidbContext>().UseInMemoryDatabase(databaseName: "CACIDB").Options; context.Database.EnsureDeleted(); using (var dbContext = new CacidbContext(options)) { dbContext.Case.Add(new Case { CaseId = 1, LastModifiedDate = DateTime.Now, CreatedDate = DateTime.Now, Title = "title 0", Description = "test 0" }); dbContext.SaveChanges(); } using (var dbContext = new CacidbContext(options)) { CasesRepository repository = new CasesRepository(dbContext, logger.Object); var caseOne = repository.GetCases().ToList().Where(m => m.CaseId == 1).FirstOrDefault(); bool result = repository.DeleteCase(caseOne); Assert.AreEqual(true, result); List <Case> cases = repository.GetCases().ToList(); Assert.AreEqual(0, cases.Count); } }
public void GetCases() { var logger = new Mock <ILogger <CasesRepository> >(); // test Get All CasesRepository repository = new CasesRepository(context, logger.Object); List <Case> cases = repository.GetCases().ToList(); Assert.AreEqual(3, cases.Count); }
private void init() { _casesRepository = new CasesRepository(); _allCases = new ObservableCollection <CaseViewModel>(); if (_casesRepository == null) { throw new ArgumentNullException("Problem with fetching Data From Database"); } this.createObservableCasesFromList(_casesRepository.GetCases(_allCasesQuery)); }