예제 #1
0
        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());
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
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);
        }