public void When_EnabledTwiceByHost_Then_SubscriptionCreatedOnlyOnce() { int totalActivations = 0, pendingActivations = 0; var host = new TestAutomationHost(_scheduler); var automation = new TestAutomation(host, OnEnabled); _scheduler.AdvanceBy(100); Assert.AreEqual(0, totalActivations); Assert.AreEqual(0, pendingActivations); host.SetIsEnabled(automation, true); _scheduler.AdvanceBy(100); Assert.AreEqual(1, totalActivations); Assert.AreEqual(1, pendingActivations); host.SetIsEnabled(automation, true); _scheduler.AdvanceBy(100); Assert.AreEqual(1, totalActivations); Assert.AreEqual(1, pendingActivations); IDisposable OnEnabled() { Interlocked.Increment(ref totalActivations); Interlocked.Increment(ref pendingActivations); return(Disposable.Create(() => Interlocked.Decrement(ref pendingActivations))); } }
public void When_SchedulePeriodic_Then_CancelSubscription() { _scheduler.AdvanceTo(new DateTimeOffset(1983, 9, 9, 15, 15, 0, TimeSpan.FromHours(-4)).Ticks); var ran = 0; var host = new TestAutomationHost(_scheduler); var automation = new TestAutomation(host); IDisposable subscription; using (new AsyncContext(_scheduler)) { subscription = automation.At(new TimeSpan(22, 0, 0), Action); } _scheduler.AdvanceBy(TimeSpan.FromDays(3).Ticks); subscription.Dispose(); _scheduler.AdvanceBy(TimeSpan.FromDays(5).Ticks); Assert.AreEqual(3, ran); async Task Action(DateTimeOffset arg) { Interlocked.Increment(ref ran); } }
public static ITextRange[] NativeArrayToManaged(TestAutomation automation, UIA.Text.TextPatternRange[] nativeElements) { if (nativeElements == null) { return(new ITextRange[0]); } return(nativeElements.Select(r => (ITextRange)NativeToManaged(automation, r)).ToArray()); }
public void When_Enable_Then_AsyncContextIsSet() { var ctx = default(AsyncContext); var ctxScheduler = default(IScheduler); var host = new TestAutomationHost(_scheduler); var automation = new TestAutomation(host, OnEnabled); _scheduler.AdvanceBy(100); host.SetIsEnabled(automation, true); _scheduler.AdvanceBy(100); Assert.IsNotNull(ctx); Assert.IsNotNull(ctxScheduler); Assert.AreEqual(_scheduler, ctxScheduler); IDisposable OnEnabled() { ctx = AsyncContext.Current; ctxScheduler = AsyncContext.Current?.Scheduler; return(Disposable.Empty); } }
/// <summary> /// Initializes client properties. /// </summary> private void Initialize() { Account = new Account(this); Token = new Token(this); DirectoryService = new DirectoryService(this); FoldersNavigation = new FoldersNavigation(this); Licensing = new Licensing(this); Logs = new Logs(this); Maintenance = new Maintenance(this); RobotsService = new RobotsService(this); Stats = new Stats(this); Status = new Status(this); TestAutomation = new TestAutomation(this); TestDataQueueActions = new TestDataQueueActions(this); Translations = new Translations(this); TaskForms = new TaskForms(this); Alerts = new Alerts(this); Assets = new Assets(this); AuditLogs = new AuditLogs(this); Buckets = new Buckets(this); Calendars = new Calendars(this); CredentialStores = new CredentialStores(this); Environments = new Environments(this); ExecutionMedia = new ExecutionMedia(this); Folders = new Folders(this); HostLicenses = new HostLicenses(this); Jobs = new Jobs(this); JobTriggers = new JobTriggers(this); Libraries = new Libraries(this); LicensesNamedUser = new LicensesNamedUser(this); LicensesRuntime = new LicensesRuntime(this); Machines = new Machines(this); MessageTemplates = new MessageTemplates(this); OrganizationUnits = new OrganizationUnits(this); Permissions = new Permissions(this); Processes = new Processes(this); ProcessSchedules = new ProcessSchedules(this); QueueDefinitions = new QueueDefinitions(this); QueueItemComments = new QueueItemComments(this); QueueItemEvents = new QueueItemEvents(this); QueueItems = new QueueItems(this); QueueProcessingRecords = new QueueProcessingRecords(this); Queues = new Queues(this); Releases = new Releases(this); RobotLogs = new RobotLogs(this); Robots = new Robots(this); Roles = new Roles(this); Sessions = new Sessions(this); Settings = new Settings(this); TaskActivities = new TaskActivities(this); TaskCatalogs = new TaskCatalogs(this); TaskNotes = new TaskNotes(this); Tasks = new Tasks(this); Tenants = new Tenants(this); TestCaseDefinitions = new TestCaseDefinitions(this); TestCaseExecutions = new TestCaseExecutions(this); TestDataQueueItems = new TestDataQueueItems(this); TestDataQueues = new TestDataQueues(this); TestSetExecutions = new TestSetExecutions(this); TestSets = new TestSets(this); TestSetSchedules = new TestSetSchedules(this); UserLoginAttempts = new UserLoginAttempts(this); Users = new Users(this); Webhooks = new Webhooks(this); GenericTasks = new GenericTasks(this); BaseUri = new System.Uri("https://cloud.uipath.com"); SerializationSettings = new JsonSerializerSettings { Formatting = Newtonsoft.Json.Formatting.Indented, DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; DeserializationSettings = new JsonSerializerSettings { DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; CustomInitialize(); }
public static TestTextRange NativeToManaged(TestAutomation automation, UIA.Text.TextPatternRange nativeElement) { return(nativeElement == null ? null : new TestTextRange(automation, nativeElement)); }