/// <summary> /// saves a new bugreport /// </summary> /// <param name="model">the BugreportItemViewModel with the report data</param> /// <returns>true if saving was successfull, otherwise false</returns> public void Save( BugreportItemViewModel model ) { ml_Bugreport bug = new ml_Bugreport() { Email = model.EmailAddress, Report = model.Feedback, ResolutionStatus = (int)muscle_log.framework.Util.Enum.BugreportResolution.Open, CRDT = DateTime.Now, LUDT = DateTime.Now }; _repo.Insert(bug); }
public void DeleteEntityByIDTest() { DateTime timeOfInsert = DateTime.Now; var entity = new ml_Bugreport(); entity.CRDT = timeOfInsert; entity.Email = "*****@*****.**"; entity.LUDT = timeOfInsert; entity.Report = "Testreport"; entity.ResolutionStatus = (int)muscle_log.framework.Util.Enum.BugreportResolution.Open; _context.ml_Bugreport.Add(entity); _unitOfWork.SaveChanges(); int countBeforeDelete = _context.ml_Bugreport.Count(); int id = entity.ID; _repository.Delete(id); _unitOfWork.SaveChanges(); Assert.AreEqual(countBeforeDelete - 1, _context.ml_Bugreport.Count()); }
public void GetAllWithPredicateMatchingEntitiesTest() { var timeOfInsert = DateTime.Now; var entity = new ml_Bugreport(); entity.CRDT = timeOfInsert; entity.Email = "*****@*****.**"; entity.LUDT = timeOfInsert; entity.Report = "Testreport1"; entity.ResolutionStatus = (int)muscle_log.framework.Util.Enum.BugreportResolution.Open; _context.ml_Bugreport.Add(entity); _addedEntities.Add(entity); timeOfInsert = DateTime.Now; entity = new ml_Bugreport(); entity.CRDT = timeOfInsert; entity.Email = "*****@*****.**"; entity.LUDT = timeOfInsert; entity.Report = "Testreport2"; entity.ResolutionStatus = (int)muscle_log.framework.Util.Enum.BugreportResolution.Open; _context.ml_Bugreport.Add(entity); _addedEntities.Add(entity); _unitOfWork.SaveChanges(); var entityCount = _repository.GetAll(x => x.Report.Contains("Testreport")).Count(); Assert.IsTrue(entityCount >= 2); }
private void AddDummyEntities() { var timeOfInsert = DateTime.Now; var entity = new ml_Bugreport(); entity.CRDT = timeOfInsert; entity.Email = "*****@*****.**"; entity.LUDT = timeOfInsert; entity.Report = "Testreport1"; entity.ResolutionStatus = (int)muscle_log.framework.Util.Enum.BugreportResolution.Open; _context.ml_Bugreport.Add(entity); _addedEntities.Add(entity); entity = new ml_Bugreport(); entity.CRDT = timeOfInsert; entity.Email = "*****@*****.**"; entity.LUDT = timeOfInsert; entity.Report = "Testreport2"; entity.ResolutionStatus = (int)muscle_log.framework.Util.Enum.BugreportResolution.Open; _context.ml_Bugreport.Add(entity); _addedEntities.Add(entity); entity = new ml_Bugreport(); entity.CRDT = timeOfInsert; entity.Email = "*****@*****.**"; entity.LUDT = timeOfInsert; entity.Report = "Testreport3"; entity.ResolutionStatus = (int)muscle_log.framework.Util.Enum.BugreportResolution.Open; _context.ml_Bugreport.Add(entity); _addedEntities.Add(entity); _unitOfWork.SaveChanges(); }
public void UpdateNotExistingEntityTest() { int freeID = -1; // find non-existant ID for (int i = 1; i < Int32.MaxValue; i++) { if (_context.ml_Bugreport.Where(b => b.ID == i).FirstOrDefault() == null) { freeID = i; break; } } if (freeID == -1) { throw new Exception("No free ID found."); } DateTime timeOfInsert = DateTime.Now; var entity = new ml_Bugreport(); entity.ID = freeID; entity.CRDT = timeOfInsert; entity.Email = "*****@*****.**"; entity.LUDT = timeOfInsert; entity.Report = "Testreport"; entity.ResolutionStatus = (int)muscle_log.framework.Util.Enum.BugreportResolution.Open; var itemsBeforeUpdate = _context.ml_Bugreport.Count(); _repository.Update(entity); _unitOfWork.SaveChanges(); Assert.AreEqual(itemsBeforeUpdate, _context.ml_Bugreport.Count()); }
public void UpdateNewEntityTest() { DateTime timeOfInsert = DateTime.Now; var entity = new ml_Bugreport(); entity.ID = -1; entity.CRDT = timeOfInsert; entity.Email = "*****@*****.**"; entity.LUDT = timeOfInsert; entity.Report = "Testreport"; entity.ResolutionStatus = (int)muscle_log.framework.Util.Enum.BugreportResolution.Open; var itemsBeforeUpdate = _context.ml_Bugreport.Count(); _repository.Update(entity); _unitOfWork.SaveChanges(); Assert.AreEqual(itemsBeforeUpdate, _context.ml_Bugreport.Count()); }
public void UpdateEntityTest() { DateTime timeOfInsert = DateTime.Now; var entity = new ml_Bugreport(); entity.ID = -1; entity.CRDT = timeOfInsert; entity.Email = "*****@*****.**"; entity.LUDT = timeOfInsert; entity.Report = "Testreport"; entity.ResolutionStatus = (int)muscle_log.framework.Util.Enum.BugreportResolution.Open; _repository.Insert(entity); _addedEntities.Add(entity); _unitOfWork.SaveChanges(); var id = entity.ID; var addedEntity = _context.ml_Bugreport.Where(b => b.ID == id).FirstOrDefault(); addedEntity.Report = "Updated Testreport"; addedEntity.LUDT = DateTime.Now; addedEntity.Email = "*****@*****.**"; addedEntity.ResolutionStatus = 1; _repository.Update(addedEntity); _unitOfWork.SaveChanges(); Assert.AreEqual(addedEntity, _context.ml_Bugreport.Where(b => b.ID == id).FirstOrDefault()); }
public void InsertEntityTest() { DateTime timeOfInsert = DateTime.Now; var entity = new ml_Bugreport(); entity.ID = -1; entity.CRDT = timeOfInsert; entity.Email = "*****@*****.**"; entity.LUDT = timeOfInsert; entity.Report = "Testreport"; entity.ResolutionStatus = (int)muscle_log.framework.Util.Enum.BugreportResolution.Open; _repository.Insert(entity); _unitOfWork.SaveChanges(); Assert.IsTrue((entity != null && entity.ID > 0)); _addedEntities.Add(entity); var bugreportFromContext = _context.ml_Bugreport.Where(r => r.ID == entity.ID).FirstOrDefault(); Assert.IsNotNull(bugreportFromContext); Assert.AreEqual(timeOfInsert, bugreportFromContext.CRDT); Assert.AreEqual(entity.Email, bugreportFromContext.Email); Assert.AreEqual(timeOfInsert, bugreportFromContext.LUDT); Assert.AreEqual(entity.Report, bugreportFromContext.Report); Assert.AreEqual(entity.ResolutionStatus, bugreportFromContext.ResolutionStatus); }
public void GetByIDTest() { var timeOfInsert = DateTime.Now; var entity = new ml_Bugreport(); entity.CRDT = timeOfInsert; entity.Email = "*****@*****.**"; entity.LUDT = timeOfInsert; entity.Report = "Testreport1"; entity.ResolutionStatus = (int)muscle_log.framework.Util.Enum.BugreportResolution.Open; _context.ml_Bugreport.Add(entity); _addedEntities.Add(entity); var entityFromRepository = _repository.Get(entity.ID); Assert.AreEqual(entity, entityFromRepository); }