public void AddReturnsId() { var repository = new PriorityRepository(dbFactory, personRepository); var response = repository.Add(new Priority()); Assert.IsNotNull(response); Assert.AreEqual(response.Id, 1); }
/// <summary> /// Initializes a new instance of the UnitOfWork class. /// </summary> /// <param name="context">The object context</param> public UnitOfWork() { _repositories = new Dictionary <string, object>(); Colors = new ColorRepository(_dbContext); Comments = new CommentRepository(_dbContext); Labels = new LabelRepository(_dbContext); Milestones = new MilestoneRepository(_dbContext); Priorities = new PriorityRepository(_dbContext); Projects = new ProjectRepository(_dbContext); Statuses = new StatusRepository(_dbContext); Tasks = new TaskRepository(_dbContext); Users = new UserRepository(_dbContext); }
public void AddPersists() { var repository = new PriorityRepository(dbFactory, personRepository); repository.Add(new Priority { Name = "Test Item" }); dbFactory.Run(db => { var response = db.Select<Priority>(); Assert.AreEqual(response.Count, 1); Assert.AreEqual(response[0].Name, "Test Item"); }); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { AssigneeRepository assigneeRepository = new AssigneeRepository(); ddlAssignees.DataSource = assigneeRepository.GetAllAssignees(); ddlAssignees.DataBind(); PriorityRepository priorityRepository = new PriorityRepository(); ddlPriorities.DataSource = priorityRepository.GetAllPriorities(); ddlPriorities.DataBind(); FillRepeater(); } }
public void DeleteFails() { dbFactory.Run(db => db.Insert(new Priority { Id = 1, Name = "Test Item" })); var repository = new PriorityRepository(dbFactory, personRepository); repository.Delete(2); dbFactory.Run(db => { var response = db.Select<Priority>(); Assert.AreEqual(response.Count, 1); Assert.AreEqual(response[0].Name, "Test Item"); }); }
public RequisitionController() { requisition = new Requisition(); requisitionForm = new RequisitionForm(); departmentRepository = new DepartmentRepository(); periodRepository = new PeriodRepository(); priorityRepository = new PriorityRepository(); productRepository = new ProductRepository(); requisitionRepository = new RequisitionRepository(); requisitionLineRepository = new RequisitionLineRepository(); requisitionRuleRepository = new RequisitionRuleRepository(); statusRepository = new StatusRepository(); supplierRepository = new SupplierRepository(); }
public void AddNewPriority() { var priority = new Priority(); var context = new Mock <TicketDbContext>(); var dbSetMock = new Mock <DbSet <Priority> >(); context.Setup(x => x.Set <Priority>()).Returns(dbSetMock.Object); dbSetMock.Setup(x => x.Add(It.IsAny <Priority>())).Returns(priority); var repository = new PriorityRepository(context.Object); repository.Add(priority); context.Verify(x => x.Set <Priority>()); dbSetMock.Verify(x => x.Add(It.Is <Priority>(y => y == priority))); }
public List <TicketListItem> GetExtendedTickes(List <Ticket> tickets) { var listOfTickets = (from t in tickets join p in ProjectRepository.All() on t.ProjectId equals p.ProjectId join c in CategoryRepository.All() on t.CategoryId equals c.CategoryId join pp in PriorityRepository.All() on t.PriorityId equals pp.PriorityId join aa in AreaRepository.All() on t.AreaId equals aa.AreaId join u in UserRepository.All() on t.OwnerUserId equals u.Id join uu in UserRepository.All() on t.AssignedTo equals uu.Id join st in StatusRepository.All() on t.TicketStatusId equals st.TicketStatusId select new TicketListItem { TicketDetailId = t.TicketDetailId, TicketNumber = t.TicketNumber.Value, ProjectId = p.ProjectId, ProjectName = p.ProjectName, CategoryId = c.CategoryId, Category = c.Name, PriorityId = pp.PriorityId, Priority = pp.Name, AreaId = aa.AreaId, AreaName = aa.Name, Title = t.Title, UserId = t.AssignedTo, AssignedUserName = uu.UserName, OwnerUserId = t.OwnerUserId, OwnerUserName = u.UserName, LastUpdateDate = t.LastUpdateDate.Value, Content = t.Details, IsLastDetail = t.IsLastDetail, IsBillable = t.IsBillable, StatusDescription = st.Name, CreatedDate = t.CreatedDate.Value, StatusId = st.TicketStatusId, Files = new List <FileData>() }).ToList(); foreach (var ticketListItem in listOfTickets) { ticketListItem.Files = FileDataRepository.Where(f => f.TicketDetailId == ticketListItem.TicketDetailId).ToList(); } return(listOfTickets); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { AssigneeRepository ar = new AssigneeRepository(); ddlAssignee.DataSource = ar.GetAllAssignees(); ddlAssignee.DataBind(); PriorityRepository pr = new PriorityRepository(); ddlPriority.DataSource = pr.GetAllPriorities(); ddlPriority.DataBind(); StateRepository sr = new StateRepository(); ddlState.DataSource = sr.GetAllStates(); ddlState.DataBind(); TagRepository tr = new TagRepository(); cblTags.DataSource = tr.GetAllTags(); cblTags.DataBind(); } }
public List <DashBoardOpenByPriority> GetDashBoardOpenTicketByPriority(string projects) { var allProjects = ProjectRepository.All(); string[] selectedProjects = !string.IsNullOrEmpty(projects) ? projects.Split(',') : allProjects.Select(p => p.ProjectId.ToString()).ToArray(); var list = new List <DashBoardOpenByPriority>(); var priorities = PriorityRepository.All(); var tickets = TicketRepository.GetTickets(); var totalTicketCount = tickets.Count(t => selectedProjects.Contains(t.ProjectId.ToString())); foreach (var priority in priorities) { var numberOfTickets = tickets.Count(t => t.PriorityId == priority.PriorityId && selectedProjects.Contains(t.ProjectId.ToString())); var item = new DashBoardOpenByPriority() { Priority = priority.Name, NumberOfTickets = numberOfTickets, Percentage = totalTicketCount > 0 ? (numberOfTickets * 100 / totalTicketCount) : 0 }; list.Add(item); } return(list); }
public void UpdateIsSingular() { dbFactory.Run(db => { db.Insert(new Priority { Id = 1, Name = "Test Item" }); db.Insert(new Priority { Id = 2, Name = "Test Item 2" }); }); var repository = new PriorityRepository(dbFactory, personRepository); repository.Update(new Priority { Id = 1, Name = "Test Edit" }); dbFactory.Run(db => { var response = db.Select<Priority>(); Assert.AreEqual(response.Count, 2); Assert.AreEqual(response.Single(x => x.Id == 1).Name, "Test Edit"); Assert.AreEqual(response.Single(x => x.Id == 2).Name, "Test Item 2"); }); }
public void MoveShiftsIncreasing2() { dbFactory.Run(db => { db.Insert(new Priority { Id = 1, Name = "Item 1", Order = 1 }); db.Insert(new Priority { Id = 2, Name = "Item 2", Order = 2 }); db.Insert(new Priority { Id = 3, Name = "Item 3", Order = 3 }); }); var repository = new PriorityRepository(dbFactory, personRepository); repository.Move(1, -2); dbFactory.Run(db => { var response = db.Select<Priority>(); Assert.AreEqual(response.Count, 3); Assert.AreEqual(response.Single(x => x.Id == 1).Order, 3); Assert.AreEqual(response.Single(x => x.Id == 2).Order, 1); Assert.AreEqual(response.Single(x => x.Id == 3).Order, 2); }); }
public void GetByIdReturnsNull() { dbFactory.Run(db => db.Insert(new Priority { Id = 1, Name = "Test Item" })); var repository = new PriorityRepository(dbFactory, personRepository); var response = repository.GetById(2); Assert.IsNull(response); }
public void GetAllReturnsEmpty() { var repository = new PriorityRepository(dbFactory, personRepository); var response = repository.GetAll(); Assert.IsNotNull(response); Assert.AreEqual(response.Count, 0); }
public List <Priority> GetPriorities() { return(PriorityRepository.All().ToList()); }
public PriorityService(PriorityRepository repository) { _repository = repository; }
PriorityController() { repo = new PriorityRepository(); }
public void GetAllReturnsItems() { dbFactory.Run(db => { db.Insert(new Priority { Id = 1, Name = "Test Item" }); db.Insert(new Priority { Id = 2, Name = "Test Item 2" }); }); var repository = new PriorityRepository(dbFactory, personRepository); var response = repository.GetAll(); Assert.IsNotNull(response); Assert.AreEqual(response.Count, 2); Assert.AreEqual(response.Single(x => x.Id == 1).Name, "Test Item"); Assert.AreEqual(response.Single(x => x.Id == 2).Name, "Test Item 2"); }