public void SequenceItemActionCheck_ScribanSubstitute_CheckPasses() { /* 𝓐𝓻𝓻𝓪𝓷𝓰𝓮... */ var testSequenceItem = new SequenceItem { command = "test-check-item-sriban-expect-pass", check = new SequenceCheck { pass_template = "{{if model.someData == 'the correct data'}}true{{else}}false{{end}}", fail_message_template = "Check failed with value: {{model.someData}}" } }; var testModel = new { someData = "the correct data" }; var dummyRunState = new RunState { YamlOptions = new YamlScript { sequence_items = new[] { testSequenceItem }.ToList() } }; var testSequenceItemAction = new SequenceItemCheck(dummyRunState, testSequenceItem, testModel, new List <SequenceItem>()); /* 𝓐𝓬𝓽 */ var actual = testSequenceItemAction.ActionAsync(new CancellationToken()).Result; /* 𝓐𝓼𝓼𝓮𝓻𝓽 */ Assert.False(testSequenceItemAction.IsFail); Assert.Null(testSequenceItemAction.Exception); Assert.Equal(JsonConvert.SerializeObject(testModel), JsonConvert.SerializeObject(actual)); }
public void SequenceItemActionCheck_ScribanSubstitute_InvalidScriban() { /* 𝓐𝓻𝓻𝓪𝓷𝓰𝓮... */ var testSequenceItem = new SequenceItem { command = "some-check-sriban-expect-invalid-template", check = new SequenceCheck { pass_template = "{{this is not valid scriban!}}true{{else}}false{{end}}" } }; var testModel = new { someData = "some data" }; var dummyRunState = new RunState { YamlOptions = new YamlScript { sequence_items = new[] { testSequenceItem }.ToList() } }; var testSequenceItemAction = new SequenceItemCheck(dummyRunState, testSequenceItem, testModel, new List <SequenceItem>()); /* 𝓐𝓬𝓽 */ var actual = testSequenceItemAction.ActionAsync(new CancellationToken()).Result; /* 𝓐𝓼𝓼𝓮𝓻𝓽 */ Assert.True(testSequenceItemAction.IsFail); Assert.NotNull(testSequenceItemAction.Exception); Assert.Null(actual); }
public void SequenceItemActionCheck_ExpectSuccess() { /* 𝓐𝓻𝓻𝓪𝓷𝓰𝓮... */ var testSequenceItem = new SequenceItem { command = "check-item", check = new SequenceCheck { pass_template = "true" } }; var dummyRunState = new RunState { YamlOptions = new YamlScript { sequence_items = new[] { testSequenceItem }.ToList() } }; var testModel = new { SomeData = "this is some data" }; var testSequenceItemAction = new SequenceItemCheck(dummyRunState, testSequenceItem, testModel, new List <SequenceItem>()); /* 𝓐𝓬𝓽 */ var actual = testSequenceItemAction.ActionAsync(new CancellationToken()).Result; /* 𝓐𝓼𝓼𝓮𝓻𝓽 */ Assert.False(testSequenceItemAction.IsFail); Assert.Null(testSequenceItemAction.Exception); Assert.Equal(JsonConvert.SerializeObject(testModel), JsonConvert.SerializeObject(actual)); }