public void Returns_a_negative_decimal_value_when_passed_one() { var retriever = new DecimalValueRetriever(); retriever.GetValue("-1").ShouldEqual(-1M); retriever.GetValue("-32.234").ShouldEqual(-32.234M); }
public void Retrieve_correct_nullable_value(string value, double?expectation) { var retriever = new DecimalValueRetriever(); var result = (decimal?)retriever.Retrieve(new KeyValuePair <string, string>(IrrelevantKey, value), IrrelevantType, typeof(decimal?)); result.Should().Be((decimal?)expectation); }
public void CanRetrieve(Type type, bool expectation) { var retriever = new DecimalValueRetriever(); var result = retriever.CanRetrieve(new KeyValuePair <string, string>(IrrelevantKey, IrrelevantKey), IrrelevantType, type); result.Should().Be(expectation); }
public void Returns_zero_when_passed_a_non_numeric_value() { var retriever = new DecimalValueRetriever(); retriever.GetValue(null).ShouldEqual(0M); retriever.GetValue("").ShouldEqual(0M); retriever.GetValue("xxxslkdfj").ShouldEqual(0M); }
public void Retrieve_a_decimal_when_passed_a_decimal_value_if_culture_is_fr_Fr() { Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR", false); var retriever = new DecimalValueRetriever(); var result = (decimal?)retriever.Retrieve(new KeyValuePair <string, string>(IrrelevantKey, "384,234879"), IrrelevantType, typeof(decimal?)); result.Should().Be(384.234879m); }
public void Returns_the_decimal_value_when_passed_a_decimal_string() { var retriever = new DecimalValueRetriever(); retriever.GetValue("0").ShouldEqual(0M); retriever.GetValue("1").ShouldEqual(1M); retriever.GetValue("2").ShouldEqual(2M); retriever.GetValue("2.23").ShouldEqual(2.23M); retriever.GetValue("384.234879").ShouldEqual(384.234879M); }
public void Returns_the_decimal_value_when_passed_a_decimal_string_if_culture_if_fr_FR() { Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR"); var retriever = new DecimalValueRetriever(); retriever.GetValue("0").Should().Be(0M); retriever.GetValue("1").Should().Be(1M); retriever.GetValue("2").Should().Be(2M); retriever.GetValue("2,23").Should().Be(2.23M); retriever.GetValue("384,234879").Should().Be(384.234879M); }