public void set_and_get_a_nullable_integer() { ConstructorInstance instance = ConstructorInstance.For <ClassWithNullableInt>(); instance.SetValue("age", "45"); instance.Get("age", typeof(int?), new StubBuildSession()).ShouldEqual(45); instance.SetValue("age", null); instance.Get("age", typeof(int?), new StubBuildSession()).ShouldBeNull(); }
public void get_and_set_for_a_nullable_date_time() { ConstructorInstance instance = ConstructorInstance.For <ClassWithNullableDate>(); instance.SetValue("date", "12/23/2009"); instance.Get("date", typeof(DateTime?), new StubBuildSession()).ShouldEqual(new DateTime(2009, 12, 23)); instance.SetValue("date", null); instance.Get("date", typeof(DateTime?), new StubBuildSession()).ShouldBeNull(); }
public void get_and_set_for_a_guid() { ConstructorInstance instance = ConstructorInstance.For <ClassWithGuid>(); Guid guid = Guid.NewGuid(); instance.SetValue("guid", guid.ToString()); instance.Get("guid", typeof(Guid), new StubBuildSession()).ShouldEqual(guid); }
public void set_and_get_a_string() { ConstructorInstance instance = ConstructorInstance.For <ColorWidget>(); instance.SetValue("color", "Red"); instance.Get("color", typeof(string), new StubBuildSession()).ShouldEqual("Red"); }
public void get_and_set_a_non_primitive_type_that_is_not_enumerable() { ConstructorInstance instance = ConstructorInstance.For <ClassWithNonPrimitive>(); var widget = new AWidget(); instance.SetValue("widget", widget); instance.Get("widget", typeof(IWidget), new StubBuildSession()).ShouldEqual(widget); }
public void Process(Type type, Registry registry) { //if (!typeof(IPersistenceDetails).IsAssignableFrom(type)) // return; if (!type.Name.Equals("PersistenceDetails")) return; IConfiguredInstance ctor = new ConstructorInstance(type); ctor.SetValue("location", this.connectionString); registry.For(type.BaseType).HttpContextScoped().Add(ctor); }
public void Process(Type type, Registry registry) { //if (!typeof(IPersistenceDetails).IsAssignableFrom(type)) // return; if (!type.Name.Equals("PersistenceDetails")) { return; } IConfiguredInstance ctor = new ConstructorInstance(type); ctor.SetValue("location", this.connectionString); registry.For(type.BaseType).HttpContextScoped().Add(ctor); }
public void Process(Type type, Registry registry) { if (!type.Name.StartsWith("Sql")) { return; } if (type == typeof(SqlCurrency)) { return; } IConfiguredInstance ctor = new ConstructorInstance(type); ctor.SetValue("connString", this.connectionString); registry.For(type.BaseType).HttpContextScoped().Add(ctor); }
public void Process(Type type, Registry registry) { if (!type.Name.StartsWith("Sql")) { return; } if (type == typeof(SqlCurrency)) { return; } IConfiguredInstance ctor = new ConstructorInstance(type); ctor.SetValue("connString", this.connectionString); registry.For(type.BaseType).HttpContextScoped().Add(ctor); }