public void Can_add_type_mapped_parameter_by_type(bool nullable) { var typeMapper = new FakeRelationalTypeMapper(); var type = nullable ? typeof(int?) : typeof(int); var parameterBuilder = new RelationalParameterBuilder(typeMapper); parameterBuilder.AddParameter( "InvariantName", "Name", type, unicode: true); Assert.Equal(1, parameterBuilder.Parameters.Count); var parameter = parameterBuilder.Parameters[0] as TypeMappedRelationalParameter; Assert.NotNull(parameter); Assert.Equal("InvariantName", parameter.InvariantName); Assert.Equal("Name", parameter.Name); Assert.Equal(typeMapper.GetMapping(typeof(int)), parameter.RelationalTypeMapping); Assert.Equal(nullable, parameter.Nullable); }
public void Can_add_dynamic_parameter() { var typeMapper = new FakeRelationalTypeMapper(); var parameterBuilder = new RelationalParameterBuilder(typeMapper); parameterBuilder.AddParameter( "InvariantName", "Name"); Assert.Equal(1, parameterBuilder.Parameters.Count); var parameter = parameterBuilder.Parameters[0] as DynamicRelationalParameter; Assert.NotNull(parameter); Assert.Equal("InvariantName", parameter.InvariantName); Assert.Equal("Name", parameter.Name); }
public void Can_add_type_mapped_parameter_by_property(bool nullable) { var typeMapper = new FakeRelationalTypeMapper(); var property = new Model().AddEntityType("MyType").AddProperty("MyProp", typeof(string)); property.IsNullable = nullable; var parameterBuilder = new RelationalParameterBuilder(typeMapper); parameterBuilder.AddParameter( "InvariantName", "Name", property); Assert.Equal(1, parameterBuilder.Parameters.Count); var parameter = parameterBuilder.Parameters[0] as TypeMappedRelationalParameter; Assert.NotNull(parameter); Assert.Equal("InvariantName", parameter.InvariantName); Assert.Equal("Name", parameter.Name); Assert.Equal(typeMapper.GetMapping(property), parameter.RelationalTypeMapping); Assert.Equal(nullable, parameter.IsNullable); }