public void CallingReturnWithNullThrows() { Assert.Throws <ArgumentNullException>("doorman", () => { DoormanPool.Return(null); }); }
public void RentingGivesDifferentInstances() { Doorman first = DoormanPool.Rent(); Doorman second = DoormanPool.Rent(); Assert.NotSame(first, second); DoormanPool.Return(first); DoormanPool.Return(second); }
public void DoormanPoolReusesItems() { Doorman first = DoormanPool.Rent(); DoormanPool.Return(first); Doorman second = DoormanPool.Rent(); Assert.Equal(first, second); DoormanPool.Return(second); }
public void DoormanPoolReusesItems() { int initialCount = DoormanPool.Count(); Doorman first = DoormanPool.Rent(); int currentCount = DoormanPool.Count(); if (currentCount > 0) { Assert.Equal(initialCount - 1, currentCount); DoormanPool.Return(first); Assert.Equal(initialCount, DoormanPool.Count()); } else { Assert.Equal(0, currentCount); DoormanPool.Return(first); Assert.Equal(initialCount + 1, DoormanPool.Count()); } }