public void Execute_DateTime_Itself() { var obj = new DateTime(2017, 11, 13, 7, 5, 0); var args = new LiteralScalarResolverArgs(obj); var resolver = new LiteralScalarResolver <DateTime>(args); Assert.That(resolver.Execute(), Is.EqualTo(obj)); }
public void Execute_StringToPercentage_Double() { var obj = "10%"; var args = new LiteralScalarResolverArgs(obj); var resolver = new LiteralScalarResolver <Percentage>(args); Assert.That(resolver.Execute().Value, Is.EqualTo(0.1)); }
public void Execute_StringToInt32_Itself() { string obj = "10"; var args = new LiteralScalarResolverArgs(obj); var resolver = new LiteralScalarResolver <decimal>(args); Assert.That(resolver.Execute(), Is.EqualTo(Int32.Parse(obj))); }
public void Execute_StringToDateTime_Itself() { var obj = "2017-11-13 07:05:00"; var args = new LiteralScalarResolverArgs(obj); var resolver = new LiteralScalarResolver <DateTime>(args); Assert.That(resolver.Execute(), Is.EqualTo(DateTime.Parse(obj))); }
public void Execute_DecimalToInt_Itself() { decimal obj = new decimal(10); var args = new LiteralScalarResolverArgs(obj); var resolver = new LiteralScalarResolver <int>(args); Assert.That(resolver.Execute(), Is.EqualTo(obj)); }
public void Execute_DoubleToDecimal_Itself() { double obj = 10.0; var args = new LiteralScalarResolverArgs(obj); var resolver = new LiteralScalarResolver <decimal>(args); Assert.That(resolver.Execute(), Is.EqualTo(obj)); }
public void Execute_String_Itself() { var obj = "My name is Cédric"; var args = new LiteralScalarResolverArgs(obj); var resolver = new LiteralScalarResolver <string>(args); Assert.That(resolver.Execute(), Is.EqualTo("My name is Cédric")); }
public void Instantiate_LiteralArgs_LiteralResolver() { var args = new LiteralScalarResolverArgs("myValue"); var factory = new ScalarResolverFactory(null); var resolver = factory.Instantiate <object>(args); Assert.That(resolver, Is.TypeOf <LiteralScalarResolver <object> >()); }
public void Compare_ResolverToInt_CorrectResult(int x, int y) { var args = new LiteralScalarResolverArgs(x); var resolver = new LiteralScalarResolver <int>(args); var comparer = new ScalarComparer <int>(); Assert.That(comparer.Compare(resolver, y), Is.EqualTo(x.CompareTo(y))); }
public void Execute_StringToDecimal_Itself(string culture) { var currentCulture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = new CultureInfo(culture); string obj = "10.0"; var args = new LiteralScalarResolverArgs(obj); var resolver = new LiteralScalarResolver <decimal>(args); Assert.That(resolver.Execute(), Is.EqualTo(decimal.Parse(obj, NumberFormatInfo.InvariantInfo))); Thread.CurrentThread.CurrentCulture = currentCulture; }
public void Compare_ResolverToResolver_CorrectResult(int x, int y) { var xArgs = new LiteralScalarResolverArgs(x); var xResolver = new LiteralScalarResolver <int>(xArgs); var yArgs = new LiteralScalarResolverArgs(y); var yResolver = new LiteralScalarResolver <int>(yArgs); var comparer = new ScalarComparer <int>(); Assert.That(comparer.Compare(xResolver, yResolver), Is.EqualTo(x.CompareTo(y))); }