コード例 #1
0
 public async Task NodeBrowsePathStaticScalarMethodsTestAsync()
 {
     // Skip.IfNot(_runAll);
     using (var harness = new TwinModuleFixture()) {
         await harness.RunTestAsync(async (device, module, services) => {
             await GetTests(device, module, services).NodeBrowsePathStaticScalarMethodsTestAsync();
         });
     }
 }
コード例 #2
0
 public async Task NodeBrowseDataAccessFC1001Test1Async()
 {
     Skip.IfNot(_runAll);
     using (var harness = new TwinModuleFixture()) {
         await harness.RunTestAsync(Endpoint, async (endpoint, services) => {
             await GetTests(endpoint, services).NodeBrowseDataAccessFC1001Test1Async();
         });
     }
 }
コード例 #3
0
 public async Task NodeBrowseContinuationTest1Async()
 {
     // Skip.IfNot(_runAll);
     using (var harness = new TwinModuleFixture()) {
         await harness.RunTestAsync(async (device, module, services) => {
             await GetTests(device, module, services).NodeBrowseContinuationTest1Async();
         });
     }
 }
コード例 #4
0
 public async Task NodeReadStaticScalarBooleanValueVariableTestAsync()
 {
     Skip.IfNot(_runAll);
     using (var harness = new TwinModuleFixture()) {
         await harness.RunTestAsync(async (device, module, services) => {
             await GetTests(device, module, services).NodeReadStaticScalarBooleanValueVariableTestAsync();
         });
     }
 }
コード例 #5
0
 public async Task HistoryReadInt64ValuesTest4Async()
 {
     Skip.IfNot(_runAll);
     using (var harness = new TwinModuleFixture()) {
         await harness.RunTestAsync(async (device, module, services) => {
             await GetTests(device, module, services).HistoryReadInt64ValuesTest4Async();
         });
     }
 }
コード例 #6
0
 public async Task NodeReadAllStaticArrayVariableNodeClassTest1Async()
 {
     // Skip.IfNot(_runAll);
     using (var harness = new TwinModuleFixture()) {
         await harness.RunTestAsync(Endpoint, async (endpoint, services) => {
             await GetTests(endpoint, services).NodeReadAllStaticArrayVariableNodeClassTest1Async();
         });
     }
 }
コード例 #7
0
 public async Task NodeWriteStaticScalarUInt16ValueVariableTestAsync()
 {
     Skip.IfNot(_runAll);
     using (var harness = new TwinModuleFixture()) {
         await harness.RunTestAsync(Endpoint, async (endpoint, services) => {
             await GetTests(endpoint, services).NodeWriteStaticScalarUInt16ValueVariableTestAsync();
         });
     }
 }
コード例 #8
0
 public async Task NodeMethodCallStaticScalarMethod3WithObjectPathAndMethodIdAndBrowsePathTestAsync()
 {
     // Skip.IfNot(_runAll);
     using (var harness = new TwinModuleFixture()) {
         await harness.RunTestAsync(Endpoint, async (endpoint, services) => {
             await GetTests(endpoint, services).NodeMethodCallStaticScalarMethod3WithObjectPathAndMethodIdAndBrowsePathTestAsync();
         });
     }
 }
コード例 #9
0
 public async Task NodeMethodCallBoiler2ResetTestAsync()
 {
     // Skip.IfNot(_runAll);
     using (var harness = new TwinModuleFixture()) {
         await harness.RunTestAsync(Endpoint, async (endpoint, services) => {
             await GetTests(endpoint, services).NodeMethodCallBoiler2ResetTestAsync();
         });
     }
 }
コード例 #10
0
 public async Task NodeReadAllStaticScalarVariableAccessLevelTest1Async()
 {
     Skip.IfNot(_runAll);
     using (var harness = new TwinModuleFixture()) {
         await harness.RunTestAsync(Endpoint, async (endpoint, services) => {
             await GetTests(endpoint, services).NodeReadAllStaticScalarVariableAccessLevelTest1Async();
         });
     }
 }
