public void TableKeyDifferentTypeNoKey() { TableKeyDifferentTypeException ex = new TableKeyDifferentTypeException(NtType.Boolean, NtType.Double); Assert.That(ex.RequestedKey, Is.EqualTo(string.Empty)); Assert.That(ex.RequestedType, Is.EqualTo(NtType.Boolean)); Assert.That(ex.TypeInTable, Is.EqualTo(NtType.Double)); Assert.That(ex.Message, Is.EqualTo($"Requested Type {NtType.Boolean} does not match actual Type {NtType.Double}.")); Assert.That(ex.ThrownByValueGet, Is.True); Assert.That(ex is InvalidOperationException); }
public void TableKeyDifferentTypeKey() { const string key = "Test"; TableKeyDifferentTypeException ex = new TableKeyDifferentTypeException(key, NtType.Boolean, NtType.Double); Assert.That(ex.RequestedKey, Is.EqualTo(key)); Assert.That(ex.RequestedType, Is.EqualTo(NtType.Boolean)); Assert.That(ex.TypeInTable, Is.EqualTo(NtType.Double)); Assert.That(ex.Message, Is.EqualTo($"Key: {key}, Requested Type: {NtType.Boolean}, Type in Table: {NtType.Double}")); Assert.That(ex.ThrownByValueGet, Is.False); Assert.That(ex is InvalidOperationException); }
public void ValueAssertions() { Value v = new Value(); TableKeyDifferentTypeException ex = Assert.Throws <TableKeyDifferentTypeException>(() => { v.GetBoolean(); }); Assert.That(ex.Message, Is.EqualTo("Requested Type Boolean does not match actual Type Unassigned.")); Assert.That(ex.ThrownByValueGet, Is.True); Assert.That(ex.TypeInTable, Is.EqualTo(NtType.Unassigned)); Assert.That(ex.RequestedType, Is.EqualTo(NtType.Boolean)); ex = Assert.Throws <TableKeyDifferentTypeException>(() => { v.GetBooleanArray(); }); Assert.That(ex.Message, Is.EqualTo("Requested Type BooleanArray does not match actual Type Unassigned.")); Assert.That(ex.ThrownByValueGet, Is.True); Assert.That(ex.TypeInTable, Is.EqualTo(NtType.Unassigned)); Assert.That(ex.RequestedType, Is.EqualTo(NtType.BooleanArray)); ex = Assert.Throws <TableKeyDifferentTypeException>(() => { v.GetDouble(); }); Assert.That(ex.Message, Is.EqualTo("Requested Type Double does not match actual Type Unassigned.")); Assert.That(ex.ThrownByValueGet, Is.True); Assert.That(ex.TypeInTable, Is.EqualTo(NtType.Unassigned)); Assert.That(ex.RequestedType, Is.EqualTo(NtType.Double)); ex = Assert.Throws <TableKeyDifferentTypeException>(() => { v.GetDoubleArray(); }); Assert.That(ex.Message, Is.EqualTo("Requested Type DoubleArray does not match actual Type Unassigned.")); Assert.That(ex.ThrownByValueGet, Is.True); Assert.That(ex.TypeInTable, Is.EqualTo(NtType.Unassigned)); Assert.That(ex.RequestedType, Is.EqualTo(NtType.DoubleArray)); ex = Assert.Throws <TableKeyDifferentTypeException>(() => { v.GetRaw(); }); Assert.That(ex.Message, Is.EqualTo("Requested Type Raw does not match actual Type Unassigned.")); Assert.That(ex.ThrownByValueGet, Is.True); Assert.That(ex.TypeInTable, Is.EqualTo(NtType.Unassigned)); Assert.That(ex.RequestedType, Is.EqualTo(NtType.Raw)); ex = Assert.Throws <TableKeyDifferentTypeException>(() => { v.GetRpc(); }); Assert.That(ex.Message, Is.EqualTo("Requested Type Rpc does not match actual Type Unassigned.")); Assert.That(ex.ThrownByValueGet, Is.True); Assert.That(ex.TypeInTable, Is.EqualTo(NtType.Unassigned)); Assert.That(ex.RequestedType, Is.EqualTo(NtType.Rpc)); ex = Assert.Throws <TableKeyDifferentTypeException>(() => { v.GetString(); }); Assert.That(ex.Message, Is.EqualTo("Requested Type String does not match actual Type Unassigned.")); Assert.That(ex.ThrownByValueGet, Is.True); Assert.That(ex.TypeInTable, Is.EqualTo(NtType.Unassigned)); Assert.That(ex.RequestedType, Is.EqualTo(NtType.String)); ex = Assert.Throws <TableKeyDifferentTypeException>(() => { v.GetStringArray(); }); Assert.That(ex.Message, Is.EqualTo("Requested Type StringArray does not match actual Type Unassigned.")); Assert.That(ex.ThrownByValueGet, Is.True); Assert.That(ex.TypeInTable, Is.EqualTo(NtType.Unassigned)); Assert.That(ex.RequestedType, Is.EqualTo(NtType.StringArray)); bool genericSuccess; v.GetValue <bool>(out genericSuccess); Assert.That(genericSuccess, Is.False); v.GetValue <TimeSpan>(out genericSuccess); Assert.That(genericSuccess, Is.False); v.GetValue <List <string> >(out genericSuccess); Assert.That(genericSuccess, Is.False); v.GetValue <int[]>(out genericSuccess); Assert.That(genericSuccess, Is.False); }