How would I write a unit test to ensure that a lock was acquired?
For example:
public void AddItem(object item)
{
lock (_list)
{
_list.Add(item)
}
}
Is there a way to ensure that the lock statement is run?
Edit: I'm not trying to prove thread-safety (this I would assume), just that the lock() statement is called.
For example, I might test a new object() statement by substituting it in a CreateObject() factory function.