xamarin-macios/tests/monotouch-test/Metal/MTLArgumentEncoderTest.cs

71 строка
1.7 KiB
C#

#if !__WATCHOS__
using System;
using Foundation;
using Metal;
using NUnit.Framework;
namespace MonoTouchFixtures.Metal {
[TestFixture]
[Preserve (AllMembers = true)]
public class MTLArgumentEncoderTest {
IMTLDevice device;
IMTLLibrary library;
IMTLFunction function;
IMTLArgumentEncoder encoder;
[SetUp]
public void SetUp ()
{
device = MTLDevice.SystemDefault;
// some older hardware won't have a default
if (device == null)
Assert.Inconclusive ("Metal is not supported");
library = device.CreateDefaultLibrary ();
if (library == null) // this happens on a simulator
Assert.Inconclusive ("Could not get the functions library for the device.");
if (library.FunctionNames.Length == 0)
Assert.Inconclusive ("Could not get functions for the pipeline.");
function = library.CreateFunction (library.FunctionNames [0]);
encoder = function.CreateArgumentEncoder (0);
}
[TearDown]
public void TearDown ()
{
library?.Dispose ();
library = null;
function?.Dispose ();
function = null;
encoder?.Dispose ();
encoder = null;
}
#if XAMCORE_4_0
[Test]
public void SetBuffers ()
{
Assert.Throws<ArgumentNullException> (() => {
encoder.SetBuffers (null, new nuint [0], new NSRange ());
}, "Null buffers should throw.");
Assert.Throws<ArgumentNullException> (() => {
encoder.SetBuffers (new IMTLBuffer [0], null, new NSRange ());
}, "Null offsets should throw.");
// assert we do not crash or throw, we are testing the extension method
Assert.DoesNotThrow (() => {
encoder.SetBuffers (new IMTLBuffer [0], new nuint [0], new NSRange ());
}, "Should not throw");
}
#endif
}
}
#endif