public void TestFormat1()
        {
            decimal amount = 100.00m;

            _w.Write($"Price: {amount:000}");
            Assert.AreEqual("Price: 100", _w.GetContents());
        }
Beispiel #2
0
 public void TestCBlockFluentAPI()
 {
     _w
     .WriteLine("// will open a C block")
     .WithCBlock("void MyMethod()", () =>
     {
         _w.WriteLine("int i = 0;");
     });
     Assert.AreEqual(expected_C, _w.GetContents());
 }
        public void TestMultiline1()
        {
            _w.WriteLine(@"
                public void MyMethod1()
                {
                    //...
                }");

            string expected =
                @"public void MyMethod1()
{
    //...
}
";

            Assert.AreEqual(expected, _w.GetContents());
        }
Beispiel #4
0
        public void TestCallback1()
        {
            Action <CodegenTextWriter> callback = (w) => w.WriteLine("Hello3");

            _w
            // Inside indented block we call anonymous Action
            .WithCurlyBraces("void MyMethod1()", () =>
            {
                _w.WriteLine("Hello");
            })

            // Inside indented block we call anonymous Action<CodegenTextWriter>
            .WithCurlyBraces("void MyMethod2()", (w) =>
            {
                w.WriteLine("Hello2");
            })

            // Inside indented block we call a named Action<CodegenTextWriter>
            .WithCurlyBraces("void MyMethod3()", callback)

            // After (outside) the indented block we call a named Action<CodegenTextWriter>
            .Write(callback)
            ;

            string expected = @"
void MyMethod1()
{
    Hello
}
void MyMethod2()
{
    Hello2
}
void MyMethod3()
{
    Hello3
}
Hello3
".TrimStart();

            Assert.AreEqual(expected, _w.GetContents());
        }
Beispiel #5
0
        public void TestIF_false_ENDIF()
        {
            _w.Write($@"WILL SHOW{IF(false)} WON'T SHOW{ENDIF}");

            string expected = @"WILL SHOW";

            Assert.AreEqual(expected, _w.GetContents());
        }