Beispiel #1
0
		protected internal static void CheckThatExistence(GraphicsContext ctx, IGraphicsResource resource)
		{
			if (resource == null)
				throw new ArgumentNullException("resource");
			if (resource.Exists(ctx) == false)
				throw new InvalidOperationException("not existing");
		}
Beispiel #2
0
        public void TestDeleteOnDispose(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 (IGraphicsResource resource = graphicsTypeSupport.AllocateSpy <IGraphicsResource>(_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); });

                Assert.AreNotEqual(0, resource.ObjectName);
                Assert.AreEqual(_Context.ObjectNameSpace, resource.ObjectNamespace);
                Assert.IsTrue(resource.Exists(_Context));

                // Delete the resource
                resource.Dispose();
                // Dispose(GraphicsContext) method shall call the Delete(GraphicsContext) method
                resource.Received().Delete(_Context);

                Assert.AreEqual(0, resource.ObjectName);
                Assert.AreEqual(Guid.Empty, resource.ObjectNamespace);
                Assert.DoesNotThrow(delegate() { resource.Exists(_Context); });
                Assert.IsFalse(resource.Exists(_Context));
            }
        }