public void AddReferenceRangeTest_Success() { StandardReference stdReference = new StandardReference() { Title = "testStdReferenceTitle" }; _unitOfWork.StandardReferences.Add(stdReference); _unitOfWork.Complete(); string message = string.Empty; var result = _target.GetReferenceRangeByID(1, out message); Assert.IsNull(result); ReferenceRange referenceRange = new ReferenceRange() { Title = "Test", Result = "Testing 123", StandardReferenceID = 1 }; var saveResult = _target.AddReferenceRange(referenceRange, out message); Assert.IsNotNull(saveResult); Assert.AreEqual(string.Empty, message); result = _target.GetReferenceRangeByID(1, out message); Assert.IsNotNull(result); Assert.AreEqual("Test", result.Title); }
public void DeleteReferenceRangeTest_Success() { StandardReference stdReference = new StandardReference() { Title = "testStdReferenceTitle" }; ReferenceRange referenceRange = new ReferenceRange() { Title = "Test", Result = "Testing 123", }; stdReference.ReferenceRanges.Add(referenceRange); _unitOfWork.StandardReferences.Add(stdReference); _unitOfWork.Complete(); string message = string.Empty; referenceRange = _target.GetReferenceRangeByID(1, out message); Assert.IsNotNull(stdReference); var saveResult = _target.DeleteReferenceRange(1, out message); Assert.IsTrue(saveResult); var result = _target.GetReferenceRangeByID(1, out message); Assert.IsNull(result); Assert.AreEqual("Invalid Reference Range ID", message); }
public void GetReferenceRangeByIDTest_NoRecord() { StandardReference stdReference = new StandardReference() { Title = "testStdReferenceTitle" }; ReferenceRange referenceRange = new ReferenceRange() { Title = "Test", Result = "Testing 123", }; stdReference.ReferenceRanges.Add(referenceRange); _unitOfWork.StandardReferences.Add(stdReference); _unitOfWork.Complete(); string message = string.Empty; var result = _target.GetReferenceRangeByID(3, out message); Assert.IsNull(result); Assert.AreEqual("Invalid Reference Range ID", message); }
public void GetReferenceRange_MinValueSuccess() { StandardReference standardReference = new StandardReference() { Title = "Test" }; ReferenceRange referenceRangeOne = new ReferenceRange() { Title = "Underweight", MinimumValue = 0, MaximumValue = 18.4, Result = "NORMAL" }; _unitOfWork.StandardReferences.Add(standardReference); _unitOfWork.Complete(); standardReference.ReferenceRanges.Add(referenceRangeOne); _unitOfWork.Complete(); string message = string.Empty; ReferenceRange result = _target.GetReferenceRange(1, 0, out message); Assert.IsNotNull(result); Assert.AreEqual("Underweight", result.Title); }
public void UpdateStandardReferenceTest_ExistingTitleReturnError() { string message = string.Empty; StandardReference stdReference = new StandardReference() { Title = "testStdReferenceTitle" }; var saveResult = _target.AddStandardReference(stdReference, out message); Assert.IsNotNull(saveResult); Assert.AreEqual(string.Empty, message); StandardReference stdReference1 = new StandardReference() { Title = "testStdReferenceTitle1" }; saveResult = _target.AddStandardReference(stdReference1, out message); Assert.IsNotNull(saveResult); Assert.AreEqual(string.Empty, message); stdReference1.Title = "testStdReferenceTitle"; var updateResult = _target.UpdateStandardReference(stdReference1, out message); Assert.IsFalse(updateResult); Assert.AreEqual("Standard Reference Title already exists", message); }
public void UpdateStandardReferenceTest_NullOrEmptyTitleReturnError() { string message = string.Empty; StandardReference stdReference = new StandardReference() { Title = "testStdReferenceTitle" }; var saveResult = _target.AddStandardReference(stdReference, out message); Assert.IsNotNull(saveResult); Assert.AreEqual(string.Empty, message); stdReference.Title = null; var updateResult = _target.UpdateStandardReference(stdReference, out message); Assert.IsFalse(updateResult); Assert.AreEqual("Please fill in all required fields", message); stdReference.Title = string.Empty; updateResult = _target.UpdateStandardReference(stdReference, out message); Assert.IsFalse(updateResult); Assert.AreEqual("Please fill in all required fields", message); stdReference.Title = " "; updateResult = _target.UpdateStandardReference(stdReference, out message); Assert.IsFalse(updateResult); Assert.AreEqual("Please fill in all required fields", message); }
public void AddStandardReferenceTest_NullStandardReferenceReturnError() { string message = string.Empty; StandardReference stdReference = null; var saveResult = _target.AddStandardReference(stdReference, out message); Assert.IsNull(saveResult); Assert.AreEqual("Please fill in all required fields", message); }
public override int GetHashCode() { unchecked { const int hashBase = (int)2166136261; const int multiplier = 16777619; int hash = hashBase; hash = (hash * multiplier) ^ StandardCode.GetHashCode(); hash = (hash * multiplier) ^ (StandardReference is null ? 0 : StandardReference.GetHashCode()); hash = (hash * multiplier) ^ (CourseOption is null ? 0 : CourseOption.GetHashCode()); return(hash); } }
public override int GetHashCode() { unchecked { const int hashBase = (int)2166136261; const int multiplier = 16777619; int hash = hashBase; hash = (hash * multiplier) ^ Uln.GetHashCode(); hash = (hash * multiplier) ^ StandardCode.GetHashCode(); hash = (hash * multiplier) ^ (StandardReference is null ? 0 : StandardReference.GetHashCode()); hash = (hash * multiplier) ^ (FamilyName is null ? 0 : FamilyName.GetHashCode()); hash = (hash * multiplier) ^ (CertificateReference is null ? 0 : CertificateReference.GetHashCode()); return(hash); } }
public void AddStandardReferenceTest_Success() { string message = string.Empty; StandardReference stdReference = new StandardReference() { Title = "testStdReferenceTitle" }; var saveResult = _target.AddStandardReference(stdReference, out message); Assert.IsNotNull(saveResult); Assert.AreEqual(string.Empty, message); var expectedResult = _target.GetStandardReferenceByID(saveResult.StandardReferenceID, out message); Assert.IsNotNull(expectedResult); Assert.AreEqual("testStdReferenceTitle", expectedResult.Title); }
public ActionResult Edit([Bind(Include = "StandardReferenceID,Title,DataType")] StandardReference standardReference) { if (!IsUserAuthenticated()) { return(RedirectToLogin()); } string message = string.Empty; using (var standardReferenceManager = new StandardReferenceManager(GetLoginUser())) { if (standardReferenceManager.UpdateStandardReference(standardReference, out message)) { SetTempDataMessage(Constants.ValueSuccessfuly("Standard Reference " + standardReference.Title + " has been updated")); return(RedirectToAction("Index")); } SetViewBagError(message); return(View(standardReference)); } }
// GET: Admin/StandardReference/Details/5 public ActionResult Details(int id = 0) { if (!IsUserAuthenticated()) { return(RedirectToLogin()); } string message = string.Empty; using (var standardReferenceManager = new StandardReferenceManager()) { StandardReference standardReference = standardReferenceManager.GetStandardReferenceByID(id, out message); if (standardReference == null) { SetViewBagError(message); return(RedirectToAction("Index")); } return(View(standardReference)); } }
public bool UpdateStandardReference(StandardReference standardReference, out string message) { message = string.Empty; if (standardReference == null) { message = Constants.PleaseFillInAllRequiredFields(); return(false); } if (string.IsNullOrEmpty(standardReference.Title) || string.IsNullOrEmpty(standardReference.Title.Trim())) { message = Constants.PleaseFillInAllRequiredFields(); return(false); } if (StandardReferenceExists(standardReference.Title, standardReference.StandardReferenceID, out message)) { message = "Standard Reference Title already exists"; return(false); } try { using (var unitOfWork = CreateUnitOfWork()) { var standardReferenceToUpdate = unitOfWork.StandardReferences.GetStandardReference(standardReference.StandardReferenceID); Util.CopyNonNullProperty(standardReference, standardReferenceToUpdate); using (TransactionScope scope = new TransactionScope()) { unitOfWork.Complete(); scope.Complete(); } } message = string.Empty; return(true); } catch (Exception ex) { ExceptionLog(ex); message = Constants.OperationFailedDuringUpdatingValue("Standard Reference"); return(false); } }
public StandardReference AddStandardReference(StandardReference standardReference, out string message) { message = string.Empty; if (standardReference == null) { message = Constants.PleaseFillInAllRequiredFields(); return(null); } if (string.IsNullOrEmpty(standardReference.Title) || string.IsNullOrEmpty(standardReference.Title.Trim())) { message = Constants.PleaseFillInAllRequiredFields(); return(null); } if (StandardReferenceExists(standardReference.Title, standardReference.StandardReferenceID, out message)) { message = "Standard Reference already exists"; return(null); } try { using (var unitOfWork = CreateUnitOfWork()) { using (TransactionScope scope = new TransactionScope()) { unitOfWork.StandardReferences.Add(standardReference); unitOfWork.Complete(); scope.Complete(); } message = string.Empty; return(standardReference); } } catch (Exception ex) { ExceptionLog(ex); message = Constants.OperationFailedDuringAddingValue("Standard Reference"); return(null); } }
public void GetReferenceRange_NoMatch() { StandardReference standardReference = new StandardReference() { Title = "Test" }; ReferenceRange referenceRangeOne = new ReferenceRange() { Title = "Underweight", MinimumValue = 0, MaximumValue = 18.4, Result = "NORMAL" }; ReferenceRange referenceRangetwo = new ReferenceRange() { Title = "Normal", MinimumValue = 18.5, MaximumValue = 24.9, Result = "NORMAL" }; _unitOfWork.StandardReferences.Add(standardReference); _unitOfWork.Complete(); standardReference.ReferenceRanges.Add(referenceRangeOne); standardReference.ReferenceRanges.Add(referenceRangetwo); _unitOfWork.Complete(); string message = string.Empty; ReferenceRange result = _target.GetReferenceRange(1, 25.0, out message); Assert.IsNull(result); Assert.AreEqual("Unable to find reference range", message); }
public void DeleteStandardReferenceTest_Success() { string message = string.Empty; StandardReference stdReference = new StandardReference() { Title = "testStdReferenceTitle" }; //ReferenceRange refrange1 = new ReferenceRange() //{ // Title = "normal", // MinimumValue = 20, // MaximumValue = 120, // Result = "normal" //}; //ReferenceRange refrange2 = new ReferenceRange() //{ // Title = "normal", // MinimumValue = 20, // MaximumValue = 120, // Result = "normal" //}; var saveResult = _target.AddStandardReference(stdReference, out message); Assert.IsNotNull(saveResult); Assert.AreEqual(string.Empty, message); var deleteResult = _target.DeleteStandardReference(stdReference.StandardReferenceID, out message); Assert.IsTrue(deleteResult); Assert.AreEqual(string.Empty, message); var expectedResult = _target.GetStandardReferenceByID(stdReference.StandardReferenceID, out message); Assert.IsNull(expectedResult); Assert.AreEqual("Invalid Standard Reference ID", message); }
// GET: Admin/StandardReference/CreateReferenceRange public ActionResult CreateReferenceRange(int standardReferenceID = 0) { if (!IsUserAuthenticated()) { return(RedirectToLogin()); } string message = string.Empty; using (var standardReferenceManager = new StandardReferenceManager()) { StandardReference standardReference = standardReferenceManager.GetStandardReferenceByID(standardReferenceID, out message); if (standardReference == null) { SetViewBagError("Invalid Standard Reference ID. Create Standard Reference first."); return(View()); } ReferenceRange referenceRange = new ReferenceRange(); referenceRange.StandardReferenceID = standardReferenceID; return(View(referenceRange)); } }