public void Should_throw_if_converter_throws()
        {
            ConverterMock.Setup(c => c.Convert <string>(It.IsAny <JToken[]>())).Throws <InvalidCastException>();

            CreateProvider(new {})
            .Invoking(p => p.GetConfiguration <string>())
            .ShouldThrow <InvalidCastException>();
        }
        public void Should_delegate_conversion_to_converter()
        {
            ConverterMock.Setup(c => c.Convert <string>(It.IsAny <JToken[]>())).Returns <JToken[]>(tokens => String.Join(String.Empty, tokens.Select(s => s.Value <string>())));

            CreateProvider("con", "tent")
            .GetConfiguration <string>()
            .Should().Be("content");

            ConverterMock.Verify(c => c.Convert <string>(It.IsAny <JToken[]>()), Times.Once);
        }
        public void Should_select_sub_property_for_deserialization()
        {
            var selectorMock = new Mock <IConfigurationSelector <JToken, JToken> >(MockBehavior.Strict);

            selectorMock.Setup(s => s.Select(It.IsAny <JToken>())).Returns <JToken>(token => token["Parent"]["Child"]);
            ConverterMock.Setup(c => c.Convert <string>(It.IsAny <JToken[]>())).Returns <JToken[]>(tokens => tokens.First().Value <string>());

            CreateProvider(new { Parent = new { Child = "content" } })
            .GetConfiguration <string>(selectorMock.Object)
            .Should().Be("content");
        }
 protected ParserTestsBase()
 {
     ConverterMock.Setup(m => m.Convert(It.IsAny <string>())).Verifiable();
     MapperMock.Setup(m => m.MapValue(It.IsAny <object>(), It.IsAny <TValue>())).Verifiable();
     ValidatorMock.Setup(m => m.Validate(It.IsAny <TValue>())).Returns(true).Verifiable();
 }