Ejemplo n.º 1
0
        public void bind_builder_types()
        {
            // Demonstrates that the builder indirection can be used

            PropertyTreeReader pt = LoadContent("epsilon-builder.xml");

            Assert.True(pt.Read());

            Epsilon e = pt.Bind <Epsilon>();

            Assert.True(e is EpsilonAlpha);
            Assert.Equal(256, e.A);
            Assert.Equal(TimeSpan.Parse("2.5:05:05.200"), e.B);
            Assert.Equal(2256.231250002, e.C);
            Assert.Equal(293680235, e.D);

            Assert.IsInstanceOf <EpsilonExtended>(e.E);

            EpsilonExtended f = (EpsilonExtended)e.E;

            Assert.Equal(1256, f.A);
            Assert.Equal(TimeSpan.Parse("12.5:05:05.200"), f.B);
            Assert.Equal(12256.231250002, f.C);
            Assert.Equal(1293680235, f.D);
            Assert.Equal(DateTime.Parse("2011-05-12 8:45AM"), f.F);
        }
Ejemplo n.º 2
0
        public void bind_ordered_list()
        {
            // Binding of an ordered list IList<T> implementation

            PropertyTreeReader pt = LoadContent("delta.xml");

            Assert.True(pt.Read());

            Delta originalD = new Delta();
            Delta d         = pt.Bind(originalD);

            Assert.True(object.ReferenceEquals(d, originalD));
            Assert.Equal(3, d.A.Count);

            Assert.True(d.A[0].A);
            Assert.Equal(0, d.A[0].B);
            Assert.Equal('g', d.A[0].D);
            Assert.Equal(DateTime.Parse("3/30/2011 1:50 AM"), d.A[0].E);

            Assert.Equal(10.5000m, d.A[1].F);
            Assert.Equal(10.5, d.A[1].G);
            Assert.Equal(256, d.A[1].H);
            Assert.Equal(1024, d.A[1].I);

            Assert.Equal("Carbonfrost F5 Project", d.A[2].M);
            Assert.Equal(new Uri("http://carbonfrost.com"), d.A[2].Q);
            Assert.Equal(TimeSpan.Parse("4.12:0:30.5"), d.A[2].R);
            Assert.Equal(new Guid("{ED826F6C-47B5-4C40-B5B1-E847CB193E03}"), d.A[2].S);

            Assert.Equal(10.5000m, d.B[0].A.F);
            Assert.Equal(10.5, d.B[0].A.G);

            // <add> is inherited, but still binds
            Assert.Equal("Carbonfrost F5 Project", d.C[0].M);
        }
Ejemplo n.º 3
0
        public void bind_nondefault_constructors_complex()
        {
            // Demonstrates that an object with a nondefault constructor
            // can be populated with a complex object like Eta

            PropertyTreeReader pt = LoadContent("iota.xml");

            Assert.True(pt.Read());

            Iota i = pt.Bind <Iota>();

            Assert.Equal(8256, i.A);
            Assert.Equal(TimeSpan.Parse("82.5:05:05.200"), i.B);
            Assert.Equal(82256.231250002, i.C);
            Assert.Equal(8293680235, i.D);
            Assert.Equal("Typedescriptor", i.F);
            Assert.Equal(new Uri("http://carbonfrost.com"), i.G);

            Eta e = i.E;

            Assert.Equal(256, e.A);
            Assert.Equal(TimeSpan.Parse("2.5:05:05.200"), e.B);
            Assert.Equal(2256.231250002, e.C);
            Assert.Equal(293680235, e.D);
        }
Ejemplo n.º 4
0
        public void bind_template_primitive_types()
        {
            PropertyTreeReader pt = LoadContent("alpha.xml");

            Assert.True(pt.Read());
            var template = pt.Bind <Template <Alpha> >();
            var a        = new Alpha();

            template.Apply(a);

            Assert.True(a.A);
            Assert.False(a.AA.HasValue);
            Assert.Equal(0, a.B);
            Assert.True(a.BB.HasValue);
            Assert.Equal(0, a.BB.Value);
            Assert.Equal('g', a.D);
            Assert.Equal(DateTime.Parse("3/30/2011 1:50 AM"), a.E);
            Assert.Equal(10.5000m, a.F);
            Assert.Equal(10.5, a.G);
            Assert.Equal(256, a.H);
            Assert.Equal(1024, a.I);
            Assert.Equal(102410241024, a.J);
            Assert.Equal(-120, a.K);
            Assert.Equal(float.NaN, a.L);
            Assert.Equal("Carbonfrost F5 Project", a.M);
            Assert.Equal(65535, a.N);
            Assert.True(6553620 == a.O);
            Assert.True(6553620655362 == a.P);
            Assert.Equal(new Uri("http://carbonfrost.com"), a.Q);
            Assert.Equal(TimeSpan.Parse("4.12:0:30.5"), a.R);
            Assert.Equal(new Guid("{BF972F0A-CB10-441B-9D25-3D6DEB9065D1}"), a.S);
            Assert.Equal(DateTimeOffset.Parse("4/1/2011 12:11:01 AM -04:00"), a.T);
            Assert.Equal(typeof(Glob), a.U);
        }
