コード例 #1
0
        public void AddEntry_Test()
        {
            // ARRANGE
            CreateSubtask();
            var subtask          = this.uow.Subtasks.Get(1);
            var project          = this.uow.Projects.Get(1);
            var entryCreateParam = new EntryCreateParam
            {
                Name    = "Test entry",
                Comment = "Test comment",
                Date    = DateTime.Now.Date,
                Started = DateTime.Now.AddHours(-2),
                Ended   = DateTime.Now.AddHours(-1)
            };
            var subtaskLogic = new SubtaskLogic();

            // ACT
            subtaskLogic.AddEntry(subtask.Id, entryCreateParam);
            subtaskLogic.Dispose();
            this.uow.Dispose();
            this.uow = new UnitOfWork();

            // ASSERT
            var inserted = this.uow.Entries.Get(1);

            Assert.IsNotNull(inserted);
            Assert.AreEqual(subtask.Id, inserted.Subtask_Id.Value);
        }
コード例 #2
0
        private void CreateEntries()
        {
            var projectTypeCreateParam = new ProjectTypeCreateParam
            {
                Name        = "Test",
                Description = "Test project type"
            };

            uow.ProjectTypes.Add(ProjectType.Create(projectTypeCreateParam));
            this.uow.Complete();

            var projectType        = this.uow.ProjectTypes.GetAll().First();
            var projectCreateParam = new ProjectCreateParam
            {
                Description = "Project description",
                Name        = "New project",
                ProjectType = projectType
            };

            uow.Projects.Add(Project.Create(projectCreateParam));
            this.uow.Complete();

            var project = this.uow.Projects.GetAll().First();
            var assignmentCreateParam = new AssignmentCreateParam
            {
                Name                   = "TestAssignment",
                DateDue                = DateTime.Now.AddDays(1),
                DatePlanned            = DateTime.Now,
                Description            = "New description",
                DurationPlannedAsTicks = new TimeSpan(1, 0, 0).Ticks,
                Project                = project
            };

            uow.Assignments.Add(Assignment.Create(assignmentCreateParam));
            this.uow.Complete();
            var assignment = this.uow.Assignments.GetAll().First();
            var subtask    = Subtask.Create(new SubtaskCreateParam
            {
                Name        = "Test subtask",
                Description = "Test description",
                Priority    = EnumDefinition.SubtaskPriority.Medium
            });

            subtask.Assignment_Id = assignment.Id;
            subtask.Assignment    = assignment;
            this.uow.Subtasks.Add(subtask);
            this.uow.Complete();

            var entryCreateParam = new EntryCreateParam
            {
                Comment = "Test comment",
                Date    = DateTime.Now.Date,
                Started = DateTime.Now.AddHours(-2),
                Ended   = DateTime.Now.AddHours(-1),
                Name    = "Test entry",
                Project = project
            };

            for (int i = 0; i < 3; i++)
            {
                this.uow.Entries.Add(Entry.Create(entryCreateParam));
            }

            this.uow.Complete();
        }