Пример #1
0
        public void Standard_methods_have_precedence_over_dynamic_methods()
        {
            var dyn = new TestDynamicClass();

            var interpreter = new Interpreter()
                              .SetVariable("dyn", dyn);

            Assert.AreEqual(dyn.ToString(), interpreter.Eval("dyn.ToString()"));
        }
Пример #2
0
        public void Standard_methods_have_precedence_over_dynamic_methods()
        {
            var dyn = new TestDynamicClass();

            var interpreter = new Interpreter()
                .SetVariable("dyn", dyn);

            Assert.AreEqual(dyn.ToString(), interpreter.Eval("dyn.ToString()"));
        }
Пример #3
0
        public void Standard_properties_have_precedence_over_dynamic_properties()
        {
            var dyn = new TestDynamicClass();

            dyn.RealProperty = "bar";

            var interpreter = new Interpreter()
                              .SetVariable("dyn", dyn);

            Assert.AreEqual(dyn.RealProperty, interpreter.Eval("dyn.RealProperty"));
        }
        public void MapTo_Given_Properties_Dont_Match_Returns_Class_With_Property_Values_Instantiated_As_Default()
        {
            // Arrange
            var content = new TestDynamicClass();

            content.TestLongProperty                   = 1;
            content.TestBoolProperty                   = true;
            content.TestStringProperty                 = "Test";
            content.TestDateTimeOffsetProperty         = DateTimeOffset.Now;
            content.TestNullableDateTimeOffsetProperty = DateTimeOffset.Now;

            // Act
            var mappedContent = content.MapTo <TestInvalidClass>();

            // Assert
            mappedContent.TestPropertyWithDifferentName.ShouldBe(default(long));
            mappedContent.TestDateTimeOffsetProperty.ShouldBe(default(DateTimeOffset?));
        }
        public void MapTo_Given_Properties_Match_Returns_Class_With_Property_Values_Populated_From_DynamicContent()
        {
            // Arrange
            var content = new TestDynamicClass();

            content.TestLongProperty                   = 1;
            content.TestBoolProperty                   = true;
            content.TestStringProperty                 = "Test";
            content.TestDateTimeOffsetProperty         = DateTimeOffset.Now;
            content.TestNullableDateTimeOffsetProperty = DateTimeOffset.Now;

            // Act
            var mappedContent = content.MapTo <TestValidClass>();

            // Assert
            mappedContent.TestLongProperty.ShouldBe(content.TestLongProperty);
            mappedContent.TestBoolProperty.ShouldBe(content.TestBoolProperty);
            mappedContent.TestStringProperty.ShouldBe(content.TestStringProperty);
            mappedContent.TestDateTimeOffsetProperty.ShouldBe(content.TestDateTimeOffsetProperty);
            mappedContent.TestNullableDateTimeOffsetProperty.ShouldBe(content.TestNullableDateTimeOffsetProperty);
        }
Пример #6
0
        public void Standard_properties_have_precedence_over_dynamic_properties()
        {
            var dyn = new TestDynamicClass();
            dyn.RealProperty = "bar";

            var interpreter = new Interpreter()
                .SetVariable("dyn", dyn);

            Assert.AreEqual(dyn.RealProperty, interpreter.Eval("dyn.RealProperty"));
        }