Пример #1
0
        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);
        }
Пример #2
0
        public void DestroyDoesNotFireAnEventWhenSpecifiedModelIsNotInModelRegistry()
        {
            var wasCalled = false;
            var model     = new DummyModel();

            eventBus.AddListener <ModelDestroyedEvent>(evt => {
                wasCalled = true;
            });

            testObj.Destroy <DummyModel>(model);

            Assert.IsFalse(wasCalled);
        }
Пример #3
0
        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);
        }
Пример #4
0
        public void DestroyDoesNothingSilentlyWhenSpecifiedModelIsNotInModelRegistry()
        {
            var model = new DummyModel();

            testObj.Destroy <DummyModel>(model);
        }