diff --git a/test/Ray.Domain.Test/Ray.Domain.Test.csproj b/test/Ray.Domain.Test/Ray.Domain.Test.csproj index 2bd616c..6f0368b 100644 --- a/test/Ray.Domain.Test/Ray.Domain.Test.csproj +++ b/test/Ray.Domain.Test/Ray.Domain.Test.csproj @@ -7,10 +7,13 @@ - - + + - + + all + runtime; build; native; contentfiles; analyzers + @@ -18,6 +21,9 @@ + + PreserveNewest + PreserveNewest diff --git a/test/Ray.Domain.Test/Tuples/BasicOperationsTests.cs b/test/Ray.Domain.Test/Tuples/BasicOperationsTests.cs new file mode 100644 index 0000000..2decec4 --- /dev/null +++ b/test/Ray.Domain.Test/Tuples/BasicOperationsTests.cs @@ -0,0 +1,40 @@ +using System.Numerics; +using Xunit; +using Xunit.Gherkin.Quick; + +namespace Ray.Domain.Test.Tuples +{ + [FeatureFile("./features/tuples/BasicOperations.feature")] + public sealed class BasicOperationsTests : Feature + { + private Vector4 _firstTuple = new Vector4(), + _secondTuple = new Vector4(); + + [Given(@"a1 = tuple (\d) (-\d) (\d) (\d)")] + public void One(float x, float y, float z, float w) + { + _firstTuple.X = x; + _firstTuple.Y = y; + _firstTuple.Z = z; + _firstTuple.W = w; + } + + [And(@"a2 = tuple (-\d) (\d) (\d) (\d)")] + public void Two(float x, float y, float z, float w) + { + _secondTuple.X = x; + _secondTuple.Y = y; + _secondTuple.Z = z; + _secondTuple.W = w; + } + + [Then(@"a1 plus a2 = tuple (\d) (\d) (\d) (\d)")] + public void Three(float x, float y, float z, float w) + { + var expectedResult = new Vector4(x, y, z, w); + var actualResult = Vector4.Add(_firstTuple, _secondTuple); + Assert.True(expectedResult.Equals(actualResult)); + } + + } +} diff --git a/test/Ray.Domain.Test/features/tuples/BasicOperations.feature b/test/Ray.Domain.Test/features/tuples/BasicOperations.feature new file mode 100644 index 0000000..9337bb9 --- /dev/null +++ b/test/Ray.Domain.Test/features/tuples/BasicOperations.feature @@ -0,0 +1,11 @@ +Feature: BasicTuplesMathFeature + In order to move around 3D space + As a Ray Tracer + I want the ability to perform basic math on points and vectors + +Background: + Given a1 = tuple 3 -2 5 1 + +Scenario​: Adding two tuples + ​​And​ a2 = tuple -2 3 1 0 + ​​Then​ a1 plus a2 = tuple 1 1 6 1