public void TestBuildMapper__CantBuild() { IValueParseMap parseMap = Substitute.For <IValueParseMap>(); ValueScalarMapperBuilder builder = new ValueScalarMapperBuilder("foo", typeof(DummyClass), parseMap); parseMap.CanParse(typeof(DummyClass)).Returns(false); Assert.Throws <InvalidOperationException>(() => builder.BuildMapper()); }
public void TestNew() { IValueParseMap parseMap = Substitute.For <IValueParseMap>(); ValueScalarMapperBuilder builder = new ValueScalarMapperBuilder("foo", typeof(DummyClass), parseMap); Assert.Equal("foo", builder.nodeDataName); Assert.Same(typeof(DummyClass), builder.fieldType); Assert.Same(parseMap, builder.parseMap); }
public void TestCanBuild__False() { IValueParseMap parseMap = Substitute.For <IValueParseMap>(); ValueScalarMapperBuilder builder = new ValueScalarMapperBuilder("foo", typeof(DummyClass), parseMap); parseMap.CanParse(typeof(DummyClass)).Returns(false); Assert.False(builder.CanBuild); }
public void TestCreateValueScalarMapperBuilder() { builder.NodeDataName.Returns("foo"); fieldWrapper.FieldType.Returns(typeof(DummyClass)); ValueScalarMapperBuilder mapperBuilder = Assert.IsType <ValueScalarMapperBuilder>(builder.CreateValueScalarMapperBuilder()); Assert.Equal("foo", mapperBuilder.nodeDataName); Assert.Same(typeof(DummyClass), mapperBuilder.fieldType); Assert.Same(parseMap, mapperBuilder.parseMap); }
public void TestBuildMapper() { IValueParseMap parseMap = Substitute.For <IValueParseMap>(); ValueScalarMapperBuilder builder = new ValueScalarMapperBuilder("foo", typeof(DummyClass), parseMap); IValueParser parser = Substitute.For <IValueParser>(); parseMap.CanParse(typeof(DummyClass)).Returns(true); parseMap.GetParser(typeof(DummyClass)).Returns(parser); ValueScalarMapper mapper = Assert.IsType <ValueScalarMapper>(builder.BuildMapper()); parseMap.Received().GetParser(typeof(DummyClass)); Assert.Equal("foo", mapper.name); Assert.Same(parser, mapper.parser); }