public async Task ReturnsNullIfMissingKey() { // Given TestExecutionContext context = new TestExecutionContext(); TestDocument document = new TestDocument(); KeyValuePair <string, string>[] args = new KeyValuePair <string, string>[] { new KeyValuePair <string, string>("Key", "Foo") }; IfShortcode shortcode = new IfShortcode(); // When IDocument result = await shortcode.ExecuteAsync(args, "Fizzbuzz", document, context); // Then result.ShouldBeNull(); }
public async Task ReturnsNullIfCanNotConvertToBool() { // Given TestExecutionContext context = new TestExecutionContext(); TestDocument document = new TestDocument(new MetadataItems { { "Foo", "abc" } }); KeyValuePair <string, string>[] args = new KeyValuePair <string, string>[] { new KeyValuePair <string, string>("Key", "Foo") }; IfShortcode shortcode = new IfShortcode(); // When IDocument result = await shortcode.ExecuteAsync(args, "Fizzbuzz", document, context); // Then result.ShouldBeNull(); }
public async Task ReturnsDocumentIfConvertedTrue() { // Given TestExecutionContext context = new TestExecutionContext(); TestDocument document = new TestDocument(new MetadataItems { { "Foo", "true" } }); KeyValuePair <string, string>[] args = new KeyValuePair <string, string>[] { new KeyValuePair <string, string>("Key", "Foo") }; IfShortcode shortcode = new IfShortcode(); // When IDocument result = await shortcode.ExecuteAsync(args, "Fizzbuzz", document, context); // Then result.ShouldBeOfType <TestDocument>().Content.ShouldBe("Fizzbuzz"); }
public async Task ReturnsDocumentIfScriptEqual() { // Given TestExecutionContext context = new TestExecutionContext(); context.ScriptHelper = new ScriptHelper(context); TestDocument document = new TestDocument() { { "Foo", 122 } }; KeyValuePair <string, string>[] args = new KeyValuePair <string, string>[] { new KeyValuePair <string, string>("Key", "=> (int)Foo + 1"), new KeyValuePair <string, string>("Value", "123") }; IfShortcode shortcode = new IfShortcode(); // When IDocument result = await shortcode.ExecuteAsync(args, "Fizzbuzz", document, context); // Then result.ShouldBeOfType <TestDocument>().Content.ShouldBe("Fizzbuzz"); }