public void Should_convert_html_to_text()
        {
            const string script = @"
                return html2Text(value);
            ";

            var vars = new ScriptVars
            {
                ["value"] = "<script>Invalid</script><STYLE>Invalid</STYLE><p>Hello World</p>"
            };

            var result = sut.Execute(vars, script).ToString();

            Assert.Equal("Hello World", result);
        }
Beispiel #2
0
        public void Should_camel_case_value()
        {
            const string script = @"
                return toCamelCase(value);
            ";

            var vars = new ScriptVars
            {
                ["value"] = "Hello World"
            };

            var result = sut.Execute(vars, script).ToString();

            Assert.Equal("helloWorld", result);
        }
        public void Should_reset_counter()
        {
            var appId = Guid.NewGuid();

            A.CallTo(() => grainFactory.GetGrain <ICounterGrain>(appId, null))
            .Returns(counter);

            A.CallTo(() => counter.ResetAsync("my", 4))
            .Returns(3);

            const string script = @"
                return resetCounter('my', 4);
            ";

            var context = new ScriptVars
            {
                ["appId"] = appId
            };

            var result = sut.Execute(context, script).ToString();

            Assert.Equal("3", result);
        }
Beispiel #4
0
        public void Should_handle_domain_id_as_string()
        {
            var id = DomainId.NewGuid();

            const string script = @"
                return value;
            ";

            var context = new ScriptVars
            {
                ["value"] = id
            };

            var result = sut.Execute(context, script);

            Assert.Equal(id.ToString(), result.ToString());
        }
 public void Should_throw_validation_exception_when_calling_reject()
 {
     Assert.Throws <ValidationException>(() => scriptEngine.Execute(new ScriptContext(), "reject()"));
     Assert.Throws <ValidationException>(() => scriptEngine.Execute(new ScriptContext(), "reject('Not valid')"));
 }