public void Get_QC_Rule_By_Id_Test() { IQualityCheckRepository repository = new QualityCheckRepository(testDBContext); var qcRule = repository.GetQualityCheckByID(1); Assert.IsNotNull(qcRule); Assert.AreEqual(qcRule.CreatedBy, 1); Assert.AreEqual(qcRule.Description, "Test rule"); Assert.AreEqual(qcRule.EnforceOrder, true); Assert.AreEqual(qcRule.IsActive, true); Assert.AreEqual(qcRule.IsVisibleToAll, true); Assert.AreEqual(qcRule.ModifiedBy, 1); Assert.AreEqual(qcRule.Name, "Test Rule"); Assert.AreEqual(qcRule.QualityCheckId, 1); Assert.AreEqual(qcRule.Name, "Test Rule"); Assert.IsNull(qcRule.FileQualityChecks); Assert.IsNotNull(qcRule.QualityCheckColumnRules); Assert.AreEqual(qcRule.QualityCheckColumnRules.Count, 2); var selColRule = qcRule.QualityCheckColumnRules.Where(rul => rul.QualityCheckColumnRuleId == 1).FirstOrDefault(); Assert.AreEqual(selColRule.Description, "Column 1"); Assert.AreEqual(selColRule.ErrorMessage, "Col1 is required"); Assert.AreEqual(selColRule.HeaderName, "Col1"); Assert.AreEqual(selColRule.IsActive, true); Assert.AreEqual(selColRule.IsRequired, true); Assert.AreEqual(selColRule.Order, 1); Assert.AreEqual(selColRule.QualityCheckColumnRuleId, 1); Assert.AreEqual(selColRule.QualityCheckId, 1); Assert.AreEqual(selColRule.Range, ""); }
public void Get_Null_QC_Rule_By_Id_Test() { IQualityCheckRepository repository = new QualityCheckRepository(testDBContext); var qcRule = repository.GetQualityCheckByID(6); Assert.IsNull(qcRule); }
public void Update_Existing_QC_Rule_Test() { IQualityCheckRepository repository = new QualityCheckRepository(testDBContext); var selQcRule = repository.GetQualityCheckByID(1); selQcRule.Description = "Updated description"; selQcRule.EnforceOrder = false; selQcRule.IsActive = false; selQcRule.IsVisibleToAll = false; selQcRule.Name = "Updated Name"; repository.UpdateQualityCheckRule(selQcRule); testDBContext.Commit(); var updatedQcRule = repository.GetQualityCheckByID(1); Assert.AreEqual(updatedQcRule.Description, "Updated description"); Assert.AreEqual(updatedQcRule.Name, "Updated Name"); Assert.IsFalse((bool)updatedQcRule.EnforceOrder); Assert.IsFalse((bool)updatedQcRule.IsVisibleToAll); Assert.IsFalse((bool)updatedQcRule.IsActive); }
public void Add_QC_Rule_Test() { IQualityCheckRepository repository = new QualityCheckRepository(testDBContext); QualityCheckColumnRule colRule = new QualityCheckColumnRule() { Description = "Column 4", ErrorMessage = "Col1 is required", HeaderName = "Col1", IsActive = true, IsRequired = true, Order = 1, QualityCheckColumnRuleId = 1, QualityCheckColumnTypeId = 1, QualityCheckId = 2, Range = "" }; QualityCheck qcRule = new QualityCheck() { CreatedBy = 1, CreatedOn = DateTime.UtcNow, Description = "Added rule", EnforceOrder = true, FileQualityChecks = null, IsActive = true, IsVisibleToAll = true, ModifiedBy = 1, ModifiedOn = DateTime.UtcNow, Name = "Added rule", QualityCheckColumnRules = new List<QualityCheckColumnRule>() { colRule }, QualityCheckId = 2 }; repository.AddQualityCheckRule(qcRule); testDBContext.Commit(); var addedQcRule = repository.GetQualityCheckByID(2); Assert.IsNotNull(addedQcRule); Assert.AreEqual(addedQcRule.CreatedBy, qcRule.CreatedBy); Assert.AreEqual(addedQcRule.Description, qcRule.Description); Assert.AreEqual(addedQcRule.EnforceOrder, qcRule.EnforceOrder); Assert.AreEqual(addedQcRule.IsActive, qcRule.IsActive); Assert.AreEqual(addedQcRule.IsVisibleToAll, qcRule.IsVisibleToAll); Assert.AreEqual(addedQcRule.ModifiedBy, qcRule.ModifiedBy); Assert.AreEqual(addedQcRule.Name, qcRule.Name); Assert.AreEqual(addedQcRule.QualityCheckId, qcRule.QualityCheckId); Assert.AreEqual(addedQcRule.Name, qcRule.Name); Assert.IsNull(addedQcRule.FileQualityChecks); Assert.IsNotNull(addedQcRule.QualityCheckColumnRules); var selColRule = addedQcRule.QualityCheckColumnRules.Where(rul => rul.QualityCheckId == 2).FirstOrDefault(); Assert.AreEqual(selColRule.Description, colRule.Description); Assert.AreEqual(selColRule.ErrorMessage, colRule.ErrorMessage); Assert.AreEqual(selColRule.HeaderName, colRule.HeaderName); Assert.AreEqual(selColRule.IsActive, colRule.IsActive); Assert.AreEqual(selColRule.IsRequired, colRule.IsRequired); Assert.AreEqual(selColRule.Order, colRule.Order); Assert.AreEqual(selColRule.QualityCheckColumnRuleId, colRule.QualityCheckColumnRuleId); Assert.AreEqual(selColRule.QualityCheckId, colRule.QualityCheckId); Assert.AreEqual(selColRule.Range, colRule.Range); }
public void Delete_Column_Rules_QC_Rule_Test() { IQualityCheckRepository repository = new QualityCheckRepository(testDBContext); repository.DeleteColumnRules(1); testDBContext.Commit(); var ruleList = repository.GetQualityCheckByID(1); Assert.IsNotNull(ruleList); Assert.AreEqual(ruleList.QualityCheckColumnRules.Count, 0); }