コード例 #1
0
        public void AcceptArgumentValueInvokesValidator()
        {
            _mockValidator.Setup(m => m.Validate("test")).Returns(true).Verifiable();

            var parser = new MyParser(null, ParserType.Command, ConverterFactory.CreateOrThrow <string>(),
                                      _mockValidator.Object, _mockMapper.Object);

            parser.ProcessContext(new object(), new ParseContext(Enumerable.Empty <string>()));

            _mockValidator.Verify(m => m.Validate("test"), Times.Once);
        }
コード例 #2
0
 public void CreateOrThrowForNullableParseTypeDoesNotThrow()
 {
     ConverterFactory.CreateOrThrow <byte?>().ShouldNotBeNull();
     ConverterFactory.CreateOrThrow <short?>().ShouldNotBeNull();
     ConverterFactory.CreateOrThrow <int?>().ShouldNotBeNull();
     ConverterFactory.CreateOrThrow <long?>().ShouldNotBeNull();
     ConverterFactory.CreateOrThrow <float?>().ShouldNotBeNull();
     ConverterFactory.CreateOrThrow <double?>().ShouldNotBeNull();
     ConverterFactory.CreateOrThrow <decimal?>().ShouldNotBeNull();
     ConverterFactory.CreateOrThrow <DateTime?>().ShouldNotBeNull();
     ConverterFactory.CreateOrThrow <TimeSpan?>().ShouldNotBeNull();
 }
コード例 #3
0
 public void CreateOrThrowForParseTypeDoesNotThrow()
 {
     ConverterFactory.CreateOrThrow <byte>().ShouldNotBeNull();
     ConverterFactory.CreateOrThrow <short>().ShouldNotBeNull();
     ConverterFactory.CreateOrThrow <int>().ShouldNotBeNull();
     ConverterFactory.CreateOrThrow <long>().ShouldNotBeNull();
     ConverterFactory.CreateOrThrow <float>().ShouldNotBeNull();
     ConverterFactory.CreateOrThrow <double>().ShouldNotBeNull();
     ConverterFactory.CreateOrThrow <decimal>().ShouldNotBeNull();
     ConverterFactory.CreateOrThrow <DateTime>().ShouldNotBeNull();
     ConverterFactory.CreateOrThrow <TimeSpan>().ShouldNotBeNull();
 }
コード例 #4
0
        public void AcceptArgumentValueInvokesMapper()
        {
            var options = new object();

            var parser = new MyParser(null, ParserType.Command, ConverterFactory.CreateOrThrow <string>(),
                                      null,
                                      _mockMapper.Object);

            _mockMapper.Setup(m => m.MapValue(options, "test")).Verifiable();
            parser.ProcessContext(options, new ParseContext(Enumerable.Empty <string>()));

            _mockMapper.Verify(m => m.MapValue(options, "test"), Times.Once);
        }
コード例 #5
0
 public void CreateOrThrowForStringDoesNotThrow()
 {
     ConverterFactory.CreateOrThrow <string>().ShouldNotBeNull();
 }
コード例 #6
0
 public void CreateOrThrowForConvertibleTypeDoesNotThrow()
 {
     ConverterFactory.CreateOrThrow <ConstructableByString>().ShouldNotBeNull();
 }
コード例 #7
0
 public void CreateOrThrowForNullableEnumTypeDoesNotThrow()
 {
     ConverterFactory.CreateOrThrow <DayOfWeek?>().ShouldNotBeNull();
 }
コード例 #8
0
 public void CreateOrThrowForUnsupportedTypeThrows()
 {
     Should.Throw <ConfigurationException>(() => ConverterFactory.CreateOrThrow <CastConverter <int> >());
 }