public override TestResult Execute() { if (string.IsNullOrEmpty(Session)) { return(TestResult.ParameterMissing("Session")); } DaSession session = GetProperty(Session) as DaSession; if (session == null) { return(TestResult.ParameterInvalid("Session")); } try { int result = session.Disconnect(new ExecutionOptions()); TestClient.ApplicationInstance.RemoveDaSession(session); } catch (Exception ex) { return(new TestResult(ex)); } UnsetProperty(Session); return(TestResult.Success()); }
public override TestResult Execute() { CountDataChanges.s_counts = 0; ExecutionOptions executionOptions = new ExecutionOptions(EnumExecutionType.SYNCHRONOUS, 0); if (TimeInterval == 0) { return(TestResult.ParameterMissing("TimeInterval")); } if (string.IsNullOrEmpty(Url)) { return(TestResult.ParameterMissing("Session")); } if (string.IsNullOrEmpty(ParentNode)) { ParentNode = "Test Folder.TestItems_0"; } try { int res; DaSession session = new DaSession(ExpandProperty(Url)); DaSubscription[] subscription = new MyDaSubscription[SubscriptionCount]; CountDataChanges.s_dataChangesPerSubscription = new long[SubscriptionCount]; uint itemCount = 0; MyDaSubscription currentSubscription; for (uint subCount = 0; subCount < SubscriptionCount; ++subCount) { currentSubscription = new MyDaSubscription(subCount, SubscriptionRate, session); subscription[subCount] = currentSubscription; CountDataChanges.s_dataChangesPerSubscription[subCount] = 0; for (uint i = 0; i < ItemsCountPerSubscription; ++i) { string itemID = ParentNode + ".TV_" + itemCount.ToString(); DaItem item = new DaItem(itemID, currentSubscription); ++itemCount; } } for (uint i = 0; i < SubscriptionCount; ++i) { subscription[i].DataChanged += new DataChangedEventHandler(HandleDataChanged); } res = session.Connect(true, true, executionOptions); System.Threading.Thread.Sleep(TimeInterval); session.Disconnect(executionOptions); string datachangesPerSubscription = ""; for (uint i = 0; i < SubscriptionCount; ++i) { datachangesPerSubscription += " | Sub#" + i.ToString() + ": " + CountDataChanges.s_dataChangesPerSubscription[i].ToString(); } datachangesPerSubscription = "Total: " + CountDataChanges.s_counts.ToString() + datachangesPerSubscription; return(TestResult.Failed(datachangesPerSubscription)); } catch (Exception ex) { return(new TestResult(ex)); } }