Ejemplo n.º 1
0
        public void Insert(Defect defect)
        {
            defect.DateLogged = DateTime.Now;

            _repository.Insert(defect);
            _repository.Save();
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        public void Update(Defect defect)
        {
            _repository.Update(defect);

            if (defect.Comments.Any())
            {
                var comment = defect.Comments.First();
                _commentRepository.Insert(comment);
            }

            _repository.Save();
        }
Ejemplo n.º 4
0
        public void CssClass()
        {
            var defect = new Defect
            {
                Status = new Status
                {
                    CssClass = "info"
                }
            };

            var result = Mapper.Map<DefectListItem>(defect);

            Assert.Equal("info", result.CssClass);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }