Assertions
The Assert class logs an Assert-level message and optionally throws on failure. All methods return LogMessage? (null = passed).
Assert.That(health > 0, "Health should be positive");
Assert.NotNull(() => GetComponent<Rigidbody>());
Assert.NotNullOrEmpty(() => playerName);
Assert.NotEmpty(() => inventoryItems);
Assert.GreaterThan(() => score, 100);
Assert.LessThan(() => score, 200);
Assert.InRange(() => score, 0, 1000);
Assert.AreEqual(() => playerName, "Hero");
Assert.NotEqual(() => playerName, "Enemy");
Assert.IsNull(() => _enemy);
Assert.IsInstanceOf<Player>(() => someObject);
Assert.NotDefault(() => someInt);
Use generics to throw a specific exception:
Assert.That<InvalidOperationException>(gameState == State.Running);
Assert.NotNull<MissingReferenceException>(() => _weapon);
By default assertions don't throw. Pass throwException: true to throw.