[Test] public void VectorMath() { Assert.AreEqual( new Vector2(2.0f, 0.5f) + new Vector2(1.0f, 3.0f), GenericOperator.Add(new Vector2(2.0f, 0.5f), new Vector2(1.0f, 3.0f))); Assert.AreEqual( new Vector2(2.0f, 0.5f) - new Vector2(1.0f, 3.0f), GenericOperator.Subtract(new Vector2(2.0f, 0.5f), new Vector2(1.0f, 3.0f))); Assert.AreEqual( new Vector2(2.0f, 0.5f) * new Vector2(1.0f, 3.0f), GenericOperator.Multiply(new Vector2(2.0f, 0.5f), new Vector2(1.0f, 3.0f))); Assert.AreEqual( new Vector2(2.0f, 0.5f) / new Vector2(1.0f, 3.0f), GenericOperator.Divide(new Vector2(2.0f, 0.5f), new Vector2(1.0f, 3.0f))); Assert.AreEqual( -new Vector2(2.0f, 0.5f), GenericOperator.Negate(new Vector2(2.0f, 0.5f))); Assert.AreEqual( new Vector2(2.0f, 0.5f) == new Vector2(1.0f, 3.0f), GenericOperator.Equal(new Vector2(2.0f, 0.5f), new Vector2(1.0f, 3.0f))); Assert.AreEqual( new Vector2(2.0f, 0.5f) == new Vector2(2.0f, 0.5f), GenericOperator.Equal(new Vector2(2.0f, 0.5f), new Vector2(2.0f, 0.5f))); }
[Test] public void IntMath() { Assert.AreEqual(2 + 3, GenericOperator.Add(2, 3)); Assert.AreEqual(2 - 3, GenericOperator.Subtract(2, 3)); Assert.AreEqual(2 * 3, GenericOperator.Multiply(2, 3)); Assert.AreEqual(2 / 3, GenericOperator.Divide(2, 3)); Assert.AreEqual(Math.Abs(-5), GenericOperator.Abs(-5)); Assert.AreEqual(5 % 4, GenericOperator.Modulo(5, 4)); Assert.AreEqual(-5, GenericOperator.Negate(5)); Assert.AreEqual(5 == 4, GenericOperator.Equal(5, 4)); Assert.AreEqual(5 == 5, GenericOperator.Equal(5, 5)); Assert.AreEqual(5 > 4, GenericOperator.GreaterThan(5, 4)); Assert.AreEqual(5 >= 5, GenericOperator.GreaterThanOrEqual(5, 5)); Assert.AreEqual(5 < 4, GenericOperator.LessThan(5, 4)); Assert.AreEqual(5 <= 5, GenericOperator.LessThanOrEqual(5, 5)); }
[Test] public void FloatMath() { Assert.AreEqual(2f + 3f, GenericOperator.Add(2f, 3f)); Assert.AreEqual(2f - 3f, GenericOperator.Subtract(2f, 3f)); Assert.AreEqual(2f * 3f, GenericOperator.Multiply(2f, 3f)); Assert.AreEqual(2f / 3f, GenericOperator.Divide(2f, 3f)); Assert.AreEqual(Math.Abs(-5f), GenericOperator.Abs(-5f)); Assert.AreEqual(5f % 4f, GenericOperator.Modulo(5f, 4f)); Assert.AreEqual(-5f, GenericOperator.Negate(5f)); Assert.AreEqual(5f == 4f, GenericOperator.Equal(5f, 4f)); Assert.AreEqual(5f == 5f, GenericOperator.Equal(5f, 5f)); Assert.AreEqual(5f > 4f, GenericOperator.GreaterThan(5f, 4f)); Assert.AreEqual(5f >= 5f, GenericOperator.GreaterThanOrEqual(5f, 5f)); Assert.AreEqual(5f < 4f, GenericOperator.LessThan(5f, 4f)); Assert.AreEqual(5f <= 5f, GenericOperator.LessThanOrEqual(5f, 5f)); }
[Test] public void ColorRgbaMath() { Assert.AreEqual( ColorRgba.Red + ColorRgba.Blue, GenericOperator.Add(ColorRgba.Red, ColorRgba.Blue)); Assert.AreEqual( ColorRgba.Red - ColorRgba.Blue, GenericOperator.Subtract(ColorRgba.Red, ColorRgba.Blue)); Assert.AreEqual( ColorRgba.Red * ColorRgba.Blue, GenericOperator.Multiply(ColorRgba.Red, ColorRgba.Blue)); Assert.AreEqual( ColorRgba.Red == ColorRgba.Blue, GenericOperator.Equal(ColorRgba.Red, ColorRgba.Blue)); Assert.AreEqual( ColorRgba.Red == ColorRgba.Red, GenericOperator.Equal(ColorRgba.Red, ColorRgba.Red)); }
public static bool operator ==(CustomerValue <T> value1, CustomerValue <T> value2) { return(GenericOperator.Equal <T>(value1._value, value2._value)); }