public void TestContains() { TVerificationResult res1; TScreenVerificationResult res2; TVerificationResultCollection coll = new TVerificationResultCollection(); // Contains(IResultInterface) res1 = new TVerificationResult(null, "test1", TResultSeverity.Resv_Noncritical); Assert.IsFalse(coll.Contains(res1), "should not contain res1"); coll.Add(res1); Assert.IsTrue(coll.Contains(res1), "should contain res1"); // Contains(string AResultContext) res1 = new TVerificationResult("testcontext", "testresulttext", "testcaption", "testresultcode", TResultSeverity.Resv_Noncritical); Assert.IsFalse(coll.Contains("testcontext"), "should not contain testcontext"); coll.Add(res1); Assert.IsTrue(coll.Contains("testcontext"), "should contain testcontext (by string)"); // Contains(object AResultContext) with a control TextBox txtTest1 = new TextBox(); res2 = new TScreenVerificationResult(txtTest1, null, "test1", "t1", txtTest1, TResultSeverity.Resv_Noncritical); Assert.IsFalse(coll.Contains(txtTest1), "should not contain txtTest1 box"); coll.Add(res2); Assert.IsTrue(coll.Contains(txtTest1), "should contain txtTest1 box"); // Contains(DataColumn) DataColumn col = new DataColumn("test", typeof(int)); Assert.IsFalse(coll.Contains(col), "should not contain col"); res2 = new TScreenVerificationResult(null, col, "test1", null, TResultSeverity.Resv_Noncritical); coll.Add(res2); Assert.IsTrue(coll.Contains(col), "should contain col"); // Contains(DataTable) DataTable tab = new DataTable("test"); DataColumn col2 = new DataColumn("test2", typeof(string)); tab.Columns.Add(col2); Assert.IsFalse(coll.Contains(tab), "should not contain tab"); res2 = new TScreenVerificationResult(null, col2, "test1", null, TResultSeverity.Resv_Noncritical); coll.Add(res2); Assert.IsTrue(coll.Contains(tab), "should contain tab"); }
private void ValidateDataManual(PSubscriptionRow ARow) { DataColumn ValidationColumn; TValidationControlsData ValidationControlsData; TVerificationResult VerificationResult = null; bool NoClearingOfVerificationResult = false; TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection; if (!chkChangeReasonSubsGivenCode.Checked) { if (VerificationResultCollection.Contains(ARow.Table.Columns[PSubscriptionTable.ColumnReasonSubsGivenCodeId])) { VerificationResultCollection.Remove(ARow.Table.Columns[PSubscriptionTable.ColumnReasonSubsGivenCodeId]); } } if (!chkChangeStartDate.Checked) { if (VerificationResultCollection.Contains(ARow.Table.Columns[PSubscriptionTable.ColumnStartDateId])) { VerificationResultCollection.Remove(ARow.Table.Columns[PSubscriptionTable.ColumnStartDateId]); } } // if 'SubscriptionStatus' is CANCELLED or EXPIRED then 'Reason Ended' and 'End Date' must be set ValidationColumn = ARow.Table.Columns[PSubscriptionTable.ColumnSubscriptionStatusId]; if (FPetraUtilsObject.ValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if ((!ARow.IsSubscriptionStatusNull()) && ((ARow.SubscriptionStatus == "CANCELLED") || (ARow.SubscriptionStatus == "EXPIRED"))) { if (ARow.IsReasonSubsCancelledCodeNull() || (ARow.ReasonSubsCancelledCode == String.Empty)) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_REASONENDEDMANDATORY_WHEN_EXPIRED)), ValidationColumn, ValidationControlsData.ValidationControl); } else if (ARow.IsDateCancelledNull()) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_DATEENDEDMANDATORY_WHEN_EXPIRED)), ValidationColumn, ValidationControlsData.ValidationControl); } } else { // if 'SubscriptionStatus' is not CANCELLED or EXPIRED then 'Reason Ended' and 'End Date' must NOT be set if (chkChangeReasonSubsCancelledCode.Checked) { if ((ARow.IsReasonSubsCancelledCodeNull()) || (ARow.ReasonSubsCancelledCode == String.Empty)) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_REASONENDEDSET_WHEN_ACTIVE)), ValidationColumn, ValidationControlsData.ValidationControl); } } else if (!chkChangeReasonSubsCancelledCode.Checked) { if (ARow.SubscriptionStatus != String.Empty) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_REASONENDEDSET_WHEN_ACTIVE)), ValidationColumn, ValidationControlsData.ValidationControl); VerificationResult.OverrideResultText(Catalog.GetString( "Reason Ended must be cleared when a Subscription is made active.")); NoClearingOfVerificationResult = true; } } if ((!ARow.IsReasonSubsCancelledCodeNull()) && (ARow.ReasonSubsCancelledCode != String.Empty)) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_REASONENDEDSET_WHEN_ACTIVE)), ValidationColumn, ValidationControlsData.ValidationControl); } else if (!ARow.IsDateCancelledNull()) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_DATEENDEDSET_WHEN_ACTIVE)), ValidationColumn, ValidationControlsData.ValidationControl); } else if (!chkChangeDateCancelled.Checked) { if (ARow.SubscriptionStatus != String.Empty) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_SUBSCRIPTION_DATEENDEDSET_WHEN_ACTIVE)), ValidationColumn, ValidationControlsData.ValidationControl); VerificationResult.OverrideResultText(Catalog.GetString("Date Ended must be cleared when a Subscription is made active.")); } } else { if (!NoClearingOfVerificationResult) { VerificationResult = null; } } } // Handle addition/removal to/from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn); } }