コード例 #11
0
 public async Task NodeWriteStaticScalarQualifiedNameValueVariableTestAsync()
 {
     // Skip.IfNot(_runAll);
     using (var harness = new TwinModuleFixture()) {
         await harness.RunTestAsync(async (device, module, services) => {
             await GetTests(device, module, services).NodeWriteStaticScalarQualifiedNameValueVariableTestAsync();
         });
     }
 }
コード例 #12
0
 public async Task NodeReadDiagnosticsVerboseTestAsync()
 {
     Skip.IfNot(_runAll);
     using (var harness = new TwinModuleFixture()) {
         await harness.RunTestAsync(Endpoint, async (endpoint, services) => {
             await GetTests(endpoint, services).NodeReadDiagnosticsVerboseTestAsync();
         });
     }
 }
コード例 #13
0
 public async Task NodeWriteStaticScalarBooleanValueVariableWithBrowsePathTest3()
 {
     // Skip.IfNot(_runAll);
     using (var harness = new TwinModuleFixture()) {
         await harness.RunTestAsync(Endpoint, async (endpoint, services) => {
             await GetTests(endpoint, services).NodeWriteStaticScalarBooleanValueVariableWithBrowsePathTest3();
         });
     }
 }
コード例 #14
0
 public async Task NodeBrowseBoilersObjectsTest2Async()
 {
     Skip.IfNot(_runAll);
     using (var harness = new TwinModuleFixture()) {
         await harness.RunTestAsync(Endpoint, async (endpoint, services) => {
             await GetTests(endpoint, services).NodeBrowseBoilersObjectsTest2Async();
         });
     }
 }
コード例 #15
0
 public async Task NodeBrowseDiagnosticsOperationsTestAsync()
 {
     Skip.IfNot(_runAll);
     using (var harness = new TwinModuleFixture()) {
         await harness.RunTestAsync(async (device, module, services) => {
             await GetTests(device, module, services).NodeBrowseDiagnosticsOperationsTestAsync();
         });
     }
 }
コード例 #16
0
 public async Task NodeMethodCallStaticScalarMethod1Test1Async()
 {
     Skip.IfNot(_runAll);
     using (var harness = new TwinModuleFixture()) {
         await harness.RunTestAsync(Endpoint, async (endpoint, services) => {
             await GetTests(endpoint, services).NodeMethodCallStaticScalarMethod1Test1Async();
         });
     }
 }
コード例 #17
0
 public async Task NodeBrowseFirstInRootTest2Async()
 {
     Skip.IfNot(_runAll);
     using (var harness = new TwinModuleFixture()) {
         await harness.RunTestAsync(async (device, module, services) => {
             await GetTests(device, module, services).NodeBrowseFirstInRootTest2Async();
         });
     }
 }
コード例 #18
0
 public async Task NodeReadDataAccessMeasurementFloatValueTestAsync()
 {
     // Skip.IfNot(_runAll);
     using (var harness = new TwinModuleFixture()) {
         await harness.RunTestAsync(async (device, module, services) => {
             await GetTests(device, module, services).NodeReadDataAccessMeasurementFloatValueTestAsync();
         });
     }
 }
コード例 #19
0
 public async Task NodeReadStaticArrayBooleanValueVariableTestAsync()
 {
     Skip.IfNot(_runAll);
     using (var harness = new TwinModuleFixture()) {
         await harness.RunTestAsync(Endpoint, async (endpoint, services) => {
             await GetTests(endpoint, services).NodeReadStaticArrayBooleanValueVariableTestAsync();
         });
     }
 }
コード例 #20
0
 public async Task NodeBrowseStaticArrayVariablesRawModeTestAsync()
 {
     Skip.IfNot(_runAll);
     using (var harness = new TwinModuleFixture()) {
         await harness.RunTestAsync(async (device, module, services) => {
             await GetTests(device, module, services).NodeBrowseStaticArrayVariablesRawModeTestAsync();
         });
     }
 }
コード例 #21
0
 public async Task NodeMethodMetadataStaticScalarMethod3WithBrowsePathTest2()
 {
     Skip.IfNot(_runAll);
     using (var harness = new TwinModuleFixture()) {
         await harness.RunTestAsync(Endpoint, async (endpoint, services) => {
             await GetTests(endpoint, services).NodeMethodMetadataStaticScalarMethod3WithBrowsePathTest2();
         });
     }
 }