Ejemplo n.º 5
0
        public void bind_concrete_class_indirections()
        {
            PropertyTreeReader pt = LoadContent("mu.xml");

            Assert.True(pt.Read());

            var b = (MuAlpha)pt.Bind <Mu>();

            Assert.Equal(420, b.B);
        }
Ejemplo n.º 6
0
        public void bind_latebound_provider_criteria()
        {
            PropertyTreeReader pt = LoadContent("iota-chi-2.xml");

            Assert.True(pt.Read());

            IotaChi b = pt.Bind(new IotaChi());

            Assert.Equal("properties", App.GetProviderName(typeof(StreamingSource), b.A).LocalName);
        }
Ejemplo n.º 7
0
        public void Bind_should_pickup_items_added_to_name_scope_and_bind_expression()
        {
            PropertyTreeReader pt = LoadContent("omicron-theta-3.xml");

            Assert.True(pt.Read());

            OmicronTheta b = pt.Bind <OmicronTheta>();

            Assert.Equal("Some string", b.Beta.D);
        }
Ejemplo n.º 8
0
        public void bind_should_apply_uri_context_to_object()
        {
            PropertyTreeReader pt = LoadContent("alpha-chi.xml");

            Assert.True(pt.Read());

            var a = pt.Bind <AlphaChi>();

            Assert.True(Convert.ToString(a.BaseUri).EndsWith("alpha-chi.xml"));
        }
Ejemplo n.º 9
0
        public void Bind_should_bind_undefined_expressions_by_ignoring()
        {
            PropertyTreeReader pt = LoadContent("beta-upsilon.xml");

            Assert.True(pt.Read());

            Beta b = pt.Bind(new Beta());

            Assert.Null(b.D);
        }
Ejemplo n.º 10
0
        public void bind_should_apply_uri_context_to_accessible_properties()
        {
            PropertyTreeReader pt = LoadContent("beta-6.xml");

            Assert.True(pt.Read());

            var a = pt.Bind <Beta>();

            Assert.True(Convert.ToString(a.J.BaseUri).EndsWith("beta-6.xml"));
        }
Ejemplo n.º 11
0
        public void bind_add_method_factory_extension_no_parameters()
        {
            PropertyTreeReader pt = LoadContent("omicron-2.xml");

            Assert.True(pt.Read());

            Omicron o = pt.Bind <Omicron>();

            Assert.Equal(new CultureInfo("fr-FR"), o.G.A);
        }
Ejemplo n.º 12
0
        public void bind_should_prefer_source_on_class()
        {
            PropertyTreeReader pt = LoadContent("beta-3.xml");

            Assert.True(pt.Read());

            Beta b = pt.Bind(new Beta());

            Assert.Equal("not a streaming source", b.Source);
        }
Ejemplo n.º 13
0
        public void bind_should_bind_nested_class()
        {
            PropertyTreeReader pt = LoadContent("iota-2.xml");

            Assert.True(pt.Read());

            Iota i = pt.Bind <Iota>();

            Assert.Equal("ng", i.H.A);
        }
Ejemplo n.º 14
0
        public void bind_should_invoke_extension_method()
        {
            PropertyTreeReader pt = LoadContent("control-extension-property-2.xml");

            Assert.True(pt.Read());

            var p = pt.Bind <Canvas>();

            Assert.Equal(132, p.Controls[0]._Left);
            Assert.Equal(66, p.Controls[1]._Left);
        }
Ejemplo n.º 15
0
        public void bind_optional_parameters()
        {
            PropertyTreeReader pt = LoadContent("upsilon.xml");

            Assert.True(pt.Read());

            Upsilon p = pt.Bind <Upsilon>();

            Assert.Equal(45, p.A);
            Assert.Equal("yipp", p.B);
        }
Ejemplo n.º 16
0
        public void bind_composable_providers()
        {
            PropertyTreeReader pt = LoadContent("pi-chi.xml");

            Assert.True(pt.Read());

            var b = pt.Bind <PiChi>().Preconditions;

            Assert.Equal("compose(environment(\"PROCESSOR_LEVEL\", \"l\"), environment(\"QR\", \"m\"), platform())",
                         b.ToString());
        }
Ejemplo n.º 17
0
        public void bind_should_resolve_relative_source_url()
        {
            PropertyTreeReader pt = LoadContent("beta-7.xml");

            Assert.True(pt.Read());

            var a = pt.Bind <Beta>().H;

            Assert.Equal('g', a.D);
            Assert.Equal(DateTime.Parse("3/30/2011 1:50 AM"), a.E);
        }
Ejemplo n.º 18
0
        public void bind_should_invoke_ancestor_attached_property_context()
        {
            PropertyTreeReader pt = LoadContent("control-extension-property.xml");

            Assert.True(pt.Read());

            var p = pt.Bind <Canvas>();

            Assert.Equal(40, p.Controls[0]._Top);
            Assert.Equal(80, p.Controls[1]._Top);
        }
