public void TryReadByteTest2() { var hash = new Hashtable(); byte? res; object rawValue; hash.Add((byte)GameParameter.MaxPlayers, (byte)123); Assert.That(GameParameterReader.TryReadByteParameter(hash, GameParameter.MaxPlayers, out res, out rawValue), Is.True); Assert.That(res, Is.Not.Null.And.EqualTo(123)); Assert.That(rawValue, Is.Not.Null.And.EqualTo(123)); hash.Clear(); hash.Add((byte)GameParameter.MaxPlayers, 1234); Assert.That(GameParameterReader.TryReadByteParameter(hash, GameParameter.MaxPlayers, out res, out rawValue), Is.True); unchecked { Assert.That(res, Is.Not.Null.And.EqualTo((byte)1234)); Assert.That(rawValue, Is.Not.Null.And.EqualTo(1234)); } hash.Clear(); double doubleValue = 1234.5; hash.Add((byte)GameParameter.MaxPlayers, doubleValue); Assert.That(GameParameterReader.TryReadByteParameter(hash, GameParameter.MaxPlayers, out res, out rawValue), Is.True); unchecked { Assert.That(res, Is.Not.Null.And.EqualTo((byte)doubleValue)); Assert.That(rawValue, Is.Not.Null.And.EqualTo(doubleValue)); } hash.Clear(); hash.Add((byte)GameParameter.MaxPlayers, "zzz"); Assert.That(GameParameterReader.TryReadByteParameter(hash, GameParameter.MaxPlayers, out res, out rawValue), Is.False); }
public void TryReadByteTest() { var hash = new Hashtable(); byte? res; object rawValue; Assert.That(GameParameterReader.TryReadByteParameter(hash, GameParameter.MaxPlayers, out res, out rawValue), Is.True); Assert.That(res, Is.Null); Assert.That(rawValue, Is.Null); hash.Add((byte)GameParameter.MaxPlayers, 123); Assert.That(GameParameterReader.TryReadByteParameter(hash, GameParameter.MaxPlayers, out res, out rawValue), Is.True); Assert.That(res, Is.Not.Null.And.EqualTo(123)); Assert.That(rawValue, Is.Not.Null.And.EqualTo(123)); hash.Clear(); hash.Add((int)GameParameter.MaxPlayers, 123); Assert.That(GameParameterReader.TryReadByteParameter(hash, GameParameter.MaxPlayers, out res, out rawValue), Is.True); Assert.That(res, Is.Not.Null.And.EqualTo(123)); Assert.That(rawValue, Is.Not.Null.And.EqualTo(123)); }