public T ConvertableTo <T>() { if (should.Negate) { try { TypeDescriptor.GetConverter(typeof(T)); assertProvider.Fail("Could convert '{0}' to {1}. Expected not covertable.", should.Target, typeof(T)); } catch { } } else { try { var converter = TypeDescriptor.GetConverter(typeof(T)); return((T)converter.ConvertFrom(should.Target)); } catch (Exception ex) { assertProvider.Fail("Could not convert '{0}' to {1}. {3}", should.Target, typeof(T), ex.ToString()); } } return(default(T)); }
public bool?True() { if (!should.Target.HasValue) { assertProvider.Fail("Expected TRUE but was NULL."); } else { if (should.Negate) { assertProvider.IsFalse(should.Target.Value); } else { assertProvider.IsTrue(should.Target.Value); } } return(should.Target); }
public DateTime?Today() { if (!should.Target.HasValue) { assertProvider.Fail("Expected TODAY but was NULL."); } else { if (should.Negate) { assertProvider.AreNotEqual(DateTime.Today, should.Target.Value.Date); } else { assertProvider.AreEqual(DateTime.Today, should.Target.Value.Date); } } return(should.Target); }