Ejemplo n.º 1
0
        public void CacheCanCloseItemsEarly()
        {
            var resourceStore = new ResourceStore <string, Disposable>(name => new Disposable(name));

            Disposable item1 = null;
            Disposable item2 = null;

            resourceStore.Access("foo", it => item1 = it);
            resourceStore.Access("bar", it => item2 = it);

            Assert.AreEqual(0, item1.DisposeCallCount);
            Assert.AreEqual(0, item2.DisposeCallCount);

            resourceStore.Close("foo");

            Assert.AreEqual(1, item1.DisposeCallCount);
            Assert.AreEqual(0, item2.DisposeCallCount);

            Assert.Throws <ObjectDisposedException>(() => resourceStore.Access("foo", it => { }));

            resourceStore.Dispose();

            Assert.AreEqual(1, item1.DisposeCallCount);
            Assert.AreEqual(1, item2.DisposeCallCount);
        }
Ejemplo n.º 2
0
        public void CacheCallsFailWhenDisposed()
        {
            var resourceStore = new ResourceStore<string, Disposable>(name => new Disposable(name));
            resourceStore.Dispose();

            Assert.Throws<ObjectDisposedException>(() => resourceStore.Access("foo", it => { }));
            Assert.Throws<ObjectDisposedException>(() => resourceStore.Close("foo"));
        }
Ejemplo n.º 3
0
        public void CacheCallsFailWhenDisposed()
        {
            var resourceStore = new ResourceStore <string, Disposable>(name => new Disposable(name));

            resourceStore.Dispose();

            Assert.Throws <ObjectDisposedException>(() => resourceStore.Access("foo", it => { }));
            Assert.Throws <ObjectDisposedException>(() => resourceStore.Close("foo"));
        }
Ejemplo n.º 4
0
        public void CacheDisposesAllItemsExactlyOnce()
        {
            var resourceStore = new ResourceStore <string, Disposable>(name => new Disposable(name));

            Disposable item1 = null;
            Disposable item2 = null;

            resourceStore.Access("foo", it => item1 = it);
            resourceStore.Access("bar", it => item2 = it);

            Assert.AreEqual(0, item1.DisposeCallCount);
            Assert.AreEqual(0, item2.DisposeCallCount);

            resourceStore.Dispose();

            Assert.AreEqual(1, item1.DisposeCallCount);
            Assert.AreEqual(1, item2.DisposeCallCount);

            resourceStore.Dispose();

            Assert.AreEqual(1, item1.DisposeCallCount);
            Assert.AreEqual(1, item2.DisposeCallCount);
        }
Ejemplo n.º 5
0
        public void CacheCanCloseItemsEarly()
        {
            var resourceStore = new ResourceStore<string, Disposable>(name => new Disposable(name));

            Disposable item1 = null;
            Disposable item2 = null;
            resourceStore.Access("foo", it => item1 = it);
            resourceStore.Access("bar", it => item2 = it);

            Assert.AreEqual(0, item1.DisposeCallCount);
            Assert.AreEqual(0, item2.DisposeCallCount);

            resourceStore.Close("foo");

            Assert.AreEqual(1, item1.DisposeCallCount);
            Assert.AreEqual(0, item2.DisposeCallCount);

            Assert.Throws<ObjectDisposedException>(() => resourceStore.Access("foo", it => { }));

            resourceStore.Dispose();

            Assert.AreEqual(1, item1.DisposeCallCount);
            Assert.AreEqual(1, item2.DisposeCallCount);
        }
Ejemplo n.º 6
0
        public void CacheDisposesAllItemsExactlyOnce()
        {
            var resourceStore = new ResourceStore<string, Disposable>(name => new Disposable(name));

            Disposable item1 = null;
            Disposable item2 = null;
            resourceStore.Access("foo", it => item1 = it);
            resourceStore.Access("bar", it => item2 = it);

            Assert.AreEqual(0, item1.DisposeCallCount);
            Assert.AreEqual(0, item2.DisposeCallCount);

            resourceStore.Dispose();

            Assert.AreEqual(1, item1.DisposeCallCount);
            Assert.AreEqual(1, item2.DisposeCallCount);

            resourceStore.Dispose();

            Assert.AreEqual(1, item1.DisposeCallCount);
            Assert.AreEqual(1, item2.DisposeCallCount);
        }
        public override void Unload()
        {
            client?.Dispose();
            client   = null;
            Instance = null;
            _exampleUserInterface?.SetState(null);    // Choose Starter
            _exampleUserInterfaceNew?.SetState(null); // Pokegear Main Menu
            PokegearUserInterfaceNew?.SetState(null); // Pokegear Events Menu
            evolveUserInterfaceNew?.SetState(null);
            summaryUIInterface?.SetState(null);
            _uiSidebar?.SetState(null);
            _partySlots?.SetState(null);
            _moves?.SetState(null);
            _battle?.SetState(null);
            BattleMode.UI            = null;
            PartySlots               = null;
            pokemonStore             = null;
            wildPokemonStore         = null;
            movesStore               = null;
            _exampleUserInterface    = null;
            _exampleUserInterfaceNew = null;
            PokegearUserInterfaceNew = null;
            _uiSidebar               = null;
            _partySlots              = null;
            _moves          = null;
            _battle         = null;
            BaseMove._mrand = null;


            ChooseStarter.Deactivate();
            ChooseStarter = null;
            ChooseStarterBulbasaur.Deactivate();
            ChooseStarterBulbasaur = null;
            ChooseStarterCharmander.Deactivate();
            ChooseStarterCharmander = null;
            ChooseStarterSquirtle.Deactivate();
            ChooseStarterSquirtle = null;
            PokegearUI.Deactivate();
            PokegearUI = null;
            PokegearUIEvents.Deactivate();
            PokegearUIEvents = null;
            evolveUI.Deactivate();
            evolveUI = null;
            UISidebar.Deactivate();
            UISidebar = null;
            Moves.Deactivate();
            Moves = null;

            summaryUI.Deactivate();
            summaryUI = null;

            PartyCycle       = null;
            FirstPKMAbility  = null;
            SecondPKMAbility = null;
            ThirdPKMAbility  = null;
            FourthPKMAbility = null;
            CompressSidebar  = null;

            Localisation = null;
            Textures     = null;
            storage      = null;
            Store.Dispose();
            Store = null;
            Scheduler?.CancelDelayedTasks();
            Scheduler      = null;
            schedulerClock = null;
            ParentPokemonNPC.HighlightTexture = null;
            ParentPokemon.HighlightTexture    = null;
        }