public void Insert(Defect defect) { defect.DateLogged = DateTime.Now; _repository.Insert(defect); _repository.Save(); }
public void InsertShouldOverrideGivenDate() { var defect = new Defect { DateLogged = new DateTime(2010, 1, 1) }; _defectRepository.Setup(x => x.Insert(It.IsAny<Defect>())).Callback<Defect>(d => defect = d); _service.Insert(defect); Assert.Equal(defect.DateLogged.Year, DateTime.Now.Year); }
public void Update(Defect defect) { _repository.Update(defect); if (defect.Comments.Any()) { var comment = defect.Comments.First(); _commentRepository.Insert(comment); } _repository.Save(); }
public void CssClass() { var defect = new Defect { Status = new Status { CssClass = "info" } }; var result = Mapper.Map<DefectListItem>(defect); Assert.Equal("info", result.CssClass); }
private static void MapComment(DefectForm form, Defect defect) { if (string.IsNullOrEmpty(form.Comment)) return; var comment = new Comment { CommentDate = DateTime.Now, DefectId = form.Id, CommentText = form.Comment, UserId = form.UserId }; defect.Comments.Add(comment); }
public void TesterName() { var defect = new Defect { Tester = new User { FirstName = "Bill", LastName = "Smith" } }; var result = Mapper.Map<DefectListItem>(defect); Assert.Equal("B. Smith", result.TesterName); }