示例#1
0
        public void TestCreation()
        {
            // Define variables and constants
            ConstantBuffer <SixteenByteStruct> defaultBuffer   = BufferFactory.NewConstantBuffer <SixteenByteStruct>();
            ConstantBuffer <SixteenByteStruct> freqWriteBuffer = defaultBuffer.Clone().WithUsage(ResourceUsage.DiscardWrite);
            ConstantBuffer <SixteenByteStruct> initDataBuffer  = defaultBuffer.Clone().WithInitialData(new SixteenByteStruct(1f, 2f, 3f, 4f));

            // Set up context

            // Execute

            // Assert outcome
            Assert.AreEqual(ResourceUsage.Immutable, defaultBuffer.Usage);
            Assert.AreEqual(ResourceUsage.DiscardWrite, freqWriteBuffer.Usage);
            Assert.AreEqual(defaultBuffer.Usage, initDataBuffer.Usage);
            Assert.AreEqual(16L, initDataBuffer.Size.InBytes);

            try {
                freqWriteBuffer.Clone().WithUsage(ResourceUsage.StagingRead);
                Assert.Fail();
            }
            catch (ArgumentException) { }

            defaultBuffer.Dispose();
            freqWriteBuffer.Dispose();
            initDataBuffer.Dispose();
        }
示例#2
0
        public void TestCopyTo()
        {
            // Define variables and constants
            ConstantBuffer <decimal> srcBuffer = BufferFactory.NewConstantBuffer <decimal>()
                                                 .WithUsage(ResourceUsage.Immutable)
                                                 .WithInitialData(13515m);
            ConstantBuffer <decimal> dstBuffer = srcBuffer.Clone()
                                                 .WithUsage(ResourceUsage.DiscardWrite);

            // Set up context


            // Execute
            srcBuffer.CopyTo(dstBuffer);
            srcBuffer.CopyTo(dstBuffer);

            try {
                dstBuffer.CopyTo(srcBuffer);
                Assert.Fail();
            }
            catch (ResourceOperationUnavailableException) { }

            // Assert outcome
            Assert.IsFalse(srcBuffer.CanBeCopyDestination);
            Assert.IsTrue(dstBuffer.CanBeCopyDestination);

            srcBuffer.Dispose();
            dstBuffer.Dispose();
        }
示例#3
0
        public void TestClone()
        {
            // Define variables and constants
            const ResourceUsage      USAGE       = ResourceUsage.DiscardWrite;
            ConstantBuffer <decimal> firstBuffer = BufferFactory.NewConstantBuffer <decimal>().WithUsage(USAGE);

            // Set up context


            // Execute
            ConstantBuffer <decimal> secondBuffer = firstBuffer.Clone();
            ConstantBuffer <decimal> thirdBuffer  = secondBuffer.Clone().WithInitialData(10516m);

            // Assert outcome
            Assert.AreEqual(USAGE, secondBuffer.Usage);
            Assert.AreEqual(firstBuffer.Usage, secondBuffer.Usage);
            Assert.AreEqual(firstBuffer.Size, secondBuffer.Size);

            Assert.AreEqual(USAGE, thirdBuffer.Usage);

            firstBuffer.Dispose();
            secondBuffer.Dispose();
            thirdBuffer.Dispose();
        }