public void TestNew() { IValueParser parser = Substitute.For <IValueParser>(); ValueScalarMapper mapper = new ValueScalarMapper("bar", parser); Assert.Equal("bar", mapper.name); Assert.Same(parser, mapper.parser); }
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); }