public void UpdateFromString_InvalidUpdateString_ThrowException() { Battery b = new Battery(200) { ChargePerc = 20.0f, Current = 23.5f, Temperature = 54.7f }; string updateString; updateString = "<V;57.564,254500.122,70.523>"; Assert.Throws<InvalidUpdateStringException>(() => b.UpdateFromString(updateString)); updateString = "<B;57.5624,254500.122,70.523>"; Assert.Throws<InvalidUpdateStringException>(() => b.UpdateFromString(updateString)); updateString = "<B;57.564,254500.122,70.523156>"; Assert.Throws<InvalidUpdateStringException>(() => b.UpdateFromString(updateString)); updateString = "B;57.564,254500.122,70.5"; Assert.Throws<InvalidUpdateStringException>(() => b.UpdateFromString(updateString)); updateString = "<B;57.564,70.523156>"; Assert.Throws<InvalidUpdateStringException>(() => b.UpdateFromString(updateString)); }
public void UpdateFromString_InvalidUpdateString_ObjectUpdated() { Battery b = new Battery(200) { ChargePerc = 20.0f, Current = 23.5f, Temperature = 54.7f }; string updateString; updateString = "<B;57.564,254500.122,70.523>"; b.UpdateFromString(updateString); Assert.AreEqual(57.564f, b.ChargePerc); Assert.AreEqual(564, 254500.122f, b.Current); Assert.AreEqual(70.523f, b.Temperature); }