コード例 #22
0
        public async Task TestGetSupervisor()
        {
            using (var harness = new TwinModuleFixture()) {
                await harness.RunTestAsync(async (device, module, services) => {
                    // Setup
                    var registry = services.Resolve <ISupervisorRegistry>();

                    // Act
                    var supervisor = await registry.GetSupervisorAsync(SupervisorModelEx.CreateSupervisorId(device, module));

                    // Assert
                    Assert.True(supervisor.Connected.Value);
                    Assert.True(supervisor.OutOfSync.Value);
                });
            }
        }
コード例 #23
0
        public async Task TestActivateDeactivate20Endpoints5TimesMultiThreaded()
        {
            using (var harness = new TwinModuleFixture()) {
                await harness.RunTestAsync(async (device, module, services) => {
                    // Setup
                    var supervisorId = SupervisorModelEx.CreateSupervisorId(device, module);
                    var activation   = services.Resolve <IActivationServices <EndpointRegistrationModel> >();
                    var hub          = services.Resolve <IIoTHubTwinServices>();

                    for (var i = 0; i < 20; i++)
                    {
                        var twin = new EndpointInfoModel {
                            Registration = new EndpointRegistrationModel {
                                Endpoint = new EndpointModel {
                                    Url = "opc.tcp://test"
                                },
                                SupervisorId = supervisorId
                            },
                            ApplicationId = "uas" + i
                        }.ToEndpointRegistration().ToDeviceTwin();
                        await hub.CreateAsync(twin);
                    }

                    var registry  = services.Resolve <IEndpointRegistry>();
                    var endpoints = await registry.ListAllEndpointsAsync();

                    for (var i = 0; i < 5; i++)
                    {
                        await Task.WhenAll(endpoints.Select(ep => registry.ActivateEndpointAsync(ep.Registration.Id)));
                        await Task.WhenAll(endpoints.Select(ep => registry.DeactivateEndpointAsync(ep.Registration.Id)));
                    }

                    var diagnostics = services.Resolve <ISupervisorDiagnostics>();
                    endpoints       = await registry.ListAllEndpointsAsync();
                    var status      = await diagnostics.GetSupervisorStatusAsync(supervisorId);

                    // Assert
                    Assert.Equal(device, status.DeviceId);
                    Assert.Equal(module, status.ModuleId);
                    Assert.Null(status.SiteId);
                    Assert.Empty(status.Endpoints);
                    Assert.True(endpoints.All(ep => ep.ActivationState == EndpointActivationState.Deactivated));
                    Assert.True(endpoints.All(ep => ep.EndpointState == null));
                });
            }
        }
コード例 #24
0
        public async Task TestActivateDeactivateEndpoint20Times()
        {
            using (var harness = new TwinModuleFixture()) {
                await harness.RunTestAsync(async (device, module, services) => {
                    // Setup
                    var supervisorId = SupervisorModelEx.CreateSupervisorId(device, module);
                    var activation   = services.Resolve <IActivationServices <EndpointRegistrationModel> >();
                    var hub          = services.Resolve <IIoTHubTwinServices>();
                    var twin         = new EndpointInfoModel {
                        Registration = new EndpointRegistrationModel {
                            Endpoint = new EndpointModel {
                                Url = "opc.tcp://test"
                            },
                            SupervisorId = supervisorId
                        },
                        ApplicationId = "ua326029342304923"
                    }.ToEndpointRegistration().ToDeviceTwin();

                    await hub.CreateAsync(twin);
                    var registry  = services.Resolve <IEndpointRegistry>();
                    var endpoints = await registry.ListAllEndpointsAsync();
                    var ep1       = endpoints.FirstOrDefault();
                    Assert.NotNull(ep1);

                    for (var i = 0; i < 20; i++)
                    {
                        // Act
                        await registry.ActivateEndpointAsync(ep1.Registration.Id);
                        await registry.DeactivateEndpointAsync(ep1.Registration.Id);
                    }

                    var diagnostics = services.Resolve <ISupervisorDiagnostics>();
                    endpoints       = await registry.ListAllEndpointsAsync();
                    var ep3         = endpoints.FirstOrDefault();
                    var status      = await diagnostics.GetSupervisorStatusAsync(supervisorId);

                    // Assert
                    Assert.Equal(device, status.DeviceId);
                    Assert.Equal(module, status.ModuleId);
                    Assert.Null(status.SiteId);
                    Assert.Empty(status.Endpoints);
                    Assert.Equal(EndpointActivationState.Deactivated, ep3.ActivationState);
                    Assert.Null(ep3.EndpointState);
                });
            }
        }
