public async Task GetRuntimeInfoTest()
        {
            // Arrange
            var systemInfo = new SystemInfo(OperatingSystemType, Architecture, Version);

            var store = Mock.Of <IEntityStore <string, ModuleState> >();
            var restartPolicyManager = Mock.Of <IRestartPolicyManager>();

            var    runtimeInfoProvider  = Mock.Of <IRuntimeInfoProvider>(r => r.GetSystemInfo(CancellationToken.None) == Task.FromResult(systemInfo));
            var    moduleStateStore     = Mock.Of <IEntityStore <string, ModuleState> >();
            string minDockerVersion     = "20";
            string dockerLoggingOptions = "dummy logging options";

            var deploymentConfig = new DeploymentConfig(
                "1.0",
                new DockerRuntimeInfo("docker", new DockerRuntimeConfig(minDockerVersion, dockerLoggingOptions)),
                new SystemModules(Option.None <IEdgeAgentModule>(), Option.None <IEdgeHubModule>()),
                new Dictionary <string, IModule>());

            var environment = new DockerEnvironment(runtimeInfoProvider, deploymentConfig, moduleStateStore, restartPolicyManager, systemInfo.OperatingSystemType, systemInfo.Architecture, systemInfo.Version);

            // act
            IRuntimeInfo reportedRuntimeInfo = await environment.GetRuntimeInfoAsync();

            // assert
            Assert.True(reportedRuntimeInfo is DockerReportedRuntimeInfo);
            var dockerReported = reportedRuntimeInfo as DockerReportedRuntimeInfo;

            Assert.Equal(OperatingSystemType, dockerReported.Platform.OperatingSystemType);
            Assert.Equal(Architecture, dockerReported.Platform.Architecture);
            Assert.Equal(Version, dockerReported.Platform.Version);
            Assert.Equal(minDockerVersion, dockerReported.Config.MinDockerVersion);
            Assert.Equal(dockerLoggingOptions, dockerReported.Config.LoggingOptions);
        }
Beispiel #2
0
        public async Task GetUnknownRuntimeInfoTest()
        {
            // Arrange
            var systemInfoResponse = new SystemInfoResponse
            {
                OSType       = OperatingSystemType,
                Architecture = Architecture
            };

            var runtimeInfoProvider  = Mock.Of <IRuntimeInfoProvider>();
            var moduleStateStore     = Mock.Of <IEntityStore <string, ModuleState> >();
            var restartPolicyManager = Mock.Of <IRestartPolicyManager>();

            var environment = new DockerEnvironment(runtimeInfoProvider, DeploymentConfig.Empty, moduleStateStore, restartPolicyManager, OperatingSystemType, Architecture);

            // act
            IRuntimeInfo reportedRuntimeInfo = await environment.GetRuntimeInfoAsync();

            // assert
            Assert.True(reportedRuntimeInfo is DockerReportedUnknownRuntimeInfo);
            var dockerReported = reportedRuntimeInfo as DockerReportedUnknownRuntimeInfo;

            Assert.Equal(OperatingSystemType, dockerReported.Platform.OperatingSystemType);
            Assert.Equal(Architecture, dockerReported.Platform.Architecture);
        }