public void destroy_runs_backwards() { List <object> actual = new List <object>(); List <object> expected = new List <object> () { "before3", "before2", "before1", "when3", "when2", "when1", "after3", "after2", "after1" }; lifecycle.BeforeDestroying(CreateValuePusher(actual, "before1")); lifecycle.BeforeDestroying(CreateValuePusher(actual, "before2")); lifecycle.BeforeDestroying(CreateValuePusher(actual, "before3")); lifecycle.WhenDestroying(CreateValuePusher(actual, "when1")); lifecycle.WhenDestroying(CreateValuePusher(actual, "when2")); lifecycle.WhenDestroying(CreateValuePusher(actual, "when3")); lifecycle.AfterDestroying(CreateValuePusher(actual, "after1")); lifecycle.AfterDestroying(CreateValuePusher(actual, "after2")); lifecycle.AfterDestroying(CreateValuePusher(actual, "after3")); lifecycle.Initialize(); lifecycle.Destroy(); Assert.That(actual, Is.EqualTo(expected).AsCollection); }
public IContext WhenDestroying(Action callback) { _lifecycle.WhenDestroying(callback); return(this); }