|
1 |
| -using System.Linq; |
2 |
| -using System.Threading.Tasks; |
3 |
| -using Automatica.Core.UnitTests.Base.Logics; |
4 |
| -using P3.Logic.Time.DelayedOff; |
5 |
| -using Xunit; |
6 |
| - |
7 |
| -[assembly: CollectionBehavior(DisableTestParallelization = true)] |
8 |
| - |
9 |
| -namespace P3.Logic.Time.Tests.DelayedOff |
10 |
| -{ |
11 |
| - public class DelayedOffTests: LogicTest<DelayedOffLogicFactory> |
12 |
| - { |
13 |
| - [Fact] |
14 |
| - public async void TestDelayedOffRule() |
15 |
| - { |
16 |
| - await Context.Dispatcher.ClearValues(); |
17 |
| - await Context.Dispatcher.ClearRegistrations(); |
18 |
| - |
19 |
| - Logic.ValueChanged(GetLogicInterfaceByTemplate(DelayedOffLogicFactory.RuleTrigger), Dispatchable, true); |
20 |
| - |
21 |
| - await Task.Delay(8000); |
22 |
| - |
23 |
| - var values = Context.Dispatcher.GetValues(Automatica.Core.Base.IO.DispatchableType.RuleInstance); |
24 |
| - |
25 |
| - Assert.Single(values); |
26 |
| - Assert.Equal(false, values.First().Value.Value); |
27 |
| - } |
28 |
| - |
29 |
| - [Fact] |
30 |
| - public async void TestDelayedOffRule2() |
31 |
| - { |
32 |
| - await Context.Dispatcher.ClearValues(); |
33 |
| - await Context.Dispatcher.ClearRegistrations(); |
34 |
| - |
35 |
| - var paramDelay = GetLogicInterfaceByTemplate(DelayedOffLogicFactory.RuleParamDelay); |
36 |
| - paramDelay.Value = 1; |
37 |
| - await Logic.Start(); |
38 |
| - |
39 |
| - Logic.ValueChanged(GetLogicInterfaceByTemplate(DelayedOffLogicFactory.RuleTrigger), Dispatchable, true); |
40 |
| - |
41 |
| - await Task.Delay(3000); |
42 |
| - |
43 |
| - var values = Context.Dispatcher.GetValues(Automatica.Core.Base.IO.DispatchableType.RuleInstance); |
44 |
| - |
45 |
| - Assert.Single(values); |
46 |
| - Assert.Equal(false, values.First().Value.Value); |
47 |
| - } |
48 |
| - |
49 |
| - |
50 |
| - [Fact] |
51 |
| - public async void TestDelayedOffRuleReset() |
52 |
| - { |
53 |
| - await Context.Dispatcher.ClearValues(); |
54 |
| - await Context.Dispatcher.ClearRegistrations(); |
55 |
| - |
56 |
| - var paramDelay = GetLogicInterfaceByTemplate(DelayedOffLogicFactory.RuleParamDelay); |
57 |
| - paramDelay.Value = 2; |
58 |
| - |
59 |
| - await Logic.Start(); |
60 |
| - |
61 |
| - Logic.ValueChanged(GetLogicInterfaceByTemplate(DelayedOffLogicFactory.RuleTrigger), Dispatchable, true); |
62 |
| - |
63 |
| - await Task.Delay(1000); |
64 |
| - |
65 |
| - Logic.ValueChanged(GetLogicInterfaceByTemplate(DelayedOffLogicFactory.RuleReset), Dispatchable, true); |
66 |
| - |
67 |
| - await Task.Delay(1500); |
68 |
| - |
69 |
| - |
70 |
| - var values = Context.Dispatcher.GetValues(Automatica.Core.Base.IO.DispatchableType.RuleInstance); |
71 |
| - |
72 |
| - Assert.Empty(values); |
73 |
| - } |
74 |
| - } |
75 |
| -} |
| 1 | +using System.Linq; |
| 2 | +using System.Threading.Tasks; |
| 3 | +using Automatica.Core.UnitTests.Base.Logics; |
| 4 | +using P3.Logic.Time.DelayedOff; |
| 5 | +using Xunit; |
| 6 | + |
| 7 | +[assembly: CollectionBehavior(DisableTestParallelization = true)] |
| 8 | + |
| 9 | +namespace P3.Logic.Time.Tests.DelayedOff |
| 10 | +{ |
| 11 | + public class DelayedOffTests: LogicTest<DelayedOffLogicFactory> |
| 12 | + { |
| 13 | + [Fact] |
| 14 | + public async void TestDelayedOffRule() |
| 15 | + { |
| 16 | + await Context.Dispatcher.ClearValues(); |
| 17 | + await Context.Dispatcher.ClearRegistrations(); |
| 18 | + |
| 19 | + Logic.ValueChanged(GetLogicInterfaceByTemplate(DelayedOffLogicFactory.RuleTrigger), Dispatchable, true); |
| 20 | + |
| 21 | + await Task.Delay(8000); |
| 22 | + |
| 23 | + var values = Context.Dispatcher.GetValues(Automatica.Core.Base.IO.DispatchableType.RuleInstance); |
| 24 | + |
| 25 | + Assert.Single(values); |
| 26 | + Assert.Equal(false, values.First().Value.Value); |
| 27 | + } |
| 28 | + |
| 29 | + [Fact] |
| 30 | + public async void TestDelayedOffRule2() |
| 31 | + { |
| 32 | + await Context.Dispatcher.ClearValues(); |
| 33 | + await Context.Dispatcher.ClearRegistrations(); |
| 34 | + |
| 35 | + var paramDelay = GetLogicInterfaceByTemplate(DelayedOffLogicFactory.RuleParamDelay); |
| 36 | + paramDelay.Value = 1; |
| 37 | + await Logic.Start(); |
| 38 | + |
| 39 | + Logic.ValueChanged(GetLogicInterfaceByTemplate(DelayedOffLogicFactory.RuleTrigger), Dispatchable, true); |
| 40 | + |
| 41 | + await Task.Delay(3000); |
| 42 | + |
| 43 | + var values = Context.Dispatcher.GetValues(Automatica.Core.Base.IO.DispatchableType.RuleInstance); |
| 44 | + |
| 45 | + Assert.Single(values); |
| 46 | + Assert.Equal(false, values.First().Value.Value); |
| 47 | + } |
| 48 | + |
| 49 | + |
| 50 | + [Fact] |
| 51 | + public async void TestDelayedOffRuleReset() |
| 52 | + { |
| 53 | + await Context.Dispatcher.ClearValues(); |
| 54 | + await Context.Dispatcher.ClearRegistrations(); |
| 55 | + |
| 56 | + var paramDelay = GetLogicInterfaceByTemplate(DelayedOffLogicFactory.RuleParamDelay); |
| 57 | + paramDelay.Value = 2; |
| 58 | + |
| 59 | + await Logic.Start(); |
| 60 | + |
| 61 | + Logic.ValueChanged(GetLogicInterfaceByTemplate(DelayedOffLogicFactory.RuleTrigger), Dispatchable, true); |
| 62 | + |
| 63 | + await Task.Delay(1000); |
| 64 | + |
| 65 | + Logic.ValueChanged(GetLogicInterfaceByTemplate(DelayedOffLogicFactory.RuleReset), Dispatchable, true); |
| 66 | + |
| 67 | + await Task.Delay(1500); |
| 68 | + |
| 69 | + |
| 70 | + var values = Context.Dispatcher.GetValues(Automatica.Core.Base.IO.DispatchableType.RuleInstance); |
| 71 | + |
| 72 | + Assert.Single(values); |
| 73 | + } |
| 74 | + } |
| 75 | +} |
0 commit comments