Example #1
0
        public void TestDisposalDoesNotDisposeParentStores()
        {
            DrawableWithDependencies drawable     = null;
            TestTextureStore         textureStore = null;
            TestSampleStore          sampleStore  = null;

            AddStep("add dependencies", () =>
            {
                Child        = drawable = new DrawableWithDependencies();
                textureStore = drawable.ParentTextureStore;
                sampleStore  = drawable.ParentSampleStore;
            });

            AddStep("clear children", Clear);
            AddUntilStep("wait for disposal", () => drawable.IsDisposed);

            AddStep("GC", () =>
            {
                drawable = null;

                GC.Collect();
                GC.WaitForPendingFinalizers();
            });

            AddAssert("parent texture store not disposed", () => !textureStore.IsDisposed);
            AddAssert("parent sample store not disposed", () => !sampleStore.IsDisposed);
        }
Example #2
0
            protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
            {
                var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));

                dependencies.CacheAs <TextureStore>(ParentTextureStore = new TestTextureStore());
                dependencies.CacheAs <ISampleStore>(ParentSampleStore  = new TestSampleStore());

                return(new DrawableRulesetDependencies(new OsuRuleset(), dependencies));
            }