コード例 #1
0
        public void PlaceholdersWithSpacesWithoutQuotes()
        {
            string script = @"
plan ""Test Plan 1""
    on selection
sync dir from path1/path2 to ${Some Placeholder}/path4
";

            var configReader = new ScriptConfigurationReader(new StringConfigurationProvider(script));

            Assert.Collection(configReader.Read(),
                              plan =>
            {
                Assert.IsType <BackupPlan>(plan);
                Assert.Equal(BackupPlan.OnSelectionRunType, plan.RunType);
                Assert.Equal("Test Plan 1", plan.Name);
                Assert.Null(plan["plan"]);
                Assert.Null(plan["on"]);
                Assert.Collection(plan.Steps,
                                  step =>
                {
                    Assert.Equal("sync", step.StepType);
                    Assert.Equal("path1/path2", step["from"]);
                    Assert.Equal("${Some Placeholder}/path4", step["to"]);
                    Assert.Null(step["sync"]);
                });
            });
        }
コード例 #2
0
        public void PlanWithStepsOfUnknownType()
        {
            string script = @"
plan ""Test Plan""
  on selection
SOMETHINGUNKNOWN bla
      from path1/path2
      to path3/path4
";

            var configReader = new ScriptConfigurationReader(new StringConfigurationProvider(script));

            Assert.Collection(configReader.Read(), plan =>
            {
                Assert.IsType <BackupPlan>(plan);
                Assert.Equal(BackupPlan.OnSelectionRunType, plan.RunType);
                Assert.Equal("Test Plan", plan.Name);
                Assert.Collection(plan.Steps,
                                  step =>
                {
                    Assert.Equal("SOMETHINGUNKNOWN", step.StepType);
                    Assert.Equal("path1/path2", step["from"]);
                    Assert.Equal("path3/path4", step["to"]);
                });
            });
        }
コード例 #3
0
        public void NoPlanHeadCollection()
        {
            string script = @"
sync dir from path1/path2 to path3/path4
";

            var configReader = new ScriptConfigurationReader(new StringConfigurationProvider(script));

            Assert.Throws <InvalidOperationException>(() => configReader.Read());
        }
コード例 #4
0
        public void InvalidWithMixedQuotes()
        {
            string script = @"
plan 'Test Plan 1"" on selection somekey somevalue
";

            var configReader = new ScriptConfigurationReader(new StringConfigurationProvider(script));

            Assert.Throws <InvalidOperationException>(() => configReader.Read());
        }
コード例 #5
0
        public void BadQuoteSyntax()
        {
            string script = @"
plan ""Test Plan
  on SOMETHINGUNKNOWN
sync dir from path1/path2 to path3/path4
";

            var configReader = new ScriptConfigurationReader(new StringConfigurationProvider(script));

            Assert.Throws <InvalidOperationException>(() => configReader.Read());
        }
コード例 #6
0
        public void PlanMissingKey()
        {
            string script = @"
plan ""Test Plan 1"" on selection ""somevalue""
";

            var configReader = new ScriptConfigurationReader(new StringConfigurationProvider(script));

            Assert.Collection(configReader.Read(),
                              plan =>
            {
                Assert.IsType <BackupPlan>(plan);
                Assert.Equal(BackupPlan.OnSelectionRunType, plan.RunType);
                Assert.Equal("Test Plan 1", plan.Name);
                Assert.Null(plan["somekey"]);
                Assert.Null(plan["plan"]);
                Assert.Null(plan["on"]);
            });
        }
コード例 #7
0
        public void ManualPlanWithMultilineSteps()
        {
            string script = @"
plan ""Test Plan 1""
    on selection somekey somevalue

sync dir
    from path1/path2
    to path3/path4
sync file
    from path5/path6/file7
    to path8/path9/file0
";

            var configReader = new ScriptConfigurationReader(new StringConfigurationProvider(script));

            Assert.Collection(configReader.Read(),
                              plan =>
            {
                Assert.IsType <BackupPlan>(plan);
                Assert.Equal(BackupPlan.OnSelectionRunType, plan.RunType);
                Assert.Equal("Test Plan 1", plan.Name);
                Assert.Equal("somevalue", plan["somekey"]);
                Assert.Null(plan["plan"]);
                Assert.Null(plan["on"]);
                Assert.Collection(plan.Steps,
                                  step =>
                {
                    Assert.Equal("sync", step.StepType);
                    Assert.Equal("path1/path2", step["from"]);
                    Assert.Equal("path3/path4", step["to"]);
                    Assert.Null(step["sync"]);
                },
                                  step =>
                {
                    Assert.Equal("sync", step.StepType);
                    Assert.Equal("path5/path6/file7", step["from"]);
                    Assert.Equal("path8/path9/file0", step["to"]);
                });
            });
        }