public void DestroyCausesSpecifiedModelToNotBeReturnedByGet() { var matchingCount = 0; var totalCount = 0; var expectedValue = "yet another random string"; DummyModel specifiedModel = null; testObj.Create <DummyModel>(model => { model.value = expectedValue; specifiedModel = model; }); testObj.Create <DummyModel>(); testObj.Destroy <DummyModel>(specifiedModel); foreach (var model in testObj.Get <DummyModel>()) { totalCount++; if (expectedValue == model.value) { matchingCount++; } } Assert.AreEqual(0, matchingCount); Assert.AreEqual(1, totalCount); }
public void DestroyDoesNotFireAnEventWhenSpecifiedModelIsNotInModelRegistry() { var wasCalled = false; var model = new DummyModel(); eventBus.AddListener <ModelDestroyedEvent>(evt => { wasCalled = true; }); testObj.Destroy <DummyModel>(model); Assert.IsFalse(wasCalled); }
public void DestroyFiresEvent() { var eventFired = false; var expectedValue = "the most random string"; DummyModel actualModel = null; eventBus.AddListener <ModelDestroyedEvent>((evt) => { var model = (DummyModel)evt.model; Assert.AreEqual(expectedValue, model.value); Assert.AreEqual(typeof(DummyModel), evt.type); eventFired = true; }); testObj.Create <DummyModel>((model) => { model.value = expectedValue; actualModel = model; }); testObj.Destroy <DummyModel>(actualModel); Assert.IsTrue(eventFired); }
public void DestroyDoesNothingSilentlyWhenSpecifiedModelIsNotInModelRegistry() { var model = new DummyModel(); testObj.Destroy <DummyModel>(model); }