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"]); }); }); }
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"]); }); }); }
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()); }
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()); }
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()); }
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"]); }); }
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"]); }); }); }