public void Add(IBacklogTask backlogTask) { var contextHelper = new DbContextHelper(); using (var dbContext = new ProSManContext(contextHelper.CreateNewContextOptions())) { contextHelper.FillData(dbContext, backlogTask.ProjectId); #region Mock dependencies var mapper = new MapperConfiguration(cfg => { cfg.AddProfile(new BacklogTaskProfile()); }).CreateMapper(); #endregion var backlogTaskService = new BacklogTaskService(dbContext, mapper); backlogTaskService.Add(backlogTask); var backlogEntity = dbContext.BacklogTasks .FirstOrDefault(); Assert.Equal(backlogTask.Name, backlogEntity.Name); Assert.Equal(backlogTask.Description, backlogEntity.Description); Assert.Equal(backlogTask.ProjectId, backlogEntity.ProjectId); } }
public void GetOverviewProject(IdentifierBase <Guid> identifierModel) { var contextHelper = new DbContextHelper(); using (var dbContext = new ProSManContext(contextHelper.CreateNewContextOptions())) { contextHelper.FillData(dbContext, identifierModel.Id, true, new ExtraEntitiesModel { Count = 2 }); var dashboardService = new DashboardService(dbContext); var overviewProject = dashboardService.GetOverviewProject(identifierModel.Id); Assert.True(overviewProject != null); Assert.True(overviewProject.AverageTasksInSprint > 0); Assert.True(overviewProject.TotalBacklogTasks > 0); Assert.True(overviewProject.TotalNonSprintTasks > 0); Assert.True(overviewProject.TotalSprints > 0); Assert.True(overviewProject.AverageHoursInSprint > 0); // check round to two digits after comma Assert.Equal(overviewProject.AverageTasksInSprint, Math.Round(overviewProject.AverageTasksInSprint, 2)); Assert.Equal(overviewProject.AverageHoursInSprint, Math.Round(overviewProject.AverageHoursInSprint, 2)); } }
public CategoryController(ILoggerFactory loggerFactory, ProSManContext dbContext, IMapper autoMapper, IMediator mediator ) : base(loggerFactory) { _dbContext = dbContext; _mapper = autoMapper; _mediator = mediator; }
public AuthorizationController(ILoggerFactory loggerFactory, SignInManager <User> signInManager, UserManager <User> userManager, IAuthorizationService authorizationService, ProSManContext dbContext, IOptions <IdentityOptions> identityOptions ) { _signInManager = signInManager; _userManager = userManager; _dbContext = dbContext; _identityOptions = identityOptions; }
public void GetDashboard(IdentifierBase <Guid> identifierModel) { var contextHelper = new DbContextHelper(); using (var dbContext = new ProSManContext(contextHelper.CreateNewContextOptions())) { contextHelper.FillData(dbContext, identifierModel.Id); var dashboardService = new DashboardService(dbContext); var dasboard = dashboardService.GetDashboard(EntityNameConstants.User); var project = dbContext.Projects .Where(c => c.Id == identifierModel.Id) .FirstOrDefault(); Assert.True(dasboard != null); Assert.True(dasboard.Projects != null); Assert.True(dasboard.Projects.Count > 0); } }
public void GetCategoryDashboard(IdentifierBase <Guid> identifierModel) { var contextHelper = new DbContextHelper(); using (var dbContext = new ProSManContext(contextHelper.CreateNewContextOptions())) { contextHelper.FillData(dbContext, identifierModel.Id); var dashboardService = new DashboardService(dbContext); var categoryDashboard = dashboardService.GetCategoryDashboard(identifierModel.Id); var category = dbContext.Categories .Where(c => c.ProjectId == identifierModel.Id) .FirstOrDefault(); Assert.True(categoryDashboard != null); Assert.True(categoryDashboard.Count > 0); Assert.Contains(categoryDashboard, cd => cd.Name == category.Name); } }
public BacklogTaskService(ProSManContext context, IMapper mapper) { _dbContext = context; _mapper = mapper; }
public SprintService(ProSManContext context, IMapper mapper) { _dbContext = context; _mapper = mapper; }
public DashboardService(ProSManContext context) { _dbContext = context; }
public void FillData(ProSManContext context, Guid randomGuid, bool needToFillTasks = false, ExtraEntitiesModel extraEntitiesModel = null) { context.Users.Add(new User { Id = randomGuid.ToString(), PasswordHash = "", UserName = EntityNameConstants.User }); context.Projects.Add(new Project { Id = randomGuid, Name = EntityNameConstants.Project, UserId = randomGuid.ToString() }); context.Sprints.Add(new Sprint { Id = randomGuid, Name = EntityNameConstants.Sprint, ProjectId = randomGuid, FromDate = new DateTime() }); context.Categories.Add(new Category { Id = randomGuid, Name = EntityNameConstants.Category, ProjectId = randomGuid }); if (needToFillTasks) { context.Tasks.Add(new Task { Id = randomGuid, CategoryId = randomGuid, ProjectId = randomGuid, SprintId = randomGuid, Name = EntityNameConstants.Task, TimeEstimate = 5 }); context.BacklogTasks.Add(new BacklogTask { Id = randomGuid, ProjectId = randomGuid, Name = EntityNameConstants.BacklogTask }); context.NonSprintTasks.Add(new NonSprintTask { Id = randomGuid, ProjectId = randomGuid, Name = EntityNameConstants.NonSprintTask }); } if (extraEntitiesModel != null) { for (int i = 0; i < extraEntitiesModel.Count; i++) { context.Sprints.Add(new Sprint { Id = Guid.NewGuid(), Name = EntityNameConstants.ExtraSprint, ProjectId = randomGuid, FromDate = new DateTime().AddDays(1) }); } } context.SaveChanges(); }
public CategoryService(ProSManContext context, IMapper mapper) { _dbContext = context; _mapper = mapper; }