コード例 #1
0
ファイル: BugManager.cs プロジェクト: cybind/Scrum-Molder
        public Bug Save(Bug bug, Guid? modifiedById = null)
        {
            try
            {
                if (bug.Id != 0)
                {
                    //var oldBug = _context.Bugs.All().Single(b => b.Id == bug.Id);
                    var oldBug = new Bug();

                    var history = new BugHistory { Id = Guid.NewGuid(), ModifiedBy = null, ModifiedDate = DateTime.Now, ModifiedById = modifiedById.Value };

                    if (oldBug.Name != bug.Name)  history.Name = oldBug.Name;

                    if (bug.History == null) bug.History = new List<BugHistory>();
                    bug.History.Add(history);
                    _context.Bugs.Update(bug);
                }
                else
                    bug = _context.Bugs.Create(bug);
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat("Exception: {0}", ex.ToString());
                return null;
            }

            return bug;
        }
コード例 #2
0
ファイル: BugManagerTest.cs プロジェクト: cybind/Scrum-Molder
        public void SaveTest()
        {
            BugManager target = new BugManager(); // TODO: Initialize to an appropriate value
            Bug bug = new Bug { Name = "test", Id = 1, ImportedBugId = 2, Description = "", Category = null, State = Enums.State.Resolved, Project = null,
                CreatedBy = null,CreateDate = DateTime.Now,Priority = Enums.Priority.Critical, Reason = Enums.Reason.Deferred}; // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value

            var actual = target.Save(bug,null);
            Assert.AreEqual(expected, actual);
        }