Example #1
0
        public void CapturesMultipleObjectsAsBean()
        {
            int    a = 330;
            float  b = 12.784f;
            string c = "paradigm";

            TestClass captive = new TestClass(a, b, c);

            string c2 = "porcupine";
            int    d  = 990;
            object e  = new OperatingSystem(PlatformID.Unix, new Version());

            AnotherTestClass captive2 = new AnotherTestClass(c2, d, e);

            Bean bean = new Bean(captive);

            bool overwrite = false;

            bean.Capture(captive2, overwrite);

            Assert.IsTrue(bean.HasValue("A"));
            Assert.IsTrue(bean.HasValue("B"));
            Assert.IsTrue(bean.HasValue("C"));
            Assert.IsTrue(bean.HasValue("D"));
            Assert.IsTrue(bean.HasValue("E"));
            Assert.AreEqual(a.ToString(), bean.GetValue("A"));
            Assert.AreEqual(b.ToString(), bean.GetValue("B"));
            Assert.AreEqual(c, bean.GetValue("C"));
            Assert.AreEqual(d.ToString(), bean.GetValue("D"));
            Assert.AreEqual(e.ToString(), bean.GetValue("E"));

            overwrite = true;

            bean.Capture(captive2, overwrite);

            Assert.IsTrue(bean.HasValue("A"));
            Assert.IsTrue(bean.HasValue("B"));
            Assert.IsTrue(bean.HasValue("C"));
            Assert.IsTrue(bean.HasValue("D"));
            Assert.IsTrue(bean.HasValue("E"));
            Assert.AreEqual(a.ToString(), bean.GetValue("A"));
            Assert.AreEqual(b.ToString(), bean.GetValue("B"));
            Assert.AreEqual(c2, bean.GetValue("C"));
            Assert.AreEqual(d.ToString(), bean.GetValue("D"));
            Assert.AreEqual(e.ToString(), bean.GetValue("E"));
        }
Example #2
0
        public void UseDifferentModelsWithSameMemberName()
        {
            // Arrange
            var template = _parser.Parse("Hi {{Name}}");
            var model1   = new TestClass {
                Name = "TestClass"
            };
            var model2 = new AnotherTestClass {
                Name = "AnotherTestClass"
            };

            // Act
            template.Render(new TemplateContext(model1));
            template.Render(new TemplateContext(model2));
            template.Render(new TemplateContext(model2));
            template.Render(new TemplateContext(model2));
            template.Render(new TemplateContext(model1));
            template.Render(new TemplateContext(model2));
        }
Example #3
0
 /// <summary>
 /// Prints the SomeData property of the testObject parameter. Used to test invokation from the server.
 /// </summary>
 /// <param name="testObject">Test object to handle</param>
 public void HandleAnotherTestClass(AnotherTestClass testObject)
 {
     Console.WriteLine("Received message: {0}", testObject.SomeData);
 }
 public TestClass(AnotherTestClass anotherTestClass)
 {
     _anotherTestClass = anotherTestClass;
 }
Example #5
0
 public TestClass(AnotherTestClass anotherTestClass)
 {
 }