コード例 #1
0
        public void TestLoadTypeCreatesType()
        {
            ModelType      outType;
            IList <string> propertyNames = new List <string>();

            propertyNames.Add("Location");
            provider.CreateType(propertyNames, out outType, "TypeName");

            //Verify the new type was created
            Assert.AreEqual(true, provider.Types.ContainsKey("TypeName"));
            Assert.AreEqual("TypeName", outType.Name);

            //Verify the properties on created type
            Assert.AreEqual(1, outType.Properties.Count);
            Assert.AreEqual("_Location", outType.Properties.First().Name);
            Assert.AreNotEqual(null, outType.Properties["_Location"]);
        }
コード例 #2
0
        public void TestDualContext()
        {
            ///This method will make sure that both the static and dynamic context's are available
            ///for use by the translator.
            ModelType      outType;
            IList <string> propertyNames = new List <string>();

            propertyNames.Add("Employee Id");
            propertyNames.Add("Location");
            propertyNames.Add("FirstName");
            propertyNames.Add("LastName");
            dynamicProvider.CreateType(propertyNames, out outType, "TypeName");

            //now that the type has been created, try to retrieve the type from the context
            ModelType dynamicType = ModelContext.Current.GetModelType("TypeName");

            Assert.AreEqual("TypeName", dynamicType.Name);

            ModelType staticType = ModelContext.Current.GetModelType("Account");

            Assert.AreEqual("Account", staticType.Name);
        }