public void Should_map_nullable_to_non_nullable() { var from = new WithNullable { Value = 10 }; var to = Mapper.Map <WithNullable>(from); Assert.Equal(from.Value, to.Value); }
public void Should_map_nullable_null_to_nullable_null() { var from = new WithNullable { Value = null }; var to = Mapper.Map <WithNullable>(from); Assert.Null(to.Value); }
public void WithNullableWithValues() { var instance = new WithNullable { Value1 = 1, Value2 = 2 }; var roundtrip = instance.Roundtrip(); Assert.AreEqual(instance.Value1, roundtrip.Value1); Assert.AreEqual(instance.Value2, roundtrip.Value2); }
public void EnumerableWithNullableToDataTable() { var items = new WithNullable[] { new WithNullable() { Message = "hello", Date = DateTime.Today, Flag = true }, new WithNullable() { Message = "good-bye", Date = null, Flag = false } }; var table = items.ToDataTable(); }
public void ExploratoryTesting_OnPerformance() { var watch = new Stopwatch(); ActionTimer.Time(watch, () => { var c = new WithoutEnsure().NonZero; }, 1000000); long withoutEnsure = watch.ElapsedTicks; Debug.WriteLine("withoutEnsure: " + withoutEnsure); watch.Reset(); ActionTimer.Time(watch, () => { var c = new WithEnsure().NonZero; }, 1000000); long withEnsure = watch.ElapsedTicks; Debug.WriteLine("withEnsure: " + withEnsure); watch.Reset(); ActionTimer.Time(watch, () => { var c = new WithNullable().NonZero; }, 1000000); long withNullable = watch.ElapsedTicks; Debug.WriteLine("withNullable: " + withNullable); Assert.That(withoutEnsure, Is.LessThan(withEnsure).And.LessThan(withNullable), "doing nothing is the fastest, but it does allow a undefined value in the enumeration."); Assert.That(withEnsure, Is.GreaterThan(withNullable), "having a custom method to ensure the defined value is more expensive than using a nullable private field"); }