public void TestNegate()
{
Assert.AreEqual(
CBORObject.FromObject(2),
CBORObject.FromObject(-2).Negate());
Assert.AreEqual(
CBORObject.FromObject(-2),
CBORObject.FromObject(2).Negate());
try {
CBORObject.True.Negate();
Assert.Fail("Should have failed");
} catch (InvalidOperationException) {
new Object();
} catch (Exception ex) {
Assert.Fail(ex.ToString());
throw new InvalidOperationException(String.Empty, ex);
}
try {
CBORObject.False.Negate();
Assert.Fail("Should have failed");
} catch (InvalidOperationException) {
new Object();
} catch (Exception ex) {
Assert.Fail(ex.ToString());
throw new InvalidOperationException(String.Empty, ex);
}
try {
CBORObject.NewArray().Negate();
Assert.Fail("Should have failed");
} catch (InvalidOperationException) {
new Object();
} catch (Exception ex) {
Assert.Fail(ex.ToString());
throw new InvalidOperationException(String.Empty, ex);
}
try {
CBORObject.NewMap().Negate();
Assert.Fail("Should have failed");
} catch (InvalidOperationException) {
new Object();
} catch (Exception ex) {
Assert.Fail(ex.ToString());
throw new InvalidOperationException(String.Empty, ex);
}
}