public void IdTest() { Department target = new Department(); // TODO: Initialize to an appropriate value int expected = 0; // TODO: Initialize to an appropriate value int actual; target.Id = expected; actual = target.Id; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void ManagerTest() { Department target = new Department(); // TODO: Initialize to an appropriate value Employee expected = null; // TODO: Initialize to an appropriate value Employee actual; target.Manager = expected; actual = target.Manager; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void NameTest() { Department target = new Department(); // TODO: Initialize to an appropriate value string expected = string.Empty; // TODO: Initialize to an appropriate value string actual; target.Name = expected; actual = target.Name; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void DepartmentConstructorTest() { Department target = new Department(); Assert.Inconclusive("TODO: Implement code to verify target"); }
public void UpsertResourceAllocations(IList<ResourceAllocationCsvItem> items) { _logger.Info("UpsertStatus called for {0} items", items.Count); // share the session - ugly this.TeamRepository.Session = this.ResourceRepository.Session = this.ResourceAllocationRepository.Session = this.ProjectRepository.Session = this.DepartmentRepository.Session; ITransaction transaction = this.ResourceAllocationRepository.BeginTransaction(); try { // clear all entries for each resource / month combination before feeding the database var grpResourceMonths = items.GroupBy(item => new {item.Name, item.Month}) ; //.Select(group => new // { // EmployeeID = group.Key.EmployeeID, // Month = group.Key.Month // }); grpResourceMonths.ToList().ForEach( grm => { var rm = grm.Key; var firstEntry = grm.First(); // lookup resource id by external id Employee resource = this.ResourceRepository.GetResourcesByName(rm.Name).FirstOrDefault() as Employee; if (resource == null) { resource = this.ResourceRepository.Add(new Employee() { FullName = firstEntry.Name, EmailAddress = String.Format("{0}@test.com", firstEntry.Name.Replace(" ", ".")) }) as Employee; var tm = this.TeamRepository.GetTeamByName(firstEntry.ResourceTeam); //if (tm == null) //{ // var department = this.DepartmentRepository.GetByName("Department"); // if (department == null) // { // department = new Department() { Name = "Department", Manager = dummyResource as Employee }; // this.DepartmentRepository.Add(department); // } // var lead = this.ResourceRepository.GetResourcesByName(firstEntry.ResourceTeamLead).SingleOrDefault() as Employee; // var t = new Team() { Name = firstEntry.Team, Lead = lead, Department = department}; // this.TeamRepository.Add(t); //} ((Employee)resource).Team = tm; this.ResourceRepository.Update(resource); // resource = this.ResourceRepository.GetResourcesByName(firstEntry.Name).FirstOrDefault(); } this.ResourceAllocationRepository.DeleteByResourceMonth(resource, rm.Month); // add allocations now? // loop through grm.ToList().ForEach(item => { // look up project first var project = this.ProjectRepository.GetProjectByName(item.Project); if (project == null) { var pItem = firstEntry; // var pTeam = this.TeamRepository.GetTeamByName() // not going to work with this file format as team id is made up var pLead = this.ResourceRepository.GetResourcesByName(pItem.ResourceTeamLead).FirstOrDefault(); if (pLead == null) { // create dummy resource Employee e = new Employee() { FullName = pItem.ResourceTeamLead }; this.ResourceRepository.Add(e); } // create dummy department var department = this.DepartmentRepository.GetByName("Department"); if (department == null) { department = new Department() { Name = "Department", Manager = pLead as Employee }; department = this.DepartmentRepository.Add(department); // department = this.DepartmentRepository.GetByName("Department"); } var team = this.TeamRepository.GetTeamByName(item.Team); if (team == null) { team = new Team() { Name = firstEntry.Team, Lead = (Employee)pLead, Department = department}; team = this.TeamRepository.Add(team); } project = new Project() { Name = item.Project, Caption = item.ProjectType, Lead = pLead as Employee, Department = department, Type = item.BudgetType, Team = team }; this.ProjectRepository.AddProject(project); project = this.ProjectRepository.GetProjectByName(item.Project); } var allocation = new ResourceAllocation { Month = item.Month, Project = project, Employee = resource, Allocation = item.AllocationPercentage }; this.ResourceAllocationRepository.Add(allocation); }); } ); this.ResourceAllocationRepository.CommitTransaction(); } catch (Exception exc) { _logger.ErrorException("Unable to import from CsvResourceAllocation file", exc); this.ResourceAllocationRepository.RollbackTransaction(); throw; } finally { } }
public static void MyClassInitialize(TestContext testContext) { _config.Configure(); _kernel = new StandardKernel(new DefaultEtlNinjectModule(ConnString)); var factory = _config.CreateSessionFactory(); using (var session = factory.OpenSession()) { _employee = new Employee { FirstName = "Dave", LastName = "Neigler", EmailAddress = "*****@*****.**" }; _team = new Team { Lead = _employee, Name = "Test Team" }; _department = new Department { Name = "Operations IT" }; session.Save(_employee); session.Save(_team); session.Save(_department); } }
public void StatusReportCascadingPersistenceTest() { const string caption1 = "Status Item StatusReportCascadingPersistenceTest"; const string caption2 = "2-Status Item StatusReportCascadingPersistenceTest"; var factory = _config.CreateSessionFactory(); int srId = 0; Project project = null; Topic topic2 = null; using (var session = factory.OpenSession()) { using (var txn = session.BeginTransaction()) { var employee = new Employee { FirstName = "Dave", LastName = "Neigler", EmailAddress = "*****@*****.**" }; session.SaveOrUpdate(employee); var team = new Team { Lead = employee, Name = "Test Team" }; session.SaveOrUpdate(team); var department = new Department { Name = "Operations IT" }; session.SaveOrUpdate(department); project = new Project { Name = "Test Project StatusReportCascadingPersistenceTest", StartDate = DateTime.Parse("01/01/2012"), EndDate = DateTime.Parse("07/01/2012"), Description = "Test project description", JiraProject = "TESTPROJ", Team = team, Type = ProjectType.Grow, Department = department }; session.SaveOrUpdate(project); var topic1 = new JiraIssueTopic { JiraId = "BOTEST-StatusReportCascadingPersistenceTest", Caption = "This is the caption" }; session.SaveOrUpdate(topic1); topic2 = new JiraIssueTopic { JiraId = "2-BOTEST-StatusReportCascadingPersistenceTest", Caption = "This is the second caption" }; session.SaveOrUpdate(topic2); var sr = new StatusReport() { Caption = "Test Status Report 1", PeriodStart = new DateTime(2012, 1, 1), PeriodEnd = new DateTime(2012, 1, 7) }; sr.Items.Add(new StatusItem { Caption = caption1, Milestone = new Milestone() { ConfidenceLevel = MilestoneConfidenceLevels.Proposed, Type = MilestoneTypes.OpenItem }, Topic = topic1, Project = project }); session.SaveOrUpdate(sr); srId = sr.Id; Assert.AreNotEqual(0, srId); txn.Commit(); } using (var txn = session.BeginTransaction()) { var sr = (from r in session.Query<StatusReport>() where r.Id == srId select r).FirstOrDefault(); var statusItem = (from si in session.Query<StatusItem>() where si.Caption.Equals(caption1) select si).FirstOrDefault(); Assert.IsNotNull(statusItem); Assert.IsNotNull(statusItem.Project); Assert.IsNotNull(statusItem.Topic); // now we add more items and see if it updates properly sr.Items.Add(new StatusItem { Caption = caption2, Milestone = new Milestone() { ConfidenceLevel = MilestoneConfidenceLevels.Proposed, Type = MilestoneTypes.OpenItem }, Topic = topic2, Project = project }); session.SaveOrUpdate(sr); var statusItem2 = (from si in session.Query<StatusItem>() where si.Caption.Equals(caption2) select si).FirstOrDefault(); Assert.IsNotNull(statusItem2); Assert.IsNotNull(statusItem2.Project); Assert.IsNotNull(statusItem2.Topic); txn.Commit(); } } }
private void InitializeHelper(out Resource dummyResource, out Department department) { var windowsIdentity = WindowsIdentity.GetCurrent(); dummyResource = null; if (windowsIdentity != null) { var login = windowsIdentity.Name; dummyResource = new Employee() { WindowsLogin = login, EmailAddress = String.Format("{0}@test.com", login), FullName = "First Last" }; } else dummyResource = new Resource() { EmailAddress = "*****@*****.**", FirstName = "FN", LastName = "LN" }; this.ResourceRepository.AddResource(dummyResource); // create dummy department department = this.DepartmentRepository.GetByName("Department"); if (department == null) { department = new Department() { Name = "Department", Manager = dummyResource as Employee }; this.DepartmentRepository.Add(department); } }