So my first TestMethod went through, as expected. I tested my SetValue method.
p1 = new DateTimePeriod { From = DateTime.MinValue, To = DateTime.MaxValue };
p2 = new DateTimePeriod { From = DateTime.MaxValue, To = DateTime.MinValue };
[TestMethod]
public void SetPeriodTest()
{
b.SetValue(ref p1, p2);
Assert.AreEqual(DateTime.MaxValue, p1.From);
Assert.AreEqual(DateTime.MinValue, p2.To);
}
But the next test fails. Apparently x.AName, x.Valid and x.Id are null although I clearly set them the same way I set p1.From and p1.To. Why are these properties returning null?
[TestMethod]
public void SetNameTest()
{
var x = new Name { AName = "Jack", Valid = p1, Id = "123" };
var y = new Name { AName = "John", Valid = p2, Id = "321" };
b.SetValue(ref x, y);
Assert.AreEqual("John", x.AName);
Assert.AreEqual(p2, x.Valid);
Assert.AreEqual("321", x.Id);
}
Aucun commentaire:
Enregistrer un commentaire