示例#1
0
        public void TestVoidDispose(Type resourceType)
        {
            if (resourceType == null)
            {
                throw new ArgumentNullException("resourceType");
            }

            IGraphicsTypeSupport graphicsTypeSupport = GetGraphicsTypeSupport(resourceType);

            if (graphicsTypeSupport == null)
            {
                Assert.Inconclusive(String.Format("no type support for {0}", resourceType.Name));
            }

            using (IGraphicsDisposable resource = graphicsTypeSupport.AllocateSpy <IGraphicsDisposable>(_Context)) {
                if (resource == null)
                {
                    Assert.Inconclusive(String.Format("unable to allocate an instance of {0}", resourceType.Name));
                }

                // Do NOT create the resource

                // Call Dispose() method
                resource.Dispose();
                // Dispose method shall not call the Dispose(GraphicsCo ntext) method since no object
                // need to be released
                resource.DidNotReceive().Dispose(_Context);
            }
        }
示例#2
0
        public void TestCurrentDispose(Type resourceType)
        {
            if (resourceType == null)
            {
                throw new ArgumentNullException("resourceType");
            }

            IGraphicsTypeSupport graphicsTypeSupport = GetGraphicsTypeSupport(resourceType);

            if (graphicsTypeSupport == null)
            {
                Assert.Inconclusive(String.Format("no type support for {0}", resourceType.Name));
            }

            // Assert currency of context
            Assert.IsTrue(_Context.IsCurrent);

            using (IGraphicsDisposable resource = graphicsTypeSupport.AllocateSpy <IGraphicsDisposable>(_Context)) {
                if (resource == null)
                {
                    Assert.Inconclusive(String.Format("unable to allocate an instance of {0}", resourceType.Name));
                }

                // Create the resource
                Assert.DoesNotThrow(delegate() { graphicsTypeSupport.Create(resource, _Context); });
                // Call Dispose() method
                Assert.DoesNotThrow(delegate() { resource.Dispose(); });
                // Dispose() method shall not call the Dispose(GraphicsContext) method since they are equivalent
                resource.DidNotReceive().Dispose(_Context);
            }
        }