Ejemplo n.º 19
0
        public void bind_composable_providers_add_child()
        {
            PropertyTreeReader pt = LoadContent("pi-chi.xml");

            Assert.True(pt.Read());

            var b = pt.Bind <PiChi>().Controls;

            Assert.True(b.Controls[0] is Paragraph);
            Assert.True(b.Controls[0].Controls[0] is TextBox);
        }
Ejemplo n.º 20
0
        public void bind_should_resolve_NameValueCollection()
        {
            PropertyTreeReader pt = LoadContent("echo.xml");

            Assert.True(pt.Read());

            var a = pt.Bind <Echo>().V;

            Assert.Equal(1, a.Keys.Count);
            Assert.Equal("b", a["a"]);
        }
Ejemplo n.º 21
0
        public void bind_should_apply_file_location_to_object()
        {
            PropertyTreeReader pt = LoadContent("beta-6.xml");

            Assert.True(pt.Read());
            var a = pt.Bind <Beta>();

            Assert.True(a.I.SetFileLocationCalled);
            Assert.Equal(9, a.I.LineNumber);
            Assert.Equal(6, a.I.LinePosition);
        }
Ejemplo n.º 22
0
        public void bind_should_store_id_in_name_scope()
        {
            PropertyTreeReader pt = LoadContent("omicron-theta.xml");

            Assert.True(pt.Read());

            var ot = pt.Bind <OmicronThetaWithScope>();

            Assert.NotNull(ot.FindName("alpha"));
            Assert.Same(ot.Alpha, ot.FindName("alpha"));
        }
Ejemplo n.º 23
0
        public void bind_should_resolve_source_ellison()
        {
            PropertyTreeReader pt = LoadContent("omicron-theta-2.xml");

            Assert.True(pt.Read());

            var a = pt.Bind <OmicronTheta>().Alpha;

            Assert.Equal('g', a.D);
            Assert.Equal(DateTime.Parse("3/30/2011 1:50 AM"), a.E);
        }
Ejemplo n.º 24
0
        public void bind_missing_properties_throws_exception()
        {
            PropertyTreeReader pt = LoadContent("beta-4.xml");

            Assert.True(pt.Read());

            var ex = Record.Exception(() => pt.Bind <Beta>());

            Assert.IsInstanceOf <PropertyTreeException>(ex);
            Assert.Contains("line 2, pos 5", ex.Message);
        }
Ejemplo n.º 25
0
        public void bind_missing_required_parameter_different_namespace()
        {
            PropertyTreeReader pt = LoadContent("eta-invalid-2.xml");

            Assert.True(pt.Read());

            var ex = ExpectPropertyTreeException(() => pt.Bind <Eta>());

            //Assert.Matches(@"required properties .+d \(https://ns.example.com/\) \(Prototypes.Eta\)", ex.Message);
            Assert.Equal(4, ex.FileLocation.LineNumber);
            Assert.Equal(2, ex.FileLocation.LinePosition);
        }
Ejemplo n.º 26
0
        public void bind_latebound_provider()
        {
            Assert.NotNull(StreamingSource.FromName("xmlFormatter"));

            PropertyTreeReader pt = LoadContent("iota-chi.xml");

            Assert.True(pt.Read());

            IotaChi b = pt.Bind(new IotaChi());

            Assert.Equal("xmlFormatter", App.GetProviderName(typeof(StreamingSource), b.A).LocalName);
        }
Ejemplo n.º 27
0
        public void bind_add_method_factory_extension_generic()
        {
            // Demonstrates that a generic interface implementation can
            // supply add methods
            PropertyTreeReader pt = LoadContent("phi.xml");

            Assert.True(pt.Read());

            Phi p = pt.Bind <Phi>();

            Assert.NotNull(p.G);
        }
Ejemplo n.º 28
0
        public void bind_dictionary_access_kvp_syntax()
        {
            PropertyTreeReader pt = LoadContent("beta-5.xml");

            Assert.True(pt.Read());

            Beta p = pt.Bind <Beta>();

            Assert.Equal(new DateTime(2011, 3, 30, 1, 50, 00), p.G["gu"].E);
            Assert.Equal(10.5000m, p.G["gu"].F);
            Assert.Equal(10.5, p.G["gu"].G);
        }
Ejemplo n.º 29
0
        public void bind_should_store_name_in_name_scope()
        {
            PropertyTreeReader pt = LoadContent("omicron-theta-2.xml");

            Assert.True(pt.Read());

            var ot = pt.Bind <OmicronThetaWithScope>();

            Assert.NotNull(ot.FindName("my"));
            Assert.Same(ot.Delta, ot.FindName("my"));
            Assert.Equal("my", ot.Delta.Name);
        }
Ejemplo n.º 30
0
        public void bind_abstract_builder_types()
        {
            // Demonstrates that the builder indirection can be used on abstract types

            PropertyTreeReader pt = LoadContent("epsilon-chi-builder.xml");

            Assert.True(pt.Read());

            EpsilonChi e = pt.Bind <EpsilonChi>();

            Assert.IsInstanceOf <EpsilonChiAlpha>(e);
        }