コード例 #25
0
        public async Task TestGetSupervisorStatus()
        {
            using (var harness = new TwinModuleFixture()) {
                await harness.RunTestAsync(async (device, module, services) => {
                    // Setup
                    var diagnostics = services.Resolve <ISupervisorDiagnostics>();

                    // Act
                    var status = await diagnostics.GetSupervisorStatusAsync(SupervisorModelEx.CreateSupervisorId(device, module));

                    // Assert
                    Assert.Equal(status.DeviceId, device);
                    Assert.Equal(status.ModuleId, module);
                    Assert.Null(status.SiteId);
                    Assert.Empty(status.Endpoints);
                });
            }
        }
コード例 #26
0
        public async Task TestActivateEndpoint()
        {
            using (var harness = new TwinModuleFixture()) {
                await harness.RunTestAsync(async (device, module, services) => {
                    // Setup
                    var supervisorId = SupervisorModelEx.CreateSupervisorId(device, module);
                    var activation   = services.Resolve <IEndpointActivation>();
                    var hub          = services.Resolve <IIoTHubTwinServices>();
                    var twin         = new EndpointInfoModel {
                        Registration = new EndpointRegistrationModel {
                            Endpoint = new EndpointModel {
                                Url = "opc.tcp://test"
                            },
                            SupervisorId = supervisorId
                        },
                        ApplicationId = "ua326029342304923"
                    }.ToEndpointRegistration(_serializer).ToDeviceTwin(_serializer);
                    await hub.CreateOrUpdateAsync(twin);
                    var registry  = services.Resolve <IEndpointRegistry>();
                    var endpoints = await registry.ListAllEndpointsAsync();
                    var ep1       = endpoints.FirstOrDefault();
                    Assert.NotNull(ep1);

                    // Act
                    await activation.ActivateEndpointAsync(ep1.Registration.Id);
                    endpoints       = await registry.ListAllEndpointsAsync();
                    var ep2         = endpoints.FirstOrDefault();
                    var diagnostics = services.Resolve <ISupervisorDiagnostics>();
                    var status      = await diagnostics.GetSupervisorStatusAsync(supervisorId);

                    // Assert
                    Assert.Equal(device, status.DeviceId);
                    Assert.Equal(module, status.ModuleId);
                    Assert.Null(status.SiteId);
                    Assert.Single(status.Endpoints);
                    Assert.Equal(ep1.Registration.Id, status.Endpoints.Single().Id);
                    Assert.Equal(EndpointActivationState.ActivatedAndConnected, status.Endpoints.Single().ActivationState);
                    Assert.Equal(EndpointActivationState.ActivatedAndConnected, ep2.ActivationState);
                    Assert.True(
                        ep2.EndpointState == EndpointConnectivityState.Connecting ||
                        ep2.EndpointState == EndpointConnectivityState.NotReachable);
                });
            }
        }
コード例 #27
0
        public async Task TestListSupervisors()
        {
            using (var harness = new TwinModuleFixture()) {
                await harness.RunTestAsync(async (device, module, services) => {
                    // Setup
                    var registry = services.Resolve <ISupervisorRegistry>();

                    // Act
                    var supervisors = await registry.ListAllSupervisorsAsync();

                    // Assert
                    Assert.Single(supervisors);
                    Assert.True(supervisors.Single().Connected.Value);
                    Assert.True(supervisors.Single().OutOfSync.Value);
                    Assert.Equal(device, SupervisorModelEx.ParseDeviceId(supervisors.Single().Id, out var moduleId));
                    Assert.Equal(module, moduleId);
                });
            }
        }