public void TestTypeMappings() { TypeMappingCollection mappings = new TypeMappingCollection(); ConfigurationSectionHelper testHelper = new ConfigurationSectionHelper(); testHelper.TypeMappings = mappings; Assert.AreEqual(mappings, testHelper.TypeMappings); }
public void TestAdd() { TypeMappingCollection collection = new TypeMappingCollection(); TypeMappingConfigurationElement element = new TypeMappingConfigurationElement(); collection.Add(element); TypeMappingConfigurationElement[] returnedElements = new TypeMappingConfigurationElement[1]; collection.CopyTo(returnedElements, 0); Assert.AreEqual(element, returnedElements[0]); }
public void TestParsingRegistrations() { ConfigurationSectionHelper helper = new ConfigurationSectionHelper(); TypeMappingConfigurationElement element = new TypeMappingConfigurationElement(); element.TypeName = "System.Object"; element.MapTo = "RockSolidIoc.Tests.EmptyObject"; TypeMappingCollection collection = new TypeMappingCollection(); collection.Add(element); helper.TypeMappings = collection; Configurator testConfigurator = new Configurator(); IIocContainer result = testConfigurator.Configure(helper); object s = result.Resolve<object>(); Assert.IsInstanceOfType(s, typeof(EmptyObject)); }
public void TestMigrationPlanLoad() { MigrationPlan plan = MigrationPlan.Load("test-plan-1.xml"); AssertNotNull("MigrationPlan.Load", plan); AssertNotNull("plan.Culture", plan.Culture); AssertEquals("plan.Culture", CultureInfo.CreateSpecificCulture("pt-br"), plan.Culture); TypeMappingCollection mappings = plan.TypeMappings; AssertNotNull("plan.TypeMappings", mappings); // 3 mappings counting the aliases... AssertEquals("mappings.Count", 3, mappings.Count); TypeMapping mapping = mappings["SamplePrevalentSystem.Title"]; AssertNotNull("mapping", mapping); AssertEquals(string.Empty, mapping.AssemblyName); AssertEquals("mapping.FieldMappings.Count", 3, mapping.FieldMappings.Count); mapping = mappings["SamplePrevalentSystem.LibrarySystem"]; AssertNotNull("mapping", mapping); AssertEquals(string.Empty, mapping.AssemblyName); AssertEquals(mapping, mappings["SamplePrevalentSystem.Library"]); AssertEquals(2, plan.Scripts.Count); Script s = plan.Scripts[0]; AssertEquals("context", s.TargetObject); AssertEquals("AfterDeserialization", s.TargetEvent); AssertEquals("// Nothing here...", s.Code); AssertEquals("vb", s.Language); s = plan.Scripts[1]; AssertEquals("c# must be the default language", "c#", s.Language); AssertEquals(1, s.Imports.Count); AssertEquals("SamplePrevalentSystem", s.Imports[0].Namespace); }
static SqlTypeExtensions() { SqlMappings = new TypeMappingCollection(); SqlMappings.Add(typeof(Int16), "smallint"); SqlMappings.Add(typeof(Int32), "int"); SqlMappings.Add(typeof(Int64), "bigint"); SqlMappings.Add(typeof(Byte[]), "binary"); //Mappings.Add(typeof(Byte[]), "image"); //Mappings.Add(typeof(Byte[]), "rowversion"); //Mappings.Add(typeof(Byte[]), "timestamp"); SqlMappings.Add(typeof(Byte), "tinyint"); SqlMappings.Add(typeof(Boolean), "bit"); SqlMappings.Add(typeof(DateTime), "date"); //Mappings.Add(typeof(DateTime), "datetime"); //Mappings.Add(typeof(DateTime), "datetime2"); //Mappings.Add(typeof(DateTime), "smalldatetime"); SqlMappings.Add(typeof(TimeSpan), "time"); SqlMappings.Add(typeof(DateTimeOffset), "datetimeoffset"); SqlMappings.Add(typeof(Decimal), "decimal"); //Mappings.Add(typeof(Decimal), "money"); //Mappings.Add(typeof(Decimal), "numeric"); //Mappings.Add(typeof(Decimal), "smallmoney"); SqlMappings.Add(typeof(Double), "float"); SqlMappings.Add(typeof(String), "varchar(max)"); //Mappings.Add(typeof(String), "nchar"); //Mappings.Add(typeof(String), "ntext"); //Mappings.Add(typeof(String), "nvarchar"); //Mappings.Add(typeof(String), "char"); //Mappings.Add(typeof(String), "text"); SqlMappings.Add(typeof(Single), "real"); SqlMappings.Add(typeof(Guid), "uniqueidentifier"); SqliteMappings = new TypeMappingCollection(); SqliteMappings.Add(typeof(Int16), "smallint"); SqliteMappings.Add(typeof(Int32), "int"); SqliteMappings.Add(typeof(Int64), "bigint"); SqliteMappings.Add(typeof(Byte[]), "binary"); //Mappings.Add(typeof(Byte[]), "image"); //Mappings.Add(typeof(Byte[]), "rowversion"); //Mappings.Add(typeof(Byte[]), "timestamp"); SqliteMappings.Add(typeof(Byte), "tinyint"); SqliteMappings.Add(typeof(Boolean), "bit"); SqliteMappings.Add(typeof(DateTime), "date"); //Mappings.Add(typeof(DateTime), "datetime"); //Mappings.Add(typeof(DateTime), "datetime2"); //Mappings.Add(typeof(DateTime), "smalldatetime"); SqliteMappings.Add(typeof(TimeSpan), "time"); SqliteMappings.Add(typeof(DateTimeOffset), "datetimeoffset"); SqliteMappings.Add(typeof(Decimal), "decimal"); //Mappings.Add(typeof(Decimal), "money"); //Mappings.Add(typeof(Decimal), "numeric"); //Mappings.Add(typeof(Decimal), "smallmoney"); SqliteMappings.Add(typeof(Double), "float"); SqliteMappings.Add(typeof(String), "varchar(1000)"); //Mappings.Add(typeof(String), "nchar"); //Mappings.Add(typeof(String), "ntext"); //Mappings.Add(typeof(String), "nvarchar"); //Mappings.Add(typeof(String), "char"); //Mappings.Add(typeof(String), "text"); SqliteMappings.Add(typeof(Single), "real"); SqliteMappings.Add(typeof(Guid), "uniqueidentifier"); }
public static string ToSqlDbType(this Type clrType, TypeMappingCollection mappingCollection) { string datatype = null; if (mappingCollection.TryGetValue(clrType, out datatype)) return datatype; throw new TypeLoadException(string.Format("Can not load CLR Type from {0}", clrType)); }
internal virtual string GetDataType(TypeMappingCollection typeMappings) { return(DataType); }
public void TestIsNotReadOnly() { TypeMappingCollection collection = new TypeMappingCollection(); Assert.IsFalse(collection.IsReadOnly()); }
public FormDesignerGenerator(CompilationUnit compilationUnit, PropertyMappingCollection mappings, TypeMappingCollection typeMappings) { this.compilationUnit = compilationUnit; this.mappings = mappings; this.typeMappings = typeMappings; }