public void TestGetModule_Content()
        {
            var modName = "xPSDesiredStateConfiguration";
            var modVers = "5.1.0.0";

            // Get path and content of expected results
            var myPath   = typeof(ClassicPullServerProtocolCompatibilityTests).GetTypeInfo().Assembly.Location;
            var myDir    = Path.GetDirectoryName(myPath);
            var dscDir   = Path.Combine(myDir, "../../../../../../tools/ci/DSC");
            var modPath  = Path.Combine(dscDir, $"{modName}_{modVers}.zip");
            var csumPath = Path.Combine(dscDir, $"{modName}_{modVers}.zip.checksum");
            var modBody  = File.ReadAllBytes(modPath);
            var csumBody = File.ReadAllText(csumPath);

            var config = BuildConfig();

            using (var client = new DscPullClient(config))
            {
                client.RegisterDscAgent().Wait();

                var moduleResult = client.GetModule(modName, modVers).Result;
                Assert.IsNotNull(moduleResult?.Content, "Module content not null");
                Assert.AreNotEqual(0, moduleResult.Content.Length, "Module content length > 0");

                Assert.AreEqual(csumBody, moduleResult.Checksum, "Expected module checksum");

                Assert.AreEqual(modBody.Length, moduleResult.Content.Length, "Expected module content size");
                CollectionAssert.AreEqual(modBody, moduleResult.Content, "Expected module content");
            }
        }
示例#2
0
        public void TestGetModule()
        {
            var modName     = "xPSDesiredStateConfiguration";
            var modVers     = "5.1.0.0";
            var modulesRoot = Path.Combine(Directory.GetCurrentDirectory(),
                                           "BasicPullHandlerRoot/Modules");
            var modPath  = Path.Combine(modulesRoot, $"{modName}/{modVers}.zip");
            var csumPath = Path.Combine(modulesRoot, $"{modName}/FYI/{modVers}.zip.checksum");
            var modBody  = File.ReadAllBytes(modPath);
            var csumBody = File.ReadAllText(csumPath);

            var fileResult = _defaultClient.GetModule(modName, modVers).Result;

            Assert.IsNotNull(fileResult?.Content, "File result is not missing or null");
            CollectionAssert.AreEqual(modBody, fileResult.Content, "File result content");
            Assert.AreEqual(csumBody, fileResult.Checksum, "Expected config checksum");
        }