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); }
public BugServiceTests() { _bug = new Domain.Entity.Bug { Name = "Simple Bug" }; _bugRepository = new Mock <IRepository <Data.Entity.Bug> >(); _bugService = new BugService(_bugRepository.Object); }
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]); }
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]); }
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]); }
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); }
public void Update(Domain.Entity.Bug bug) { var dataBug = MapToData(bug); _bugRepository.Update(dataBug); }
public Guid Insert(Domain.Entity.Bug bug) { var dataBug = MapToData(bug); return(_bugRepository.Insert(dataBug)); }