public List <Issue> GetAllIssues(int page, int perPage) { try { var issues = _issueRepository.GetAll(page, perPage); issues.ForEach(x => x.WorkItem = _workItemRepository.FindByIssue(x.Id)); return(issues); } catch (Exception e) { throw new Exception(e.Message); } }
public void RemoveIssueByTransfertObject_Successfull() { var options = new DbContextOptionsBuilder <FacilityContext>() .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name) .Options; using var memoryCtx = new FacilityContext(options); var componentTypeRepository = new ComponentTypeRepository(memoryCtx); var componentType = new ComponentTypeTO { Archived = false, Name = new MultiLanguageString("Name1En", "Name1Fr", "Name1Nl"), }; var componentType2 = new ComponentTypeTO { Archived = false, Name = new MultiLanguageString("Name2En", "Name2Fr", "Name2Nl"), }; var addedComponentType1 = componentTypeRepository.Add(componentType); var addedComponentType2 = componentTypeRepository.Add(componentType2); memoryCtx.SaveChanges(); var IssueToUseInTest = new IssueTO { Description = "prout", Name = new MultiLanguageString("Issue1EN", "Issue1FR", "Issue1NL"), ComponentType = addedComponentType1, }; var IssueToUseInTest2 = new IssueTO { Description = "proutprout", Name = new MultiLanguageString("Issue2EN", "Issue2FR", "Issue2NL"), ComponentType = addedComponentType1, }; var IssueToUseInTest3 = new IssueTO { Description = "proutproutprout", Name = new MultiLanguageString("Issue3EN", "Issue3FR", "Issue3NL"), ComponentType = addedComponentType2, }; var issueRepository = new IssueRepository(memoryCtx); var f1 = issueRepository.Add(IssueToUseInTest); var f2 = issueRepository.Add(IssueToUseInTest2); memoryCtx.SaveChanges(); issueRepository.Remove(f2); memoryCtx.SaveChanges(); var retrievedIssues = issueRepository.GetAll(); Assert.AreEqual(1, retrievedIssues.Count()); Assert.IsFalse(retrievedIssues.Any(x => x.Id == 2)); }
private void ReadAll() { // Act List <Issue> issues = _repo.GetAll(); // Assert Assert.IsTrue(issues.Count > 0, "Repo returned no results"); Assert.AreEqual(TITLE, issues[issues.Count - 1].Title, "Last Item doesn't match expectation"); }
public void AddIssue_Successfull() { var options = new DbContextOptionsBuilder <FacilityContext>() .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name) .Options; using (var memoryCtx = new FacilityContext(options)) { var componentTypeRepository = new ComponentTypeRepository(memoryCtx); var componentType = new ComponentTypeTO { Archived = false, Name = new MultiLanguageString("Name1En", "Name1Fr", "Name1Nl"), }; var addedComponentType1 = componentTypeRepository.Add(componentType); memoryCtx.SaveChanges(); var IssueToUseInTest = new IssueTO { Description = "prout", Name = new MultiLanguageString("Issue1EN", "Issue1FR", "Issue1NL"), ComponentType = addedComponentType1, }; var issueRepository = new IssueRepository(memoryCtx); issueRepository.Add(IssueToUseInTest); memoryCtx.SaveChanges(); Assert.AreEqual(1, issueRepository.GetAll().Count()); var IssueToAssert = issueRepository.GetById(1); Assert.AreEqual(1, IssueToAssert.Id); Assert.AreEqual("prout", IssueToAssert.Description); } }
public void GetAllReturnsItems() { dbFactory.Run(db => { db.Insert(new Issue { Id = 1, Title = "Test Item" }); db.Insert(new Issue { Id = 2, Title = "Test Item 2" }); }); var repository = new IssueRepository(dbFactory, personRepository); var response = repository.GetAll(); Assert.IsNotNull(response); Assert.AreEqual(response.Count, 2); Assert.AreEqual(response.Single(x => x.Id == 1).Title, "Test Item"); Assert.AreEqual(response.Single(x => x.Id == 2).Title, "Test Item 2"); }
public void GetAllReturnsEmpty() { var repository = new IssueRepository(dbFactory, personRepository); var response = repository.GetAll(); Assert.IsNotNull(response); Assert.AreEqual(response.Count, 0); }