Example #1
0
        public void CanCreateUpdateDeleteDscConfiguration()
        {
            using (var context = MockContext.Start(GetType().FullName))
            {
                using (var testFixture = new AutomationTestBase(context))
                {
                    var configName           = DscConfigurationDefinition.TestSimpleConfigurationDefinition.ConfigurationName;
                    var configContent        = DscConfigurationDefinition.TestSimpleConfigurationDefinition.PsScript;
                    var description          = DscConfigurationDefinition.TestSimpleConfigurationDefinition.Description;
                    var contentHashValue     = DscConfigurationDefinition.TestSimpleConfigurationDefinition.ContentHashValue;
                    var contentHashAlgorithm = DscConfigurationDefinition.TestSimpleConfigurationDefinition.ContentHashAlgorithm;
                    var contentType          = DscConfigurationDefinition.TestSimpleConfigurationDefinition.ContentType;

                    const string updatedDescription = "new sample configuration test";

                    var configuration = testFixture.CreateDscConfiguration(configName, configContent,
                                                                           description, contentHashValue, contentHashAlgorithm, contentType);

                    var config = testFixture.GetDscConfiguration(configName);
                    Assert.NotNull(config);
                    Assert.Equal(config.Name, configuration.Name);
                    Assert.Equal(config.Description, configuration.Description);

                    config.Description = updatedDescription;
                    testFixture.UpdateDscConfiguration(config, configContent,
                                                       description, contentHashValue, contentHashAlgorithm, contentType);

                    var dscConfigurations = testFixture.GetDscConfigurations();
                    Assert.NotNull(dscConfigurations);
                    Assert.Single(dscConfigurations.ToList());
                    configuration = dscConfigurations.ToList()[0];
                    Assert.Equal(configName, configuration.Name);

                    testFixture.DeleteDscConfiguration(configName);

                    Assert.Throws <ErrorResponseException>(() =>
                    {
                        config = testFixture.GetDscConfiguration(configName);
                    });
                }
            }
        }