Exemplo n.º 1
0
        public static Data.Entity.Bug MapToData(Domain.Entity.Bug bug)
        {
            var result = new Data.Entity.Bug();

            result.IdBug = bug.IdBug;
            result.Name  = bug.Name;
            return(result);
        }
Exemplo n.º 2
0
 public BugServiceTests()
 {
     _bug = new Domain.Entity.Bug {
         Name = "Simple Bug"
     };
     _bugRepository = new Mock <IRepository <Data.Entity.Bug> >();
     _bugService    = new BugService(_bugRepository.Object);
 }
Exemplo n.º 3
0
        public void BugService_IsValid_return_false_when_name_is_empty()
        {
            var bug           = new Domain.Entity.Bug();
            var errorMessages = new List <string>();
            var expected      = _bugService.IsValid(bug, out errorMessages);

            Assert.IsFalse(expected);
            Assert.IsTrue(errorMessages.Any());
            Assert.AreEqual("the name of the bug cannot be empty", errorMessages[0]);
        }
Exemplo n.º 4
0
        public void BugService_IsValid_return_false_when_IdProject_is_guidEmpty()
        {
            var bug = new Domain.Entity.Bug {
                Name = "name", IdPriority = Guid.NewGuid(), IdProject = Guid.Empty
            };
            var errorMessages = new List <string>();
            var expected      = _bugService.IsValid(bug, out errorMessages);

            Assert.IsFalse(expected);
            Assert.IsTrue(errorMessages.Any());
            Assert.AreEqual("the id pf the project of the bug cannot be a guid empty", errorMessages[0]);
        }
Exemplo n.º 5
0
        public void BugService_IsValid_return_false_when_IdPriority_is_null()
        {
            var bug = new Domain.Entity.Bug {
                Name = "name", IdPriority = null
            };
            var errorMessages = new List <string>();
            var expected      = _bugService.IsValid(bug, out errorMessages);

            Assert.IsFalse(expected);
            Assert.IsTrue(errorMessages.Any());
            Assert.AreEqual("the priority of the bug cannot be null", errorMessages[0]);
        }
Exemplo n.º 6
0
        public bool IsValid(Domain.Entity.Bug bug, out List <string> errorMessages)
        {
            var result = true;

            errorMessages = new List <string>();

            if (bug == null)
            {
                errorMessages.Add("the bug cannot be null");
                return(false);
            }
            if (string.IsNullOrWhiteSpace(bug.Name))
            {
                result = false;
                errorMessages.Add("the name of the bug cannot be empty");
            }
            if (bug.IdPriority == null)
            {
                result = false;
                errorMessages.Add("the priority of the bug cannot be null");
            }
            if (bug.IdPriority == Guid.Empty)
            {
                result = false;
                errorMessages.Add("the priority of the bug cannot be a guid empty");
            }
            if (bug.IdProject == null)
            {
                result = false;
                errorMessages.Add("the id of the project of the bug cannot be null");
            }
            if (bug.IdProject == Guid.Empty)
            {
                result = false;
                errorMessages.Add("the id pf the project of the bug cannot be a guid empty");
            }

            return(result);
        }
Exemplo n.º 7
0
        public void Update(Domain.Entity.Bug bug)
        {
            var dataBug = MapToData(bug);

            _bugRepository.Update(dataBug);
        }
Exemplo n.º 8
0
        public Guid Insert(Domain.Entity.Bug bug)
        {
            var dataBug = MapToData(bug);

            return(_bugRepository.Insert(dataBug));
        }