public void HoldInstanceWithNull() { // Setup var lifespan = new CacheLifespan(); // Execute lifespan.Hold(a_instance: null); }
public void HoldInstance() { // Setup var lifespan = new CacheLifespan(); var instance = new object(); // Execute lifespan.Hold(instance); // Assert Assert.AreSame(instance, lifespan.Instance); }
public void KillInstanceWithNoInstanceHeld() { // Setup var lifespan = new CacheLifespan(); var instance = new object(); lifespan.Hold(instance); // Execute lifespan.Kill(); // Assert Assert.IsNull(lifespan.Instance); }
public async Task WaitPastTimeout() { // Setup var lifespan = new CacheLifespan(TimeSpan.FromMilliseconds(500)); var instance = new object(); lifespan.Hold(instance); // Execute await Task.Delay(1000); // Assert Assert.IsNull(lifespan.Instance); }