Exemplo n.º 1
0
        public void CanCreateUpdateDeleteRunbook()
        {
            using (var context = MockContext.Start(GetType().FullName))
            {
                using (var testFixture = new AutomationTestBase(context))
                {
                    var runbookName    = RunbookDefinition.TestPSScript.RunbookName;
                    var runbookContent = RunbookDefinition.TestPSScript.PsScript;

                    testFixture.CreatePSScriptRunbook(runbookName, runbookContent);
                    var runbook = testFixture.GetRunbook(runbookName);
                    Assert.NotNull(runbook);

                    testFixture.PublishRunbook(runbook.Name);
                    runbook = testFixture.GetRunbook(runbookName);
                    Assert.Equal("Published", runbook.State);

                    const string description = "description of runbook";
                    runbook.LogProgress = true;
                    runbook.Description = description;

                    testFixture.UpdateRunbook(runbook);
                    var updatedRunbook = testFixture.GetRunbook(runbookName);
                    Assert.True(runbook.LogProgress);
                    Assert.False(runbook.LogVerbose);
                    Assert.Equal(runbook.Description, updatedRunbook.Description);

                    var runbookContentV2 = RunbookDefinition.TestPSScriptV2.PsScript;
                    testFixture.UpdateRunbookContent(runbookName, runbookContentV2);
                    var updatedContent = testFixture.GetRunbookContent(runbookName);
                    var reader         = new StreamReader(updatedContent);
                    Assert.Equal(runbookContentV2, reader.ReadToEnd());

                    testFixture.DeleteRunbook(runbookName);

                    Assert.Throws <ErrorResponseException>(() =>
                    {
                        runbook = testFixture.GetRunbook(runbookName);
                    });
                }
            }
        }