예제 #1
0
        public void TestNew()
        {
            IValueParser parser = Substitute.For <IValueParser>();

            ValueScalarMapper mapper = new ValueScalarMapper("bar", parser);

            Assert.Equal("bar", mapper.name);
            Assert.Same(parser, mapper.parser);
        }
예제 #2
0
        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);
        }