public void TryConvert_NullConverter_ThrowsArgumentNullException() { var policy = new ScalarConversionPolicy(); IPropertyToken token; Assert.Throws <ArgumentNullException>(() => policy.TryConvert(null, null, out token)); }
public void TryConvert_NullValue_ReturnsFalse() { var converter = Mock.Of <IPropertyConverter>(); var policy = new ScalarConversionPolicy(); IPropertyToken token; Assert.False(policy.TryConvert(converter, null, out token)); }
public void TryConvert_BoolValue_ReturnsScalarToken() { var converter = Mock.Of <IPropertyConverter>(); var policy = new ScalarConversionPolicy(); IPropertyToken token; Assert.True(policy.TryConvert(converter, true, out token)); var scalar = token as ScalarToken; Assert.NotNull(scalar); Assert.Equal(scalar.Value, true); }
public void TryConvert_DecimalValue_ReturnsScalarToken() { decimal payload = 10.0M; var converter = Mock.Of <IPropertyConverter>(); var policy = new ScalarConversionPolicy(); IPropertyToken token; Assert.True(policy.TryConvert(converter, payload, out token)); var scalar = token as ScalarToken; Assert.NotNull(scalar); Assert.Equal(scalar.Value, payload); }
public void TryConvert_UriValue_ReturnsScalarToken() { var payload = new Uri("http://localhost/"); var converter = Mock.Of <IPropertyConverter>(); var policy = new ScalarConversionPolicy(); IPropertyToken token; Assert.True(policy.TryConvert(converter, payload, out token)); var scalar = token as ScalarToken; Assert.NotNull(scalar); Assert.Equal(scalar.Value, payload); }
public void TryConvert_TimeSpanValue_ReturnsScalarToken() { var payload = TimeSpan.FromHours(1); var converter = Mock.Of <IPropertyConverter>(); var policy = new ScalarConversionPolicy(); IPropertyToken token; Assert.True(policy.TryConvert(converter, payload, out token)); var scalar = token as ScalarToken; Assert.NotNull(scalar); Assert.Equal(scalar.Value, payload); }
public void TryConvert_StringValue_ReturnsScalarToken() { string payload = "Hello World!"; var converter = Mock.Of <IPropertyConverter>(); var policy = new ScalarConversionPolicy(); IPropertyToken token; Assert.True(policy.TryConvert(converter, payload, out token)); var scalar = token as ScalarToken; Assert.NotNull(scalar); Assert.Equal(scalar.Value, payload); }