From 7576cc304562d9a370a1db049058453c7f70b8d5 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 10 Aug 2022 15:55:04 +0200 Subject: [PATCH] Add unit test for [D2DPixelShaderSource] --- .../D2DPixelShaderSourceTests.cs | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/ComputeSharp.D2D1.Tests/D2DPixelShaderSourceTests.cs diff --git a/tests/ComputeSharp.D2D1.Tests/D2DPixelShaderSourceTests.cs b/tests/ComputeSharp.D2D1.Tests/D2DPixelShaderSourceTests.cs new file mode 100644 index 00000000..29852df5 --- /dev/null +++ b/tests/ComputeSharp.D2D1.Tests/D2DPixelShaderSourceTests.cs @@ -0,0 +1,34 @@ +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace ComputeSharp.D2D1.Tests; + +[TestClass] +[TestCategory("D2DPixelShaderSource")] +public partial class D2DPixelShaderSourceTests +{ + [D2DPixelShaderSource(@" + #define D2D_INPUT_COUNT 1 + #define D2D_INPUT0_SIMPLE + + #include ""d2d1effecthelpers.hlsli"" + + D2D_PS_ENTRY(Execute) + { + float4 color = D2DGetInput(0); + float3 rgb = saturate(1.0 - color.rgb); + return float4(rgb, 1); + } + ")] + [D2DEmbeddedBytecode(D2D1ShaderProfile.PixelShader50)] + [D2DCompileOptions(D2D1CompileOptions.OptimizationLevel0)] + private static partial ReadOnlySpan InvertEffect(); + + [TestMethod] + public void VerifyInvertEffectBytecode() + { + ReadOnlySpan bytecode = InvertEffect(); + + Assert.IsTrue(bytecode.Length > 0); + } +} \ No newline at end of file