public void 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 ShortcodeResult result = shortcode.Execute(args, "Fizzbuzz", document, context); // Then result.ShouldBeNull(); }
public void 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 ShortcodeResult result = shortcode.Execute(args, "Fizzbuzz", document, context); // Then result.ShouldBeNull(); }
public void 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 ShortcodeResult result = shortcode.Execute(args, "Fizzbuzz", document, context); // Then result.ContentProvider.GetStream().ReadToEnd().ShouldBe("Fizzbuzz"); }
public void 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 ShortcodeResult result = shortcode.Execute(args, "Fizzbuzz", document, context); // Then result.ContentProvider.GetStream().ReadToEnd().ShouldBe("Fizzbuzz"); }