diff --git a/Source/Expressive.Tests/ExpressionTests.cs b/Source/Expressive.Tests/ExpressionTests.cs index 06616df..9973d08 100644 --- a/Source/Expressive.Tests/ExpressionTests.cs +++ b/Source/Expressive.Tests/ExpressionTests.cs @@ -1,139 +1,137 @@ using Expressive.Exceptions; -using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; using System.Globalization; using System.Threading; using NUnit.Framework; using NUnit.Framework.Constraints; -using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert; namespace Expressive.Tests { - [TestClass] + [TestFixture] public class ExpressionTests { #region Operators #region Plus Operator - [TestMethod] + [Test] public void SimpleIntegerAddition() { Expression expression = new Expression("1+3"); object value = expression.Evaluate(); - Assert.AreEqual(4, value); + Assert.That(value, Is.EqualTo(4)); } - [TestMethod] + [Test] public void SimpleDecimalAddition() { Expression expression = new Expression("1.3+3.5"); object value = expression.Evaluate(); - Assert.AreEqual(4.8M, value); + Assert.That(value, Is.EqualTo(4.8M)); } - [TestMethod] + [Test] public void ShouldAddDoubleAndDecimal() { var expression = new Expression("1.8 + Abs([var1])"); object value = expression.Evaluate(new Dictionary { { "var1", 9.2 } }); - Assert.AreEqual(11M, value); + Assert.That(value, Is.EqualTo(11M)); } - [TestMethod] + [Test] public void ShouldConcatenateStrings() { var expression = new Expression("'1.8' + 'suffix'"); object value = expression.Evaluate(); - Assert.AreEqual("1.8suffix", value); + Assert.That(value, Is.EqualTo("1.8suffix")); } - [TestMethod] + [Test] public void ShouldHandleUnaryPlus() { var expression = new Expression("1.8++0.2"); object value = expression.Evaluate(); - Assert.AreEqual(2.0M, value); + Assert.That(value, Is.EqualTo(2.0M)); - Assert.AreEqual(-2, new Expression("+(1 * -2)").Evaluate()); + Assert.That(new Expression("+(1 * -2)").Evaluate(), Is.EqualTo(-2)); } #endregion - [TestMethod] + [Test] public void SimpleBodmas() { Expression expression = new Expression("1-3*2"); object value = expression.Evaluate(); - Assert.AreEqual(-5, value); + Assert.That(value, Is.EqualTo(-5)); } - [TestMethod] + [Test] public void ScientificNotation() { var expression = new Expression("1.23e2"); - Assert.AreEqual(123, expression.Evaluate()); + Assert.That(expression.Evaluate(), Is.EqualTo(123)); } - [TestMethod] + [Test] public void ScientificNotationWithLargeNumber() { var expression = new Expression("1.23e22"); - Assert.AreEqual(12300000000000000000000M, expression.Evaluate()); + Assert.That(expression.Evaluate(), Is.EqualTo(12300000000000000000000M)); } #region Subtract Operator - [TestMethod] + [Test] public void SimpleIntegerSubtraction() { Expression expression = new Expression("3-1"); object value = expression.Evaluate(); - Assert.AreEqual(2, value); + Assert.That(value, Is.EqualTo(2)); } - [TestMethod] + [Test] public void SimpleDecimalSubtraction() { Expression expression = new Expression("3.5-1.2"); object value = expression.Evaluate(); - Assert.AreEqual(2.3M, value); + Assert.That(value, Is.EqualTo(2.3M)); } - [TestMethod] + [Test] public void ShouldHandleUnarySubtraction() { var expression = new Expression("1.8--0.2"); object value = expression.Evaluate(); - Assert.AreEqual(2.0M, value); + Assert.That(value, Is.EqualTo(2.0M)); - Assert.AreEqual(2, new Expression("-(1 * -2)").Evaluate()); + Assert.That(new Expression("-(1 * -2)").Evaluate(), Is.EqualTo(2)); } #endregion - [TestMethod] + [Test] public void LogicTests() { Assert.AreEqual(true, new Expression("1 && 1").Evaluate()); @@ -148,7 +146,7 @@ public void LogicTests() Assert.AreEqual(true, new Expression("[child1] == false && [child2] == false").Evaluate(new Dictionary { ["child1"] = new Expression("1 == 0"), ["child2"] = new Expression("1 == 0") })); } - [TestMethod] + [Test] public void RelationalTests() { Assert.AreEqual(true, new Expression("1 == 1").Evaluate()); @@ -168,7 +166,7 @@ public void RelationalTests() Assert.AreEqual(true, new Expression("[date1] == '01/01/2016 00:00:00'").Evaluate(new Dictionary { ["date1"] = new DateTime(2016, 01, 01) })); } - [TestMethod] + [Test] public void NullCoalescingTests() { Assert.AreEqual(1, new Expression("null ?? 1").Evaluate()); @@ -179,7 +177,7 @@ public void NullCoalescingTests() #endregion - [TestMethod] + [Test] public void AggregatesHandledInOperators() { Expression expression = new Expression("[array]+2"); @@ -196,222 +194,243 @@ public void AggregatesHandledInOperators() #region Functions - [TestMethod, ExpectedException(typeof(ExpressiveException), "Abs() takes only 1 argument(s)")] + [Test] public void AbsShouldHandleOnlyOneArgument() { Assert.AreEqual(1, new Expression("Abs(-1)").Evaluate()); - Assert.AreEqual(12, new Expression("abs(1,2,4,5)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); + Assert.That( + () => new Expression("abs(1,2,4,5)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate(), + Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Acos() takes only 1 argument(s)")] + [Test] public void AcosShouldHandleOnlyOneArgument() { Assert.AreEqual(0d, new Expression("Acos(1)").Evaluate()); - Assert.AreEqual(12, new Expression("Acos(1,2,4,5)").Evaluate()); + Assert.That(() => new Expression("Acos(1,2,4,5)").Evaluate(), Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Asin() takes only 1 argument(s)")] + [Test] public void AsinShouldHandleOnlyOneArgument() { Assert.AreEqual(0d, new Expression("Asin(0)").Evaluate()); - Assert.AreEqual(12, new Expression("asin(1,2,4,5)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); + Assert.That( + () => new Expression("asin(1,2,4,5)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate(), + Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Atan() takes only 1 argument(s)")] + [Test] public void AtanShouldHandleOnlyOneArgument() { Assert.AreEqual(0d, new Expression("Atan(0)").Evaluate()); - Assert.AreEqual(12, new Expression("atan(1,2,4,5)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); + Assert.That(() => new Expression("Atan(1,2,4,5)").Evaluate(), Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Average() expects at least 1 argument(s)")] + [Test] public void AverageShouldHandleAtLeastOneArgument() { Assert.AreEqual(3d, new Expression("Average(1,2,4,5)").Evaluate()); Assert.AreEqual(1d, new Expression("average(1)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); Assert.AreEqual(12.5, new Expression("Average(10, 20, 5, 15)").Evaluate()); - new Expression("average()", ExpressiveOptions.IgnoreCaseForParsing).Evaluate(); + Assert.That( + () => new Expression("average()", ExpressiveOptions.IgnoreCaseForParsing).Evaluate(), + Throws.InstanceOf()); } - [TestMethod] + [Test] public void AverageShouldHandleIEnumerable() { Assert.AreEqual(3d, new Expression("Average(1,2,4,5,[array])").Evaluate(new Dictionary { ["array"] = new[] { 1, 2, 4, 5 } })); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Ceiling() takes only 1 argument(s)")] + [Test] public void CeilingShouldHandleOnlyOneArgument() { Assert.AreEqual(2M, new Expression("Ceiling(1.5)").Evaluate()); - Assert.AreEqual(12, new Expression("ceiling(1,2,4,5)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); + Assert.That( + () => new Expression("ceiling(1,2,4,5)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate(), + Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Cos() takes only 1 argument(s)")] + [Test] public void CosShouldHandleOnlyOneArgument() { Assert.AreEqual(1d, new Expression("Cos(0)").Evaluate()); - Assert.AreEqual(12, new Expression("Cos(1,2,4,5)").Evaluate()); + Assert.That(() => new Expression("Cos(1,2,4,5)").Evaluate(), Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Count() expects at least 1 argument(s)")] + [Test] public void CountShouldHandleAtLeastOneArgument() { Assert.AreEqual(1, new Expression("Count(0)").Evaluate()); Assert.AreEqual(4, new Expression("count(1,2,4,5)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); - new Expression("Count()").Evaluate(); + Assert.That(() => new Expression("Count()").Evaluate(), Throws.InstanceOf()); } - [TestMethod] + [Test] public void CountShouldHandleIEnumerable() { Assert.AreEqual(5, new Expression("Count([array])").Evaluate(new Dictionary { ["array"] = new[] { 0, 1, 2, 3, 4 } })); Assert.AreEqual(5, new Expression("Count([array])").Evaluate(new Dictionary { ["array"] = new List { 0, 1, 2, 3, 4 } })); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Exp() takes only 1 argument(s)")] + [Test] public void ExpShouldHandleOnlyOneArgument() { Assert.AreEqual(1d, new Expression("Exp(0)").Evaluate()); - Assert.AreEqual(12, new Expression("exp(1,2,4,5)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); + Assert.That( + () => new Expression("exp(1,2,4,5)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate(), + Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Floor() takes only 1 argument(s)")] + [Test] public void FloorShouldHandleOnlyOneArgument() { Assert.AreEqual(1d, new Expression("Floor(1.5)").Evaluate()); - Assert.AreEqual(12, new Expression("Floor(1,2,4,5)").Evaluate()); + Assert.That(() => new Expression("Floor(1,2,4,5)").Evaluate(), Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "IEEERemainder() takes only 2 argument(s)")] + [Test] public void IEEERemainderShouldHandleOnlyTwoArguments() { Assert.AreEqual(-1d, new Expression("IEEERemainder(3, 2)").Evaluate()); - Assert.AreEqual(12, new Expression("IEEERemainder(1,2,4,5)").Evaluate()); + + Assert.That(() => new Expression("IEEERemainder(1,2,4,5)").Evaluate(), Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "If() takes only 3 argument(s)")] + [Test] public void IfShouldHandleOnlyThreeArguments() { Assert.AreEqual("Low risk", new Expression("If(1 > 8, 'High risk', 'Low risk')").Evaluate()); Assert.AreEqual("Low risk", new Expression("If(1 > 8, 1 / 0, 'Low risk')").Evaluate()); - Assert.AreEqual(12, new Expression("If(1 > 9, 2, 4, 5)").Evaluate()); + + Assert.That(() => new Expression("If(1 > 9, 2, 4, 5)").Evaluate(), Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "In() expects at least 2 argument(s)")] + [Test] public void InShouldHandleAtLeastTwoArguments() { Assert.AreEqual(false, new Expression("In('abc','def','ghi','jkl')").Evaluate()); - Assert.AreEqual(1, new Expression("in(0)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); - new Expression("In()", ExpressiveOptions.IgnoreCaseForParsing).Evaluate(); + Assert.That( + () => new Expression("in(0)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate(), + Throws.InstanceOf()); + + Assert.That(() => new Expression("In()").Evaluate(), Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Length() takes only 1 argument(s)")] + [Test] public void LengthShouldHandleOnlyOneArgument() { Assert.AreEqual(5, new Expression("Length('abcde')").Evaluate()); - new Expression("Length()", ExpressiveOptions.IgnoreCaseForParsing).Evaluate(); + Assert.That(() => new Expression("Length()").Evaluate(), Throws.InstanceOf()); } - [TestMethod] + [Test] public void LengthShouldHandleNotJustStrings() { Assert.AreEqual(3, new Expression("Length(123)").Evaluate()); Assert.AreEqual(null, new Expression("Length(null)").Evaluate()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Log() takes only 2 argument(s)")] + [Test] public void LogShouldHandleOnlyTwoArguments() { Assert.AreEqual(0d, new Expression("Log(1, 10)").Evaluate()); - Assert.AreEqual(12, new Expression("Log(1,2,4,5)").Evaluate()); + Assert.That(() => new Expression("Log(1,2,4,5)").Evaluate(), Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Log10() takes only 1 argument(s)")] + [Test] public void Log10ShouldHandleOnlyOneArgument() { Assert.AreEqual(0d, new Expression("Log10(1)").Evaluate()); - Assert.AreEqual(12, new Expression("Log10(1,2,4,5)").Evaluate()); + Assert.That(() => new Expression("Log10(1,2,4,5)").Evaluate(), Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Max() expects at least 1 argument(s)")] + [Test] public void MaxShouldHandleAtLeastOneArgument() { Assert.AreEqual(3, new Expression("Max(3, 2)").Evaluate()); - Assert.AreEqual(12, new Expression("Max()").Evaluate()); + Assert.That(() => new Expression("Max()").Evaluate(), Throws.InstanceOf()); } - [TestMethod] + [Test] public void MaxShouldHandleIEnumerable() { Assert.AreEqual(50, new Expression("Max(1,2,4,5,[array])").Evaluate(new Dictionary { ["array"] = new[] { 1, 2, 4, 50 } })); } - [TestMethod] + [Test] public void MaxShouldIgnoreNull() { Assert.AreEqual(null, new Expression("Max(null,2,4,5,[array])").Evaluate(new Dictionary { ["array"] = new[] { 1, 2, 4, 50 } })); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Mean() expects at least 1 argument(s)")] + [Test] public void MeanShouldHandleAtLeastOneArgument() { Assert.AreEqual(3d, new Expression("Mean(1,2,4,5)").Evaluate()); Assert.AreEqual(1d, new Expression("mean(1)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); Assert.AreEqual(12.5, new Expression("Mean(10, 20, 5, 15)").Evaluate()); - new Expression("mean()", ExpressiveOptions.IgnoreCaseForParsing).Evaluate(); + Assert.That( + () => new Expression("mean()", ExpressiveOptions.IgnoreCaseForParsing).Evaluate(), + Throws.InstanceOf()); } - [TestMethod] + [Test] public void MeanShouldHandleIEnumerable() { Assert.AreEqual(3d, new Expression("Mean(1,2,4,5,[array])").Evaluate(new Dictionary { ["array"] = new[] { 1, 2, 4, 5 } })); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Median() expects at least 1 argument(s)")] + [Test] public void MedianShouldHandleAtLeastOneArgument() { Assert.AreEqual(3.0M, new Expression("Median(1,2,4,5)").Evaluate()); Assert.AreEqual(1.0M, new Expression("median(1)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); Assert.AreEqual(12.5M, new Expression("Median(10, 20, 5, 15)").Evaluate()); - new Expression("median()", ExpressiveOptions.IgnoreCaseForParsing).Evaluate(); + Assert.That( + () => new Expression("median()", ExpressiveOptions.IgnoreCaseForParsing).Evaluate(), + Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Min() expects at least 1 argument(s)")] + [Test] public void MinShouldHandleAtLeastOneArgument() { Assert.AreEqual(2, new Expression("Min(3, 2)").Evaluate()); - Assert.AreEqual(12, new Expression("Min()").Evaluate()); + Assert.That(() => new Expression("Min()").Evaluate(), Throws.InstanceOf()); } - [TestMethod] + [Test] public void MinShouldHandleIEnumerable() { Assert.AreEqual(1, new Expression("Min(1,2,4,5,[array])").Evaluate(new Dictionary { ["array"] = new[] { 1, 2, 4, 50 } })); } - [TestMethod] + [Test] public void MinShouldIgnoreNull() { Assert.AreEqual(null, new Expression("Min(null,2,4,5,[array])").Evaluate(new Dictionary { ["array"] = new[] { 1, 2, 4, 50 } })); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Mode() expects at least 1 argument(s)")] + [Test] public void ModeShouldHandleAtLeastOneArgument() { Assert.AreEqual(2, new Expression("Mode(1,2,4,5,2)").Evaluate()); Assert.AreEqual(1, new Expression("mode(1)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); Assert.AreEqual(10, new Expression("Mode(10, 20, 5, 15)").Evaluate()); - new Expression("mode()", ExpressiveOptions.IgnoreCaseForParsing).Evaluate(); + Assert.That( + () => new Expression("mode()", ExpressiveOptions.IgnoreCaseForParsing).Evaluate(), + Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "PadLeft() takes only 3 argument(s)")] + [Test] public void PadLeftShouldHandleOnlyTwoArguments() { Assert.AreEqual("0000abc", new Expression("PadLeft('abc', 7, '0')").Evaluate()); @@ -419,10 +438,11 @@ public void PadLeftShouldHandleOnlyTwoArguments() Assert.AreEqual(null, new Expression("PadLeft(null, 7, '0')").Evaluate()); Assert.AreEqual(null, new Expression("PadLeft('abcdefghi', null, '0')").Evaluate()); Assert.AreEqual(" abcd", new Expression("PadLeft('abcd', 7, null)").Evaluate()); - Assert.AreEqual(12, new Expression("PadLeft(1,2,4,5)").Evaluate()); + + Assert.That(() => new Expression("PadLeft(1,2,4,5)").Evaluate(), Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "PadRight() takes only 3 argument(s)")] + [Test] public void PadRightShouldHandleOnlyTwoArguments() { Assert.AreEqual("abc0000", new Expression("PadRight('abc', 7, '0')").Evaluate()); @@ -430,71 +450,77 @@ public void PadRightShouldHandleOnlyTwoArguments() Assert.AreEqual(null, new Expression("PadRight(null, 7, '0')").Evaluate()); Assert.AreEqual(null, new Expression("PadRight('abcdefghi', null, '0')").Evaluate()); Assert.AreEqual("abcd ", new Expression("PadRight('abcd', 7, null)").Evaluate()); - Assert.AreEqual(12, new Expression("PadRight(1,2,4,5)").Evaluate()); + + Assert.That(() => new Expression("PadRight(1,2,4,5)").Evaluate(), Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Pow() takes only 2 argument(s)")] + [Test] public void PowShouldHandleOnlyTwoArguments() { Assert.AreEqual(9d, new Expression("Pow(3, 2)").Evaluate()); - Assert.AreEqual(12, new Expression("Pow(1,2,4,5)").Evaluate()); + + Assert.That(() => new Expression("Pow(1,2,4,5)").Evaluate(), Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Regex() takes only 2 argument(s)")] + [Test] public void RegexShouldHandleOnlyTwoArguments() { Expression expression = new Expression(@"Regex('text', '^\s*(?:\+?(\d{1,3}))?([-. (]*(\d{3})[-. )]*)?((\d{3})[-. ]*(\d{2,4})(?:[-.x ]*(\d+))?)\s*$')"); Assert.AreEqual(false, expression.Evaluate()); expression = new Expression(@"Regex('text', '^\s*(?:\+?(\d{1,3}))?([-. (]*(\d{3})[-. )]*)?((\d{3})[-. ]*(\d{2,4})(?:[-.x ]*(\d+))?)\s*$', '')"); - Assert.AreEqual(false, expression.Evaluate()); + Assert.That(() => expression.Evaluate(), Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Round() takes only 2 argument(s)")] + [Test] public void RoundShouldHandleOnlyTwoArguments() { Assert.AreEqual(3.22d, new Expression("Round(3.222222, 2)").Evaluate()); - Assert.AreEqual(12, new Expression("Round(1,2,4,5)").Evaluate()); + + Assert.That(() => new Expression("Round(1,2,4,5)").Evaluate(), Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Sign() takes only 1 argument(s)")] + [Test] public void SignShouldHandleOnlyOneArgument() { Assert.AreEqual(-1, new Expression("Sign(-10)").Evaluate()); - Assert.AreEqual(12, new Expression("Sign(1,2,4,5)").Evaluate()); + + Assert.That(() => new Expression("Sign(1,2,4,5)").Evaluate(), Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Sin() takes only 1 argument(s)")] + [Test] public void SinShouldHandleOnlyOneArgument() { Assert.AreEqual(0d, new Expression("Sin(0)").Evaluate()); - Assert.AreEqual(12, new Expression("Sin(1,2,4,5)").Evaluate()); + + Assert.That(() => new Expression("Sin(1,2,4,5)").Evaluate(), Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Sqrt() takes only 1 argument(s)")] + [Test] public void SqrtShouldHandleOnlyOneArgument() { Assert.AreEqual(5d, new Expression("Sqrt(25)").Evaluate()); - Assert.AreEqual(12, new Expression("Sqrt(1,2,4,5)").Evaluate()); + + Assert.That(() => new Expression("Sqrt(1,2,4,5)").Evaluate(), Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Sum() expects at least 1 argument(s)")] + [Test] public void SumShouldHandleAtLeastOneArgument() { Assert.AreEqual(12, new Expression("Sum(1,2,4,5)").Evaluate()); Assert.AreEqual(1, new Expression("sum(1)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); Assert.AreEqual(72, new Expression("sum(1,2,4,5,10,20,30)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); - new Expression("Sum()").Evaluate(); + Assert.That(() => new Expression("Sum()").Evaluate(), Throws.InstanceOf()); } - [TestMethod] + [Test] public void SumShouldHandleIEnumerable() { Assert.AreEqual(10, new Expression("Sum([array])").Evaluate(new Dictionary { ["array"] = new[] { 0, 1, 2, 3, 4 } })); } - [TestMethod] + [Test] public void SumShouldHandleIEnumerableWithNulls() { var arguments = new Dictionary @@ -506,11 +532,11 @@ public void SumShouldHandleIEnumerableWithNulls() var result = expression.Evaluate(arguments); - Assert.IsInstanceOfType(result, typeof(decimal?)); + Assert.That(result, Is.InstanceOf(typeof(decimal?))); Assert.AreEqual(6.5m, result); } - [TestMethod] + [Test] public void SumShouldUseZeroInsteadOfNull() { var arguments = new Dictionary @@ -522,25 +548,27 @@ public void SumShouldUseZeroInsteadOfNull() var result = expression.Evaluate(arguments); - Assert.IsInstanceOfType(result, typeof(decimal?)); + Assert.That(result, Is.InstanceOf(typeof(decimal?))); Assert.AreEqual(1.1m, result); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Tan() takes only 1 argument(s)")] + [Test] public void TanShouldHandleOnlyOneArgument() { Assert.AreEqual(0d, new Expression("Tan(0)").Evaluate()); - Assert.AreEqual(12, new Expression("Tan(1,2,4,5)").Evaluate()); + + Assert.That(() => new Expression("Tan(1,2,4,5)").Evaluate(), Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Truncate() takes only 1 argument(s)")] + [Test] public void TruncateShouldHandleOnlyOneArgument() { Assert.AreEqual(1d, new Expression("Truncate(1.7)").Evaluate()); - Assert.AreEqual(12, new Expression("Truncate(1,2,4,5)").Evaluate()); + + Assert.That(() => new Expression("Truncate(1,2,4,5)").Evaluate(), Throws.InstanceOf()); } - [TestMethod] + [Test] public void CustomFunctionsWithLambda() { var exp = new Expression("myfunc('abc')"); @@ -552,130 +580,9 @@ public void CustomFunctionsWithLambda() Assert.AreEqual(1, exp.Evaluate()); } - #region Date Functions - - [TestMethod, ExpectedException(typeof(ExpressiveException), "AddDays() takes only 2 argument(s)")] - public void AddDaysShouldHandleOnlyTwoArguments() - { - Assert.AreEqual(new DateTime(2016, 01, 03), new Expression("AddDays(#2016-01-01#, 2)").Evaluate()); - Assert.AreEqual(new DateTime(2016, 01, 03), new Expression("addDays(#2016-01-01#, 2)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); - - new Expression("AddDays()").Evaluate(); - } - - [TestMethod, ExpectedException(typeof(ExpressiveException), "AddHours() takes only 2 argument(s)")] - public void AddHoursShouldHandleOnlyTwoArguments() - { - Assert.AreEqual(new DateTime(2016, 01, 01, 02, 00, 00), new Expression("AddHours(#2016-01-01 00:00:00#, 2)").Evaluate()); - Assert.AreEqual(new DateTime(2016, 01, 01, 02, 00, 00), new Expression("addhours(#2016-01-01 00:00:00#, 2)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); - - new Expression("AddHours()").Evaluate(); - } - - [TestMethod, ExpectedException(typeof(ExpressiveException), "AddMinutes() takes only 2 argument(s)")] - public void AddMinutesShouldHandleOnlyTwoArguments() - { - Assert.AreEqual(new DateTime(2016, 01, 01, 00, 02, 00), new Expression("AddMinutes(#2016-01-01 00:00:00#, 2)").Evaluate()); - Assert.AreEqual(new DateTime(2016, 01, 01, 00, 02, 00), new Expression("addminutes(#2016-01-01 00:00:00#, 2)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); - - new Expression("AddMinutes()").Evaluate(); - } - - [TestMethod, ExpectedException(typeof(ExpressiveException), "AddMonths() takes only 2 argument(s)")] - public void AddMonthsShouldHandleOnlyTwoArguments() - { - Assert.AreEqual(new DateTime(2016, 03, 01), new Expression("AddMonths(#2016-01-01#, 2)").Evaluate()); - Assert.AreEqual(new DateTime(2016, 03, 01), new Expression("addmonths(#2016-01-01#, 2)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); - - new Expression("AddMonths()").Evaluate(); - } - - [TestMethod, ExpectedException(typeof(ExpressiveException), "AddYears() takes only 2 argument(s)")] - public void AddYearsShouldHandleOnlyTwoArguments() - { - Assert.AreEqual(new DateTime(2018, 01, 01), new Expression("AddYears(#2016-01-01#, 2)").Evaluate()); - Assert.AreEqual(new DateTime(2018, 01, 01), new Expression("addyears(#2016-01-01#, 2)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); - - new Expression("AddYears()").Evaluate(); - } - - [TestMethod, ExpectedException(typeof(ExpressiveException), "DayOf() takes only 1 argument(s)")] - public void DayOfShouldHandleOnlyOneArgument() - { - Assert.AreEqual(1, new Expression("DayOf(#2016-01-01#)").Evaluate()); - Assert.AreEqual(12, new Expression("dayof(#2016-01-12#)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); - - new Expression("DayOf()").Evaluate(); - } - - [TestMethod, ExpectedException(typeof(ExpressiveException), "DaysBetween() takes only 2 argument(s)")] - public void DaysBetweenShouldHandleOnlyTwoArguments() - { - Assert.AreEqual((new DateTime(2016, 01, 12) - new DateTime(2016, 01, 01)).TotalDays, new Expression("DaysBetween(#2016-01-01#, #2016-01-12#)").Evaluate()); - Assert.AreEqual((new DateTime(2016, 12, 01) - new DateTime(2016, 01, 01)).TotalDays, new Expression("daysbetween(#2016-01-01#, #2016-12-01#)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); - - new Expression("DaysBetween()").Evaluate(); - } - - [TestMethod, ExpectedException(typeof(ExpressiveException), "HourOf() takes only 1 argument(s)")] - public void HourOfShouldHandleOnlyOneArgument() - { - Assert.AreEqual(2, new Expression("HourOf(#2016-01-01 02:00:00#)").Evaluate()); - Assert.AreEqual(2, new Expression("hourof(#2016-01-12 02:00:00#)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); - - new Expression("HourOf()").Evaluate(); - } - - [TestMethod, ExpectedException(typeof(ExpressiveException), "HoursBetween() takes only 2 argument(s)")] - public void HoursBetweenShouldHandleOnlyTwoArguments() - { - Assert.AreEqual((new DateTime(2016, 01, 01, 23, 00, 00) - new DateTime(2016, 01, 01)).TotalHours, new Expression("HoursBetween(#2016-01-01#, #2016-01-01 23:00:00#)").Evaluate()); - Assert.AreEqual((new DateTime(2016, 12, 01, 23, 00, 00) - new DateTime(2016, 01, 01)).TotalHours, new Expression("hoursbetween(#2016-01-01#, #2016-12-01 23:00:00#)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); - - new Expression("HoursBetween()").Evaluate(); - } - - [TestMethod, ExpectedException(typeof(ExpressiveException), "MinuteOf() takes only 1 argument(s)")] - public void MinuteOfShouldHandleOnlyOneArgument() - { - Assert.AreEqual(55, new Expression("MinuteOf(#2016-01-01 02:55:00#)").Evaluate()); - Assert.AreEqual(12, new Expression("minuteof(#2016-01-12 02:12:00#)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); - - new Expression("MinuteOf()").Evaluate(); - } - - [TestMethod, ExpectedException(typeof(ExpressiveException), "MinutesBetween() takes only 2 argument(s)")] - public void MinutesBetweenShouldHandleOnlyTwoArguments() - { - Assert.AreEqual((new DateTime(2016, 01, 01, 23, 12, 00) - new DateTime(2016, 01, 01)).TotalMinutes, new Expression("MinutesBetween(#2016-01-01#, #2016-01-01 23:12:00#)").Evaluate()); - Assert.AreEqual((new DateTime(2016, 12, 01, 23, 32, 00) - new DateTime(2016, 01, 01)).TotalMinutes, new Expression("minutesbetween(#2016-01-01#, #2016-12-01 23:32:00#)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); - - new Expression("MinutesBetween()").Evaluate(); - } - - [TestMethod, ExpectedException(typeof(ExpressiveException), "MonthOf() takes only 1 argument(s)")] - public void MonthOfShouldHandleOnlyOneArgument() - { - Assert.AreEqual(01, new Expression("MonthOf(#2016-01-01#)").Evaluate()); - Assert.AreEqual(06, new Expression("monthof(#2016-06-12#)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); - - new Expression("MonthOf()").Evaluate(); - } - - [TestMethod, ExpectedException(typeof(ExpressiveException), "YearOf() takes only 1 argument(s)")] - public void YearOfShouldHandleOnlyOneArgument() - { - Assert.AreEqual(2016, new Expression("YearOf(#2016-01-01#)").Evaluate()); - Assert.AreEqual(2016, new Expression("yearof(#2016-01-12#)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate()); - - new Expression("YearOf()").Evaluate(); - } - - #endregion - #region Conversion Functions - [TestMethod] + [Test] public void ShouldConvertToDate() { var arguments = new Dictionary @@ -690,7 +597,7 @@ public void ShouldConvertToDate() Assert.AreEqual(new DateTime(2018, 10, 01), (DateTime)expression.Evaluate(arguments)); } - [TestMethod] + [Test] public void ShouldConvertToDecimal() { var arguments = new Dictionary @@ -710,7 +617,7 @@ public void ShouldConvertToDecimal() Assert.AreEqual(4.4M, (decimal)expression.Evaluate(arguments)); } - [TestMethod] + [Test] public void ShouldConvertToDouble() { var arguments = new Dictionary @@ -730,7 +637,7 @@ public void ShouldConvertToDouble() Assert.AreEqual(4d, (double)expression.Evaluate(arguments)); } - [TestMethod] + [Test] public void ShouldConvertToInteger() { var arguments = new Dictionary @@ -750,7 +657,7 @@ public void ShouldConvertToInteger() Assert.AreEqual(4, (int)expression.Evaluate(arguments)); } - [TestMethod] + [Test] public void ShouldConvertToLong() { var arguments = new Dictionary @@ -770,7 +677,7 @@ public void ShouldConvertToLong() Assert.AreEqual(4L, (long)expression.Evaluate(arguments)); } - [TestMethod] + [Test] public void ShouldConvertToString() { var arguments = new Dictionary @@ -798,7 +705,7 @@ public void ShouldConvertToString() #region General - //[TestMethod] + //[Test] //public void TestAsync() //{ // Expression expression = new Expression("1+3"); @@ -818,7 +725,7 @@ public void ShouldConvertToString() // Assert.AreEqual(4, result); //} - //[TestMethod] + //[Test] //public void TestAsyncSafety() //{ // Expression expression = new Expression("1+3+[abc]"); @@ -838,16 +745,18 @@ public void ShouldConvertToString() // Assert.IsNull(result); //} - [TestMethod, ExpectedException(typeof(ExpressiveException), "There aren't enough ')' symbols. Expected 2 but there is only 1")] + [Test] public void ShouldIdentifyParenthesisMismatch() { Expression expression = new Expression("(a + b) * (4 - 2"); - object value = expression.Evaluate(new Dictionary { { "a", 2 }, { "b", 3 } }); + Assert.That( + () => expression.Evaluate(new Dictionary { { "a", 2 }, { "b", 3 } }), + Throws.InstanceOf()); } // Expressions currently no longer short circuit at this level given the new feature of allowing aggregates in operations. - //[TestMethod] + //[Test] //public void ShouldShortCircuitBooleanExpressions() //{ // var expression = new Expression("([a] != 0) && ([b]/[a]>2)"); @@ -855,14 +764,14 @@ public void ShouldIdentifyParenthesisMismatch() // Assert.AreEqual(false, expression.Evaluate(new Dictionary { { "a", 0 } })); //} - [TestMethod] + [Test] public void ShouldCompareDates() { Assert.AreEqual(true, new Expression("#1/1/2009#==#1/1/2009#").Evaluate()); Assert.AreEqual(false, new Expression("#2/1/2009#==#1/1/2009#").Evaluate()); } - [TestMethod] + [Test] public void ShouldEvaluateSubExpressions() { var volume = new Expression("[surface] * [h]"); @@ -871,7 +780,7 @@ public void ShouldEvaluateSubExpressions() Assert.AreEqual(6, volume.Evaluate(new Dictionary { { "surface", surface }, { "h", 3 }, { "l", 1 }, { "K", 2 } })); } - [TestMethod] + [Test] public void ShouldParseValues() { Assert.AreEqual(123456, new Expression("123456").Evaluate()); @@ -882,7 +791,7 @@ public void ShouldParseValues() Assert.AreEqual("qwerty", new Expression("'qwerty'").Evaluate()); } - [TestMethod] + [Test] public void ShouldEscapeCharacters() { Assert.AreEqual("'hello'", new Expression(@"'\'hello\''").Evaluate()); @@ -892,7 +801,7 @@ public void ShouldEscapeCharacters() Assert.AreEqual("hel\nlo", new Expression(@"'hel\nlo'").Evaluate()); } - [TestMethod] + [Test] public void ShouldHandleOperatorsPriority() { Assert.AreEqual(8, new Expression("2+2+2+2").Evaluate()); @@ -904,39 +813,36 @@ public void ShouldHandleOperatorsPriority() Assert.AreEqual(13.5d, new Expression("18.0/2.0/2.0*3.0").Evaluate()); } - [TestMethod] + [Test] public void ShouldNotLosePrecision() { Assert.AreEqual(0.5, new Expression("3/6").Evaluate()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "Unrecognised token 'blarsh'")] + [Test] public void ShouldFailOnUnrecognisedToken() { - Assert.AreEqual(0.5, new Expression("1 + blarsh + 4").Evaluate()); + Assert.That( + () => new Expression("1 + blarsh + 4").Evaluate(), + Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(ExpressiveException), "The variable 'a' has not been supplied.")] + [Test] public void ShouldHandleCaseSensitivity() { new Expression("([a] + [b]) * (4 - 2)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate(new Dictionary { { "A", 2 }, { "b", 3 } }); new Expression("IF(true, true, false)", ExpressiveOptions.IgnoreCaseForParsing).Evaluate(); - try - { - new Expression("IF(true, true, false)").Evaluate(); - } - catch (UnrecognisedTokenException ute) - { - Assert.AreEqual("Unrecognised token 'IF'", ute.Message); - } + Assert.That(() => new Expression("IF(true, true, false)").Evaluate(), Throws.InstanceOf()); Expression expression = new Expression("([a] + [b]) * (4 - 2)"); - object value = expression.Evaluate(new Dictionary { { "A", 2 }, { "b", 3 } }); + Assert.That( + () => expression.Evaluate(new Dictionary { { "A", 2 }, { "b", 3 } }), + Throws.InstanceOf()); } - [TestMethod] + [Test] public void ShouldReturnCorrectVariables() { var expression = new Expression("([a] + [b] * [c]) + ([a] * [b])"); @@ -944,7 +850,7 @@ public void ShouldReturnCorrectVariables() Assert.AreEqual(3, expression.ReferencedVariables.Count); } - [TestMethod] + [Test] public void CheckNullValuesAreHandledCorrectly() { Assert.IsNull(new Expression("2 + [a]").Evaluate(new Dictionary { ["a"] = null })); @@ -954,7 +860,7 @@ public void CheckNullValuesAreHandledCorrectly() Assert.IsNull(new Expression("2 % [a]").Evaluate(new Dictionary { ["a"] = null })); } - [TestMethod] + [Test] public void CheckNaNIsHandledCorrectly() { Assert.AreEqual(double.NaN, new Expression("2 + [a]").Evaluate(new Dictionary { ["a"] = double.NaN })); @@ -964,7 +870,7 @@ public void CheckNaNIsHandledCorrectly() Assert.AreEqual(double.NaN, new Expression("2 % [a]").Evaluate(new Dictionary { ["a"] = double.NaN })); } - [TestMethod] + [Test] public void CheckComplicatedDepth() { // This was a previous bug (Issue #6) so this is in place to make sure it does not re-occur. @@ -975,29 +881,14 @@ public void CheckComplicatedDepth() Assert.AreEqual(25d, value); } - [TestMethod] - public void ShouldThrowExceptionIfEitherSideIsMissing() + [TestCase("<= #today#")] + [TestCase("#today# <=")] + public void ShouldThrowExceptionIfEitherSideIsMissing(string expression) { - try - { - new Expression("<= #today#").Evaluate(); - } - catch (ExpressiveException ee) - { - Assert.AreEqual("The left hand side of the operation is missing.", ee.Message); - } - - try - { - new Expression("#today# <=").Evaluate(); - } - catch (ExpressiveException ee) - { - Assert.AreEqual("The right hand side of the operation is missing.", ee.Message); - } + Assert.That(() => new Expression(expression).Evaluate(), Throws.InstanceOf()); } - [TestMethod] + [Test] public void ShouldThrowExceptionIfNoContents() { try @@ -1019,14 +910,14 @@ public void ShouldThrowExceptionIfNoContents() } } - [TestMethod] + [Test] public void ShouldMatchStringToBooleanTrue() { Assert.IsTrue((bool)new Expression("'True' && true").Evaluate()); Assert.IsFalse((bool)new Expression("'False' && true").Evaluate()); } - [TestMethod] + [Test] public void ShouldHandleCommaDecimalSeparatorForEuropeanCultures() { //Rule('a60f99fa-21ee-4dfa-b8c1-80ffaa3a83de', 10, 20) @@ -1034,7 +925,7 @@ public void ShouldHandleCommaDecimalSeparatorForEuropeanCultures() Assert.AreEqual(20, invariantExpression.Evaluate()); } - [TestMethod] + [Test] public void ShouldHandlePartiallyMatchingCustomFunctionNames() { var expression = new Expression("CountInstances()"); @@ -1053,7 +944,7 @@ public void ShouldHandlePartiallyMatchingCustomFunctionNames() #endregion - [TestMethod] + [Test] public void ShouldHandleBugTwentyTwo() { // Not working @@ -1094,7 +985,7 @@ public void ShouldHandleBugTwentyTwo() Assert.AreEqual(2.0f, (float)expression.Evaluate(arguments)); } - [TestMethod] + [Test] public void ShouldHandleBugTwentyThree() { var arguments = new Dictionary @@ -1105,7 +996,7 @@ public void ShouldHandleBugTwentyThree() Assert.AreEqual("Date Needed", new Expression("if([plate.datecontrol] = NULL, 'Date Needed', 'Date Entered')", ExpressiveOptions.IgnoreCaseForParsing).Evaluate(arguments)); } - [TestMethod] + [Test] public void ShouldHandleBugTwentyFour() { var arguments = new Dictionary @@ -1117,7 +1008,7 @@ public void ShouldHandleBugTwentyFour() Assert.AreEqual(true, new Expression("[DischargeStatus1_Value] > 00 AND[DischargeStatus2_Value] = 00", ExpressiveOptions.IgnoreCaseForParsing).Evaluate(arguments)); } - [TestMethod] + [Test] public void ShouldIgnoreCurrentCulture() { ExecuteUnderCulture("de-DE", () => @@ -1129,7 +1020,7 @@ public void ShouldIgnoreCurrentCulture() #region Actual unit tests for the Expression class to remain. - [TestMethod] + [Test] public void ShouldEvaluateT() { var expression = new Expression("1 + 2.0 + 3 * 4.0"); @@ -1183,7 +1074,7 @@ private static IEnumerable DictionaryEnumerationS } } - [TestMethod] + [Test] public void ShouldRethrowOnInvalidEvaluateT() { var expression = new Expression("1 + 2.0 + 3 * 4.0"); @@ -1200,7 +1091,7 @@ public void ShouldRethrowOnInvalidEvaluateT() } } - Assert.Fail("Invalid handling of exceptions."); + Assert.Fail(); } #endregion diff --git a/Source/Expressive.Tests/Expressions/Binary/Additive/AddExpressionTests.cs b/Source/Expressive.Tests/Expressions/Binary/Additive/AddExpressionTests.cs index e06442b..4152d91 100644 --- a/Source/Expressive.Tests/Expressions/Binary/Additive/AddExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/Binary/Additive/AddExpressionTests.cs @@ -1,45 +1,44 @@ using System.Collections.Generic; using Expressive.Expressions; using Expressive.Expressions.Binary.Additive; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; using Moq; +using System; namespace Expressive.Tests.Expressions.Binary.Additive { - [TestClass] + [TestFixture] public class AddExpressionTests { - [TestMethod] + [Test] public void TestEvaluate() { var expression = new AddExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)1), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)2), + MockExpression.ThatEvaluatesTo(1), + MockExpression.ThatEvaluatesTo(2), new Context(ExpressiveOptions.None)); Assert.AreEqual(3, expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestEvaluateWithDifferentSizedArrays() { var expression = new AddExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)new[] { 1, 2, 3 }), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)new[] { 1 }), + MockExpression.ThatEvaluatesTo(new[] { 1, 2, 3 }), + MockExpression.ThatEvaluatesTo(new[] { 1 }), new Context(ExpressiveOptions.None)); Assert.IsNull(expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestEvaluateWithEmptyLeftArray() { -#pragma warning disable CA1825 // Avoid zero-length array allocations. - Array.Empty does not exist in net 4.5 var expression = new AddExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)new int[0]), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)new[] { 1, 2, 3 }), + MockExpression.ThatEvaluatesTo(Array.Empty()), + MockExpression.ThatEvaluatesTo(new[] { 1, 2, 3 }), new Context(ExpressiveOptions.None)); -#pragma warning restore CA1825 // Avoid zero-length array allocations. var result = (object[])expression.Evaluate(null); Assert.IsTrue(result.Length == 3); @@ -50,12 +49,12 @@ public void TestEvaluateWithEmptyLeftArray() Assert.AreEqual(result[2], null); } - [TestMethod] + [Test] public void TestEvaluateWithOneSidedArray() { var expression = new AddExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)new[] { 1, 2, 3 }), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)2), + MockExpression.ThatEvaluatesTo(new[] { 1, 2, 3 }), + MockExpression.ThatEvaluatesTo(2), new Context(ExpressiveOptions.None)); var result = (object[])expression.Evaluate(null); @@ -65,12 +64,12 @@ public void TestEvaluateWithOneSidedArray() Assert.AreEqual(result[2], 5); } - [TestMethod] + [Test] public void TestEvaluateWithSameSizedArrays() { var expression = new AddExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)new[] { 1, 2, 3 }), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)new[] { 1, 2, 3 }), + MockExpression.ThatEvaluatesTo(new[] { 1, 2, 3 }), + MockExpression.ThatEvaluatesTo(new[] { 1, 2, 3 }), new Context(ExpressiveOptions.None)); var result = (object[])expression.Evaluate(null); @@ -80,12 +79,12 @@ public void TestEvaluateWithSameSizedArrays() Assert.AreEqual(result[2], 6); } - [TestMethod] + [Test] public void TestStringAddition() { var expression = new AddExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)"1"), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)2), + MockExpression.ThatEvaluatesTo("1"), + MockExpression.ThatEvaluatesTo(2), new Context(ExpressiveOptions.None)); Assert.AreEqual("12", expression.Evaluate(null)); diff --git a/Source/Expressive.Tests/Expressions/Binary/Additive/SubtractExpressionTests.cs b/Source/Expressive.Tests/Expressions/Binary/Additive/SubtractExpressionTests.cs index 6b3c59e..7c76a8b 100644 --- a/Source/Expressive.Tests/Expressions/Binary/Additive/SubtractExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/Binary/Additive/SubtractExpressionTests.cs @@ -1,20 +1,17 @@ -using System.Collections.Generic; -using Expressive.Expressions; -using Expressive.Expressions.Binary.Additive; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; +using Expressive.Expressions.Binary.Additive; +using NUnit.Framework; namespace Expressive.Tests.Expressions.Binary.Additive { - [TestClass] + [TestFixture] public class SubtractExpressionTests { - [TestMethod] + [Test] public void TestEvaluate() { var expression = new SubtractExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)1), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)2), + MockExpression.ThatEvaluatesTo(1), + MockExpression.ThatEvaluatesTo(2), new Context(ExpressiveOptions.None)); Assert.AreEqual(-1, expression.Evaluate(null)); diff --git a/Source/Expressive.Tests/Expressions/Binary/Bitwise/BitwiseAndExpressionTests.cs b/Source/Expressive.Tests/Expressions/Binary/Bitwise/BitwiseAndExpressionTests.cs index d975d63..6d585d3 100644 --- a/Source/Expressive.Tests/Expressions/Binary/Bitwise/BitwiseAndExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/Binary/Bitwise/BitwiseAndExpressionTests.cs @@ -1,20 +1,17 @@ -using System.Collections.Generic; -using Expressive.Expressions; -using Expressive.Expressions.Binary.Bitwise; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; +using Expressive.Expressions.Binary.Bitwise; +using NUnit.Framework; namespace Expressive.Tests.Expressions.Binary.Bitwise { - [TestClass] + [TestFixture] public class BitwiseAndExpressionTests { - [TestMethod] + [Test] public void TestEvaluate() { var expression = new BitwiseAndExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)0x1001), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)0x0001), + MockExpression.ThatEvaluatesTo(0x1001), + MockExpression.ThatEvaluatesTo(0x0001), new Context(ExpressiveOptions.None)); Assert.AreEqual(0x0001, expression.Evaluate(null)); diff --git a/Source/Expressive.Tests/Expressions/Binary/Bitwise/BitwiseExclusiveOrExpressionTests.cs b/Source/Expressive.Tests/Expressions/Binary/Bitwise/BitwiseExclusiveOrExpressionTests.cs index 18662ab..d8ba313 100644 --- a/Source/Expressive.Tests/Expressions/Binary/Bitwise/BitwiseExclusiveOrExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/Binary/Bitwise/BitwiseExclusiveOrExpressionTests.cs @@ -1,20 +1,17 @@ -using System.Collections.Generic; -using Expressive.Expressions; -using Expressive.Expressions.Binary.Bitwise; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; +using Expressive.Expressions.Binary.Bitwise; +using NUnit.Framework; namespace Expressive.Tests.Expressions.Binary.Bitwise { - [TestClass] + [TestFixture] public class BitwiseExclusiveOrExpressionTests { - [TestMethod] + [Test] public void TestEvaluate() { var expression = new BitwiseExclusiveOrExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)1111), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)0001), + MockExpression.ThatEvaluatesTo(1111), + MockExpression.ThatEvaluatesTo(0001), new Context(ExpressiveOptions.None)); Assert.AreEqual(1110, expression.Evaluate(null)); diff --git a/Source/Expressive.Tests/Expressions/Binary/Bitwise/BitwiseOrExpressionTests.cs b/Source/Expressive.Tests/Expressions/Binary/Bitwise/BitwiseOrExpressionTests.cs index f357cbb..02e369a 100644 --- a/Source/Expressive.Tests/Expressions/Binary/Bitwise/BitwiseOrExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/Binary/Bitwise/BitwiseOrExpressionTests.cs @@ -1,20 +1,17 @@ -using System.Collections.Generic; -using Expressive.Expressions; -using Expressive.Expressions.Binary.Bitwise; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; +using Expressive.Expressions.Binary.Bitwise; +using NUnit.Framework; namespace Expressive.Tests.Expressions.Binary.Bitwise { - [TestClass] + [TestFixture] public class BitwiseOrExpressionTests { - [TestMethod] + [Test] public void TestEvaluate() { var expression = new BitwiseOrExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)1001), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)0001), + MockExpression.ThatEvaluatesTo(1001), + MockExpression.ThatEvaluatesTo(0001), new Context(ExpressiveOptions.None)); Assert.AreEqual(1001, expression.Evaluate(null)); diff --git a/Source/Expressive.Tests/Expressions/Binary/Bitwise/LeftShiftExpressionTests.cs b/Source/Expressive.Tests/Expressions/Binary/Bitwise/LeftShiftExpressionTests.cs index 424817f..a042f5e 100644 --- a/Source/Expressive.Tests/Expressions/Binary/Bitwise/LeftShiftExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/Binary/Bitwise/LeftShiftExpressionTests.cs @@ -1,20 +1,17 @@ -using System.Collections.Generic; -using Expressive.Expressions; -using Expressive.Expressions.Binary.Bitwise; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; +using Expressive.Expressions.Binary.Bitwise; +using NUnit.Framework; namespace Expressive.Tests.Expressions.Binary.Bitwise { - [TestClass] + [TestFixture] public class LeftShiftExpressionTests { - [TestMethod] + [Test] public void TestEvaluate() { var expression = new LeftShiftExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)0x1001), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)0x0001), + MockExpression.ThatEvaluatesTo(0x1001), + MockExpression.ThatEvaluatesTo(0x0001), new Context(ExpressiveOptions.None)); Assert.AreEqual(0x1001 << 0x0001, expression.Evaluate(null)); diff --git a/Source/Expressive.Tests/Expressions/Binary/Bitwise/RightShiftExpressionTests.cs b/Source/Expressive.Tests/Expressions/Binary/Bitwise/RightShiftExpressionTests.cs index a6a79e0..077d191 100644 --- a/Source/Expressive.Tests/Expressions/Binary/Bitwise/RightShiftExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/Binary/Bitwise/RightShiftExpressionTests.cs @@ -1,20 +1,17 @@ -using System.Collections.Generic; -using Expressive.Expressions; -using Expressive.Expressions.Binary.Bitwise; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; +using Expressive.Expressions.Binary.Bitwise; +using NUnit.Framework; namespace Expressive.Tests.Expressions.Binary.Bitwise { - [TestClass] + [TestFixture] public class RightShiftExpressionTests { - [TestMethod] + [Test] public void TestEvaluate() { var expression = new RightShiftExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)0x1001), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)0x0001), + MockExpression.ThatEvaluatesTo(0x1001), + MockExpression.ThatEvaluatesTo(0x0001), new Context(ExpressiveOptions.None)); Assert.AreEqual(0x1001 >> 0x0001, expression.Evaluate(null)); diff --git a/Source/Expressive.Tests/Expressions/Binary/Conditional/NullCoalescingExpressionTests.cs b/Source/Expressive.Tests/Expressions/Binary/Conditional/NullCoalescingExpressionTests.cs index 0d49b1c..f06f64e 100644 --- a/Source/Expressive.Tests/Expressions/Binary/Conditional/NullCoalescingExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/Binary/Conditional/NullCoalescingExpressionTests.cs @@ -1,31 +1,31 @@ using System.Collections.Generic; using Expressive.Expressions; using Expressive.Expressions.Binary.Conditional; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; using Moq; namespace Expressive.Tests.Expressions.Binary.Conditional { - [TestClass] + [TestFixture] public class NullCoalescingExpressionTests { - [TestMethod] + [Test] public void TestNotNullEvaluate() { var expression = new NullCoalescingExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)"Non null"), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)"Never used"), + MockExpression.ThatEvaluatesTo("Non null"), + MockExpression.ThatEvaluatesTo("Never used"), new Context(ExpressiveOptions.None)); Assert.AreEqual("Non null", expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestNullEvaluate() { var expression = new NullCoalescingExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)null), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)"Now used"), + MockExpression.ThatEvaluatesTo(null), + MockExpression.ThatEvaluatesTo("Now used"), new Context(ExpressiveOptions.None)); Assert.AreEqual("Now used", expression.Evaluate(null)); diff --git a/Source/Expressive.Tests/Expressions/Binary/Logical/AndExpressionTests.cs b/Source/Expressive.Tests/Expressions/Binary/Logical/AndExpressionTests.cs index c7eb9d0..f7c8a02 100644 --- a/Source/Expressive.Tests/Expressions/Binary/Logical/AndExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/Binary/Logical/AndExpressionTests.cs @@ -1,65 +1,65 @@ using System.Collections.Generic; using Expressive.Expressions; using Expressive.Expressions.Binary.Logical; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; using Moq; namespace Expressive.Tests.Expressions.Binary.Logical { - [TestClass] + [TestFixture] public class AndExpressionTests { - [TestMethod] + [Test] public void TestBothTrueEvaluate() { var expression = new AndExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object) true), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object) true), + MockExpression.ThatEvaluatesTo(true), + MockExpression.ThatEvaluatesTo(true), new Context(ExpressiveOptions.None)); Assert.AreEqual(true, expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestLeftTrueEvaluate() { var expression = new AndExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object) true), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object) false), + MockExpression.ThatEvaluatesTo(true), + MockExpression.ThatEvaluatesTo(false), new Context(ExpressiveOptions.None)); Assert.AreEqual(false, expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestNeitherTrueEvaluate() { var expression = new AndExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object) false), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object) false), + MockExpression.ThatEvaluatesTo(false), + MockExpression.ThatEvaluatesTo(false), new Context(ExpressiveOptions.None)); Assert.AreEqual(false, expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestRightTrueEvaluate() { var expression = new AndExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object) false), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object) true), + MockExpression.ThatEvaluatesTo(false), + MockExpression.ThatEvaluatesTo(true), new Context(ExpressiveOptions.None)); Assert.AreEqual(false, expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestShortCircuit() { var rightHandMock = new Mock(); var expression = new AndExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)false), + MockExpression.ThatEvaluatesTo(false), rightHandMock.Object, new Context(ExpressiveOptions.None)); diff --git a/Source/Expressive.Tests/Expressions/Binary/Logical/OrExpressionTests.cs b/Source/Expressive.Tests/Expressions/Binary/Logical/OrExpressionTests.cs index a76f83b..9699be7 100644 --- a/Source/Expressive.Tests/Expressions/Binary/Logical/OrExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/Binary/Logical/OrExpressionTests.cs @@ -1,65 +1,65 @@ using System.Collections.Generic; using Expressive.Expressions; using Expressive.Expressions.Binary.Logical; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; using Moq; namespace Expressive.Tests.Expressions.Binary.Logical { - [TestClass] + [TestFixture] public class OrExpressionTests { - [TestMethod] + [Test] public void TestBothTrueEvaluate() { var expression = new OrExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)true), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)true), + MockExpression.ThatEvaluatesTo(true), + MockExpression.ThatEvaluatesTo(true), new Context(ExpressiveOptions.None)); Assert.AreEqual(true, expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestLeftTrueEvaluate() { var expression = new OrExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)true), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)false), + MockExpression.ThatEvaluatesTo(true), + MockExpression.ThatEvaluatesTo(false), new Context(ExpressiveOptions.None)); Assert.AreEqual(true, expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestNeitherTrueEvaluate() { var expression = new OrExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)false), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)false), + MockExpression.ThatEvaluatesTo(false), + MockExpression.ThatEvaluatesTo(false), new Context(ExpressiveOptions.None)); Assert.AreEqual(false, expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestRightTrueEvaluate() { var expression = new OrExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)false), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)true), + MockExpression.ThatEvaluatesTo(false), + MockExpression.ThatEvaluatesTo(true), new Context(ExpressiveOptions.None)); Assert.AreEqual(true, expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestShortCircuit() { var rightHandMock = new Mock(); var expression = new OrExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)true), + MockExpression.ThatEvaluatesTo(true), rightHandMock.Object, new Context(ExpressiveOptions.None)); diff --git a/Source/Expressive.Tests/Expressions/Binary/Multiplicative/DivideExpressionTests.cs b/Source/Expressive.Tests/Expressions/Binary/Multiplicative/DivideExpressionTests.cs index acdcd3c..5d18026 100644 --- a/Source/Expressive.Tests/Expressions/Binary/Multiplicative/DivideExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/Binary/Multiplicative/DivideExpressionTests.cs @@ -1,20 +1,17 @@ -using System.Collections.Generic; -using Expressive.Expressions; -using Expressive.Expressions.Binary.Multiplicative; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; +using Expressive.Expressions.Binary.Multiplicative; +using NUnit.Framework; namespace Expressive.Tests.Expressions.Binary.Multiplicative { - [TestClass] + [TestFixture] public class DivideExpressionTests { - [TestMethod] + [Test] public void TestEvaluate() { var expression = new DivideExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)1), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)1), + MockExpression.ThatEvaluatesTo(1), + MockExpression.ThatEvaluatesTo(1), new Context(ExpressiveOptions.None)); Assert.AreEqual(1d, expression.Evaluate(null)); diff --git a/Source/Expressive.Tests/Expressions/Binary/Multiplicative/ModulusExpressionTests.cs b/Source/Expressive.Tests/Expressions/Binary/Multiplicative/ModulusExpressionTests.cs index 758d1b3..300b18a 100644 --- a/Source/Expressive.Tests/Expressions/Binary/Multiplicative/ModulusExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/Binary/Multiplicative/ModulusExpressionTests.cs @@ -1,20 +1,17 @@ -using System.Collections.Generic; -using Expressive.Expressions; -using Expressive.Expressions.Binary.Multiplicative; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; +using Expressive.Expressions.Binary.Multiplicative; +using NUnit.Framework; namespace Expressive.Tests.Expressions.Binary.Multiplicative { - [TestClass] + [TestFixture] public class ModulusExpressionTests { - [TestMethod] + [Test] public void TestEvaluate() { var expression = new ModulusExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)5), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)2), + MockExpression.ThatEvaluatesTo(5), + MockExpression.ThatEvaluatesTo(2), new Context(ExpressiveOptions.None)); Assert.AreEqual(1, expression.Evaluate(null)); diff --git a/Source/Expressive.Tests/Expressions/Binary/Multiplicative/MultiplyExpressionTests.cs b/Source/Expressive.Tests/Expressions/Binary/Multiplicative/MultiplyExpressionTests.cs index f518fb4..9ecc4a2 100644 --- a/Source/Expressive.Tests/Expressions/Binary/Multiplicative/MultiplyExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/Binary/Multiplicative/MultiplyExpressionTests.cs @@ -1,20 +1,17 @@ -using System.Collections.Generic; -using Expressive.Expressions; -using Expressive.Expressions.Binary.Multiplicative; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; +using Expressive.Expressions.Binary.Multiplicative; +using NUnit.Framework; namespace Expressive.Tests.Expressions.Binary.Multiplicative { - [TestClass] + [TestFixture] public class MultiplyExpressionTests { - [TestMethod] + [Test] public void TestEvaluate() { var expression = new MultiplyExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)5), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)2), + MockExpression.ThatEvaluatesTo(5), + MockExpression.ThatEvaluatesTo(2), new Context(ExpressiveOptions.None)); Assert.AreEqual(10, expression.Evaluate(null)); diff --git a/Source/Expressive.Tests/Expressions/Binary/Relational/EqualExpressionTests.cs b/Source/Expressive.Tests/Expressions/Binary/Relational/EqualExpressionTests.cs index cd43dbb..456906b 100644 --- a/Source/Expressive.Tests/Expressions/Binary/Relational/EqualExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/Binary/Relational/EqualExpressionTests.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using Expressive.Expressions; -using Expressive.Expressions.Binary.Relational; -using Moq; +using Expressive.Expressions.Binary.Relational; using NUnit.Framework; namespace Expressive.Tests.Expressions.Binary.Relational @@ -29,8 +26,8 @@ public static class EqualExpressionTests public static void TestEvaluate(object lhs, object rhs, object expectedValue) { var expression = new EqualExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == lhs), - Mock.Of(e => e.Evaluate(It.IsAny>()) == rhs), + MockExpression.ThatEvaluatesTo(lhs), + MockExpression.ThatEvaluatesTo(rhs), new Context(ExpressiveOptions.None)); Assert.That(expression.Evaluate(null), Is.EqualTo(expectedValue)); diff --git a/Source/Expressive.Tests/Expressions/Binary/Relational/GreaterThanExpressionTests.cs b/Source/Expressive.Tests/Expressions/Binary/Relational/GreaterThanExpressionTests.cs index 5805284..c0121eb 100644 --- a/Source/Expressive.Tests/Expressions/Binary/Relational/GreaterThanExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/Binary/Relational/GreaterThanExpressionTests.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using Expressive.Expressions; -using Expressive.Expressions.Binary.Relational; -using Moq; +using Expressive.Expressions.Binary.Relational; using NUnit.Framework; namespace Expressive.Tests.Expressions.Binary.Relational @@ -29,8 +26,8 @@ public static class GreaterThanExpressionTests public static void TestEvaluate(object lhs, object rhs, object expectedValue) { var expression = new GreaterThanExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == lhs), - Mock.Of(e => e.Evaluate(It.IsAny>()) == rhs), + MockExpression.ThatEvaluatesTo(lhs), + MockExpression.ThatEvaluatesTo(rhs), new Context(ExpressiveOptions.None)); Assert.That(expression.Evaluate(null), Is.EqualTo(expectedValue)); diff --git a/Source/Expressive.Tests/Expressions/Binary/Relational/GreaterThanOrEqualExpressionTests.cs b/Source/Expressive.Tests/Expressions/Binary/Relational/GreaterThanOrEqualExpressionTests.cs index 0bfaaf3..f787d78 100644 --- a/Source/Expressive.Tests/Expressions/Binary/Relational/GreaterThanOrEqualExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/Binary/Relational/GreaterThanOrEqualExpressionTests.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using Expressive.Expressions; -using Expressive.Expressions.Binary.Relational; -using Moq; +using Expressive.Expressions.Binary.Relational; using NUnit.Framework; namespace Expressive.Tests.Expressions.Binary.Relational @@ -29,8 +26,8 @@ public static class GreaterThanOrEqualExpressionTests public static void TestEvaluate(object lhs, object rhs, object expectedValue) { var expression = new GreaterThanOrEqualExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == lhs), - Mock.Of(e => e.Evaluate(It.IsAny>()) == rhs), + MockExpression.ThatEvaluatesTo(lhs), + MockExpression.ThatEvaluatesTo(rhs), new Context(ExpressiveOptions.None)); Assert.That(expression.Evaluate(null), Is.EqualTo(expectedValue)); diff --git a/Source/Expressive.Tests/Expressions/Binary/Relational/LessThanExpressionTests.cs b/Source/Expressive.Tests/Expressions/Binary/Relational/LessThanExpressionTests.cs index dbf874f..592b21f 100644 --- a/Source/Expressive.Tests/Expressions/Binary/Relational/LessThanExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/Binary/Relational/LessThanExpressionTests.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using Expressive.Expressions; -using Expressive.Expressions.Binary.Relational; -using Moq; +using Expressive.Expressions.Binary.Relational; using NUnit.Framework; namespace Expressive.Tests.Expressions.Binary.Relational @@ -29,8 +26,8 @@ public static class LessThanExpressionTests public static void TestEvaluate(object lhs, object rhs, object expectedValue) { var expression = new LessThanExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == lhs), - Mock.Of(e => e.Evaluate(It.IsAny>()) == rhs), + MockExpression.ThatEvaluatesTo(lhs), + MockExpression.ThatEvaluatesTo(rhs), new Context(ExpressiveOptions.None)); Assert.That(expression.Evaluate(null), Is.EqualTo(expectedValue)); diff --git a/Source/Expressive.Tests/Expressions/Binary/Relational/LessThanOrEqualExpressionTests.cs b/Source/Expressive.Tests/Expressions/Binary/Relational/LessThanOrEqualExpressionTests.cs index 7a73ce7..e9b8f1c 100644 --- a/Source/Expressive.Tests/Expressions/Binary/Relational/LessThanOrEqualExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/Binary/Relational/LessThanOrEqualExpressionTests.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using Expressive.Expressions; -using Expressive.Expressions.Binary.Relational; -using Moq; +using Expressive.Expressions.Binary.Relational; using NUnit.Framework; namespace Expressive.Tests.Expressions.Binary.Relational @@ -29,8 +26,8 @@ public static class LessThanOrEqualExpressionTests public static void TestEvaluate(object lhs, object rhs, object expectedValue) { var expression = new LessThanOrEqualExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == lhs), - Mock.Of(e => e.Evaluate(It.IsAny>()) == rhs), + MockExpression.ThatEvaluatesTo(lhs), + MockExpression.ThatEvaluatesTo(rhs), new Context(ExpressiveOptions.None)); Assert.That(expression.Evaluate(null), Is.EqualTo(expectedValue)); diff --git a/Source/Expressive.Tests/Expressions/Binary/Relational/NotEqualExpressionTests.cs b/Source/Expressive.Tests/Expressions/Binary/Relational/NotEqualExpressionTests.cs index 811b5d8..2eaa3fe 100644 --- a/Source/Expressive.Tests/Expressions/Binary/Relational/NotEqualExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/Binary/Relational/NotEqualExpressionTests.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using Expressive.Expressions; -using Expressive.Expressions.Binary.Relational; -using Moq; +using Expressive.Expressions.Binary.Relational; using NUnit.Framework; namespace Expressive.Tests.Expressions.Binary.Relational @@ -29,8 +26,8 @@ public static class NotEqualExpressionTests public static void TestEvaluate(object lhs, object rhs, object expectedValue) { var expression = new NotEqualExpression( - Mock.Of(e => e.Evaluate(It.IsAny>()) == lhs), - Mock.Of(e => e.Evaluate(It.IsAny>()) == rhs), + MockExpression.ThatEvaluatesTo(lhs), + MockExpression.ThatEvaluatesTo(rhs), new Context(ExpressiveOptions.None)); Assert.That(expression.Evaluate(null), Is.EqualTo(expectedValue)); diff --git a/Source/Expressive.Tests/Expressions/ConstantValueExpressionTests.cs b/Source/Expressive.Tests/Expressions/ConstantValueExpressionTests.cs index d6da6e3..8630c85 100644 --- a/Source/Expressive.Tests/Expressions/ConstantValueExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/ConstantValueExpressionTests.cs @@ -1,13 +1,13 @@ using System; using Expressive.Expressions; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Expressions { - [TestClass] + [TestFixture] public class ConstantValueExpressionTests { - [TestMethod] + [Test] public void TestBooleanValue() { var constantValueExpression = new ConstantValueExpression(true); @@ -15,7 +15,7 @@ public void TestBooleanValue() Assert.AreEqual(true, constantValueExpression.Evaluate(null)); } - [TestMethod] + [Test] public void TestDateTimeValue() { var now = DateTime.Now; @@ -25,7 +25,7 @@ public void TestDateTimeValue() Assert.AreEqual(now, constantValueExpression.Evaluate(null)); } - [TestMethod] + [Test] public void TestDecimalValue() { var constantValueExpression = new ConstantValueExpression(123M); @@ -33,7 +33,7 @@ public void TestDecimalValue() Assert.AreEqual(123M, constantValueExpression.Evaluate(null)); } - [TestMethod] + [Test] public void TestDoubleValue() { var constantValueExpression = new ConstantValueExpression(123d); @@ -41,7 +41,7 @@ public void TestDoubleValue() Assert.AreEqual(123d, constantValueExpression.Evaluate(null)); } - [TestMethod] + [Test] public void TestIntegerValue() { var constantValueExpression = new ConstantValueExpression(123); @@ -49,7 +49,7 @@ public void TestIntegerValue() Assert.AreEqual(123, constantValueExpression.Evaluate(null)); } - [TestMethod] + [Test] public void TestLongValue() { var constantValueExpression = new ConstantValueExpression(123L); @@ -57,7 +57,7 @@ public void TestLongValue() Assert.AreEqual(123L, constantValueExpression.Evaluate(null)); } - [TestMethod] + [Test] public void TestStringValue() { var constantValueExpression = new ConstantValueExpression("123"); @@ -65,7 +65,7 @@ public void TestStringValue() Assert.AreEqual("123", constantValueExpression.Evaluate(null)); } - [TestMethod] + [Test] public void TestUnsupportedValue() { var unsupportedValue = new {Name = "Shaun", Age = 99}; diff --git a/Source/Expressive.Tests/Expressions/FunctionExpressionTests.cs b/Source/Expressive.Tests/Expressions/FunctionExpressionTests.cs index 23203dc..29b7a34 100644 --- a/Source/Expressive.Tests/Expressions/FunctionExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/FunctionExpressionTests.cs @@ -1,20 +1,20 @@ -using System.Collections.Generic; + using Expressive.Expressions; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; +using NUnit.Framework; +using System; namespace Expressive.Tests.Expressions { - [TestClass] + [TestFixture] public class FunctionExpressionTests { - [TestMethod] + [Test] public void TestEvaluate() { var expression = new FunctionExpression( "testFunc", (p,a) => 123, - new []{ Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)1) }); + Array.Empty()); Assert.AreEqual(123, expression.Evaluate(null)); } diff --git a/Source/Expressive.Tests/Expressions/ParenthesisedExpressionTests.cs b/Source/Expressive.Tests/Expressions/ParenthesisedExpressionTests.cs index 62ceed0..1a4b0d1 100644 --- a/Source/Expressive.Tests/Expressions/ParenthesisedExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/ParenthesisedExpressionTests.cs @@ -1,30 +1,26 @@ -using System.Collections.Generic; -using Expressive.Exceptions; +using Expressive.Exceptions; using Expressive.Expressions; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; +using NUnit.Framework; namespace Expressive.Tests.Expressions { - [TestClass] + [TestFixture] public class ParenthesisedExpressionTests { - [TestMethod] + [Test] public void TestEvaluate() { - var mockExpression = Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)1); - - var expression = new ParenthesisedExpression(mockExpression); + var expression = new ParenthesisedExpression(MockExpression.ThatEvaluatesTo(1)); Assert.AreEqual(1, expression.Evaluate(null)); } - [TestMethod, ExpectedException(typeof(MissingParticipantException), "Missing contents inside ().")] + [Test] public void TestNullEvaluate() { var expression = new ParenthesisedExpression(null); - Assert.AreEqual(1, expression.Evaluate(null)); + Assert.That(() => expression.Evaluate(null), Throws.InstanceOf()); } } } diff --git a/Source/Expressive.Tests/Expressions/Unary/Additive/MinusExpressionTests.cs b/Source/Expressive.Tests/Expressions/Unary/Additive/MinusExpressionTests.cs index e9412a9..a24e650 100644 --- a/Source/Expressive.Tests/Expressions/Unary/Additive/MinusExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/Unary/Additive/MinusExpressionTests.cs @@ -1,65 +1,56 @@ using System; -using System.Collections.Generic; -using Expressive.Expressions; using Expressive.Expressions.Unary.Additive; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; +using NUnit.Framework; namespace Expressive.Tests.Expressions.Unary.Additive { - [TestClass] + [TestFixture] public class MinusExpressionTests { - [TestMethod] + [Test] public void TestNull() { - var expression = new MinusExpression(Mock.Of(e => - e.Evaluate(It.IsAny>()) == (object)null)); + var expression = new MinusExpression(MockExpression.ThatEvaluatesTo(null)); Assert.IsNull(expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestInteger() { - var expression = new MinusExpression(Mock.Of(e => - e.Evaluate(It.IsAny>()) == (object)12)); + var expression = new MinusExpression(MockExpression.ThatEvaluatesTo(12)); Assert.AreEqual(-12, expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestDouble() { - var expression = new MinusExpression(Mock.Of(e => - e.Evaluate(It.IsAny>()) == (object)13.5d)); + var expression = new MinusExpression(MockExpression.ThatEvaluatesTo(13.5d)); Assert.AreEqual(-13.5d, expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestDecimal() { - var expression = new MinusExpression(Mock.Of(e => - e.Evaluate(It.IsAny>()) == (object)12.4M)); + var expression = new MinusExpression(MockExpression.ThatEvaluatesTo(12.4M)); Assert.AreEqual(-12.4M, expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestString() { - var expression = new MinusExpression(Mock.Of(e => - e.Evaluate(It.IsAny>()) == (object)"12")); + var expression = new MinusExpression(MockExpression.ThatEvaluatesTo("12")); Assert.AreEqual(-12M, expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestInvalid() { - var expression = new MinusExpression(Mock.Of(e => - e.Evaluate(It.IsAny>()) == (object)DateTime.Now)); + var expression = new MinusExpression(MockExpression.ThatEvaluatesTo(DateTime.Now)); Assert.IsNull(expression.Evaluate(null)); } diff --git a/Source/Expressive.Tests/Expressions/Unary/Additive/PlusExpressionTests.cs b/Source/Expressive.Tests/Expressions/Unary/Additive/PlusExpressionTests.cs index d9ef241..41b24ba 100644 --- a/Source/Expressive.Tests/Expressions/Unary/Additive/PlusExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/Unary/Additive/PlusExpressionTests.cs @@ -1,65 +1,56 @@ using System; -using System.Collections.Generic; -using Expressive.Expressions; using Expressive.Expressions.Unary.Additive; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; +using NUnit.Framework; namespace Expressive.Tests.Expressions.Unary.Additive { - [TestClass] + [TestFixture] public class PlusExpressionTests { - [TestMethod] + [Test] public void TestNull() { - var expression = new PlusExpression(Mock.Of(e => - e.Evaluate(It.IsAny>()) == (object) null)); + var expression = new PlusExpression(MockExpression.ThatEvaluatesTo(null)); Assert.IsNull(expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestInteger() { - var expression = new PlusExpression(Mock.Of(e => - e.Evaluate(It.IsAny>()) == (object) 12)); + var expression = new PlusExpression(MockExpression.ThatEvaluatesTo(12)); Assert.AreEqual(12, expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestDouble() { - var expression = new PlusExpression(Mock.Of(e => - e.Evaluate(It.IsAny>()) == (object) 13.5d)); + var expression = new PlusExpression(MockExpression.ThatEvaluatesTo(13.5d)); Assert.AreEqual(13.5d, expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestDecimal() { - var expression = new PlusExpression(Mock.Of(e => - e.Evaluate(It.IsAny>()) == (object) 12.4M)); + var expression = new PlusExpression(MockExpression.ThatEvaluatesTo(12.4M)); Assert.AreEqual(12.4M, expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestString() { - var expression = new PlusExpression(Mock.Of(e => - e.Evaluate(It.IsAny>()) == (object) "12")); + var expression = new PlusExpression(MockExpression.ThatEvaluatesTo("12")); Assert.AreEqual(12M, expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestInvalid() { - var expression = new PlusExpression(Mock.Of(e => - e.Evaluate(It.IsAny>()) == (object) DateTime.Now)); + var expression = new PlusExpression(MockExpression.ThatEvaluatesTo(DateTime.Now)); Assert.IsNull(expression.Evaluate(null)); } diff --git a/Source/Expressive.Tests/Expressions/Unary/Logical/NotExpressionTests.cs b/Source/Expressive.Tests/Expressions/Unary/Logical/NotExpressionTests.cs index 14c1ee9..da46129 100644 --- a/Source/Expressive.Tests/Expressions/Unary/Logical/NotExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/Unary/Logical/NotExpressionTests.cs @@ -2,57 +2,52 @@ using System.Collections.Generic; using Expressive.Expressions; using Expressive.Expressions.Unary.Logical; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; using Moq; namespace Expressive.Tests.Expressions.Unary.Logical { - [TestClass] + [TestFixture] public class NotExpressionTests { - [TestMethod] + [Test] public void TestNull() { - var expression = new NotExpression(Mock.Of(e => - e.Evaluate(It.IsAny>()) == (object) null)); + var expression = new NotExpression(MockExpression.ThatEvaluatesTo(null)); Assert.IsNull(expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestFalse() { - var expression = new NotExpression(Mock.Of(e => - e.Evaluate(It.IsAny>()) == (object)false)); + var expression = new NotExpression(MockExpression.ThatEvaluatesTo(false)); Assert.IsTrue((bool)expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestTrue() { - var expression = new NotExpression(Mock.Of(e => - e.Evaluate(It.IsAny>()) == (object)true)); + var expression = new NotExpression(MockExpression.ThatEvaluatesTo(true)); Assert.IsFalse((bool)expression.Evaluate(null)); } - [TestMethod] + [Test] public void TestInteger() { - var expression = new NotExpression(Mock.Of(e => - e.Evaluate(It.IsAny>()) == (object)1)); + var expression = new NotExpression(MockExpression.ThatEvaluatesTo(1)); Assert.IsFalse((bool)expression.Evaluate(null)); } - [TestMethod, ExpectedException(typeof(InvalidCastException))] + [Test] public void TestInvalid() { - var expression = new NotExpression(Mock.Of(e => - e.Evaluate(It.IsAny>()) == (object)DateTime.Now)); + var expression = new NotExpression(MockExpression.ThatEvaluatesTo(DateTime.Now)); - Assert.IsFalse((bool)expression.Evaluate(null)); + Assert.That(() => expression.Evaluate(null), Throws.InstanceOf()); } } } diff --git a/Source/Expressive.Tests/Expressions/VariableExpressionTests.cs b/Source/Expressive.Tests/Expressions/VariableExpressionTests.cs index a6e6480..e9dc051 100644 --- a/Source/Expressive.Tests/Expressions/VariableExpressionTests.cs +++ b/Source/Expressive.Tests/Expressions/VariableExpressionTests.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using Expressive.Expressions; -using Moq; using NUnit.Framework; using Assert = NUnit.Framework.Assert; @@ -14,7 +13,7 @@ public static void TestWithExpressionVariableSupplied() { var expression = new VariableExpression("pi"); - var variable = Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)Math.PI); + var variable = MockExpression.ThatEvaluatesTo(Math.PI); Assert.That( expression.Evaluate(new Dictionary { ["pi"] = variable }), diff --git a/Source/Expressive.Tests/Expressive.Tests.csproj b/Source/Expressive.Tests/Expressive.Tests.csproj index 5789ea3..65e72ef 100644 --- a/Source/Expressive.Tests/Expressive.Tests.csproj +++ b/Source/Expressive.Tests/Expressive.Tests.csproj @@ -27,8 +27,6 @@ - - all diff --git a/Source/Expressive.Tests/Functions/Conversion/DateFunctionTests.cs b/Source/Expressive.Tests/Functions/Conversion/DateFunctionTests.cs index e5152b1..56d8b29 100644 --- a/Source/Expressive.Tests/Functions/Conversion/DateFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Conversion/DateFunctionTests.cs @@ -1,24 +1,21 @@ using System; -using System.Collections.Generic; using Expressive.Exceptions; -using Expressive.Expressions; using Expressive.Functions; using Expressive.Functions.Conversion; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; +using NUnit.Framework; namespace Expressive.Tests.Functions.Conversion { - [TestClass] + [TestFixture] public class DateFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("Date", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestEvaluateWithDateTime() { object dateTimeNow = DateTime.Now; @@ -27,49 +24,49 @@ public void TestEvaluateWithDateTime() Assert.AreEqual(dateTimeNow, this.Evaluate(dateTimeNow)); } - [TestMethod, ExpectedException(typeof(InvalidCastException))] + [Test] public void TestEvaluateWithDouble() { - this.Evaluate(12345d); + Assert.That(() => this.Evaluate(12345d), Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(InvalidCastException))] + [Test] public void TestEvaluateWithFloat() { - this.Evaluate(12345f); + Assert.That(() => this.Evaluate(12345f), Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(InvalidCastException))] + [Test] public void TestEvaluateWithInteger() { - this.Evaluate(12345); + Assert.That(() => this.Evaluate(12345), Throws.InstanceOf()); } - [TestMethod, ExpectedException(typeof(InvalidCastException))] + [Test] public void TestEvaluateWithLong() { - this.Evaluate(12345L); + Assert.That(() => this.Evaluate(12345L), Throws.InstanceOf()); } - [TestMethod] + [Test] public void TestEvaluateWithNull() { Assert.IsNull(this.Evaluate(new object[] {null})); } - [TestMethod] + [Test] public void TestEvaluateWithValidString() { Assert.AreEqual(new DateTime(2019, 01, 01), this.Evaluate("2019/01/01")); } - [TestMethod, ExpectedException(typeof(FormatException))] + [Test] public void TestEvaluateWithInvalidString() { - this.Evaluate("20cb/01/01"); + Assert.That(() => this.Evaluate("20cb/01/01"), Throws.InstanceOf()); } - [TestMethod] + [Test] public void TestEvaluateWithValidStringAndValidFormat() { const string dateString = "2019/01/01 11:00:00"; @@ -78,16 +75,16 @@ public void TestEvaluateWithValidStringAndValidFormat() Assert.AreEqual(new DateTime(2019, 01, 01, 11, 00, 00), this.Evaluate(dateString, format)); } - [TestMethod, ExpectedException(typeof(FormatException))] + [Test] public void TestEvaluateWithValidStringAndInvalidFormat() { const string dateString = "2019/01/01 11:00:00"; const string format = "yyyy/MM/dd"; // Not entirely convinced that this should throw an error but DateTime.ParseExact does. - this.Evaluate(dateString, format); + Assert.That(() => this.Evaluate(dateString, format), Throws.InstanceOf()); } - [TestMethod] + [Test] public void TestEvaluateWithValidStringAndNonStringFormat() { const string dateString = "2019/01/01 11:00:00"; @@ -97,7 +94,7 @@ public void TestEvaluateWithValidStringAndNonStringFormat() Assert.AreEqual(new DateTime(2019, 01, 01, 11, 00, 00), this.Evaluate(dateString, format)); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "Date() expects at least 1 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Conversion/DecimalFunctionTests.cs b/Source/Expressive.Tests/Functions/Conversion/DecimalFunctionTests.cs index 1174568..9f16716 100644 --- a/Source/Expressive.Tests/Functions/Conversion/DecimalFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Conversion/DecimalFunctionTests.cs @@ -1,66 +1,63 @@ using System; -using System.Collections.Generic; using Expressive.Exceptions; -using Expressive.Expressions; using Expressive.Functions; using Expressive.Functions.Conversion; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; +using NUnit.Framework; namespace Expressive.Tests.Functions.Conversion { - [TestClass] + [TestFixture] public class DecimalFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("Decimal", this.ActualFunction.Name); } - [TestMethod, ExpectedException(typeof(InvalidCastException))] + [Test] public void TestEvaluateWithDateTime() { - this.Evaluate(DateTime.Now); + Assert.That(() => this.Evaluate(DateTime.Now), Throws.InstanceOf()); } - [TestMethod] + [Test] public void TestEvaluateWithDecimal() { Assert.AreEqual(12345M, this.Evaluate(12345M)); } - [TestMethod] + [Test] public void TestEvaluateWithDouble() { Assert.AreEqual(12345M, this.Evaluate(12345d)); } - [TestMethod] + [Test] public void TestEvaluateWithFloat() { Assert.AreEqual(12345M, this.Evaluate(12345f)); } - [TestMethod] + [Test] public void TestEvaluateWithInteger() { Assert.AreEqual(12345M, this.Evaluate(12345)); } - [TestMethod] + [Test] public void TestEvaluateWithNull() { Assert.IsNull(this.Evaluate(new object[] { null })); } - [TestMethod] + [Test] public void TestEvaluateWithString() { Assert.AreEqual(12345M, this.Evaluate("12345")); } - [TestMethod] + [Test] public void TestEvaluateWithLong() { var function = new DecimalFunction(); @@ -69,14 +66,14 @@ public void TestEvaluateWithLong() var result = function.Evaluate(new[] { - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object)longValue) + MockExpression.ThatEvaluatesTo(longValue) }, new Context(ExpressiveOptions.None)); Assert.AreEqual(12345M, result); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "Decimal() takes only 1 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Conversion/DoubleFunctionTests.cs b/Source/Expressive.Tests/Functions/Conversion/DoubleFunctionTests.cs index 361b153..d3d6441 100644 --- a/Source/Expressive.Tests/Functions/Conversion/DoubleFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Conversion/DoubleFunctionTests.cs @@ -2,68 +2,68 @@ using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Conversion; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Conversion { - [TestClass] + [TestFixture] public class DoubleFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("Double", this.ActualFunction.Name); } - [TestMethod, ExpectedException(typeof(InvalidCastException))] + [Test] public void TestEvaluateWithDateTime() { - this.Evaluate(DateTime.Now); + Assert.That(() => this.Evaluate(DateTime.Now), Throws.InstanceOf()); } - [TestMethod] + [Test] public void TestEvaluateWithDecimal() { Assert.AreEqual(12345d, this.Evaluate(12345M)); } - [TestMethod] + [Test] public void TestEvaluateWithDouble() { Assert.AreEqual(12345d, this.Evaluate(12345d)); } - [TestMethod] + [Test] public void TestEvaluateWithFloat() { Assert.AreEqual(12345d, this.Evaluate(12345f)); } - [TestMethod] + [Test] public void TestEvaluateWithInteger() { Assert.AreEqual(12345d, this.Evaluate(12345)); } - [TestMethod] + [Test] public void TestEvaluateWithLong() { Assert.AreEqual(12345d, this.Evaluate(12345L)); } - [TestMethod] + [Test] public void TestEvaluateWithNull() { Assert.IsNull(this.Evaluate(new object[] { null })); } - [TestMethod] + [Test] public void TestEvaluateWithString() { Assert.AreEqual(12345d, this.Evaluate("12345")); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "Double() takes only 1 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Conversion/IntegerFunctionTests.cs b/Source/Expressive.Tests/Functions/Conversion/IntegerFunctionTests.cs index f3ef526..1bbdea6 100644 --- a/Source/Expressive.Tests/Functions/Conversion/IntegerFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Conversion/IntegerFunctionTests.cs @@ -2,68 +2,68 @@ using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Conversion; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Conversion { - [TestClass] + [TestFixture] public class IntegerFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("Integer", this.ActualFunction.Name); } - [TestMethod, ExpectedException(typeof(InvalidCastException))] + [Test] public void TestEvaluateWithDateTime() { - this.Evaluate(DateTime.Now); + Assert.That(() => this.Evaluate(DateTime.Now), Throws.InstanceOf()); } - [TestMethod] + [Test] public void TestEvaluateWithDecimal() { Assert.AreEqual(12345, this.Evaluate(12345M)); } - [TestMethod] + [Test] public void TestEvaluateWithDouble() { Assert.AreEqual(12345, this.Evaluate(12345d)); } - [TestMethod] + [Test] public void TestEvaluateWithFloat() { Assert.AreEqual(12345, this.Evaluate(12345f)); } - [TestMethod] + [Test] public void TestEvaluateWithInteger() { Assert.AreEqual(12345, this.Evaluate(12345)); } - [TestMethod] + [Test] public void TestEvaluateWithLong() { Assert.AreEqual(12345, this.Evaluate(12345L)); } - [TestMethod] + [Test] public void TestEvaluateWithNull() { Assert.IsNull(this.Evaluate(new object[] { null })); } - [TestMethod] + [Test] public void TestEvaluateWithString() { Assert.AreEqual(12345, this.Evaluate("12345")); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "Integer() takes only 1 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Conversion/LongFunctionTests.cs b/Source/Expressive.Tests/Functions/Conversion/LongFunctionTests.cs index 07a91db..6ddaad5 100644 --- a/Source/Expressive.Tests/Functions/Conversion/LongFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Conversion/LongFunctionTests.cs @@ -1,73 +1,69 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Conversion; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Conversion { - [TestClass] + [TestFixture] public class LongFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("Long", this.ActualFunction.Name); } - [TestMethod, ExpectedException(typeof(InvalidCastException))] + [Test] public void TestEvaluateWithDateTime() { - this.Evaluate(DateTime.Now); + Assert.That(() => this.Evaluate(DateTime.Now), Throws.InstanceOf()); } - [TestMethod] + [Test] public void TestEvaluateWithDecimal() { Assert.AreEqual(12345L, this.Evaluate(12345M)); } - [TestMethod] + [Test] public void TestEvaluateWithDouble() { Assert.AreEqual(12345L, this.Evaluate(12345d)); } - [TestMethod] + [Test] public void TestEvaluateWithFloat() { Assert.AreEqual(12345L, this.Evaluate(12345f)); } - [TestMethod] + [Test] public void TestEvaluateWithInteger() { Assert.AreEqual(12345L, this.Evaluate(12345)); } - [TestMethod] + [Test] public void TestEvaluateWithLong() { Assert.AreEqual(12345L, this.Evaluate(12345L)); } - [TestMethod] + [Test] public void TestEvaluateWithNull() { Assert.IsNull(this.Evaluate(new object[] { null })); } - [TestMethod] + [Test] public void TestEvaluateWithString() { Assert.AreEqual(12345L, this.Evaluate("12345")); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "Long() takes only 1 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Conversion/StringFunctionTests.cs b/Source/Expressive.Tests/Functions/Conversion/StringFunctionTests.cs index d1fbc36..8d2af8b 100644 --- a/Source/Expressive.Tests/Functions/Conversion/StringFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Conversion/StringFunctionTests.cs @@ -4,20 +4,20 @@ using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Conversion; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Conversion { - [TestClass] + [TestFixture] public class StringFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("String", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestEvaluateWithDateTime() { var dateTime = DateTime.Now; @@ -25,7 +25,7 @@ public void TestEvaluateWithDateTime() Assert.AreEqual(dateTime.ToString(CultureInfo.CurrentCulture), this.Evaluate(dateTime)); } - [TestMethod] + [Test] public void TestEvaluateWithDateTimeAndValidFormat() { var dateTime = new DateTime(2019, 01, 01, 11, 00, 00); @@ -35,7 +35,7 @@ public void TestEvaluateWithDateTimeAndValidFormat() Assert.AreEqual(dateString, this.Evaluate(dateTime, format)); } - [TestMethod] + [Test] public void TestEvaluateWithDateTimeAndNonStringFormat() { var currentCulture = Thread.CurrentThread.CurrentCulture; @@ -55,49 +55,49 @@ public void TestEvaluateWithDateTimeAndNonStringFormat() } } - [TestMethod] + [Test] public void TestEvaluateWithDecimal() { Assert.AreEqual("12345", this.Evaluate(12345M)); } - [TestMethod] + [Test] public void TestEvaluateWithDouble() { Assert.AreEqual("12345", this.Evaluate(12345d)); } - [TestMethod] + [Test] public void TestEvaluateWithFloat() { Assert.AreEqual("12345", this.Evaluate(12345f)); } - [TestMethod] + [Test] public void TestEvaluateWithInteger() { Assert.AreEqual("12345", this.Evaluate(12345)); } - [TestMethod] + [Test] public void TestEvaluateWithLong() { Assert.AreEqual("12345", this.Evaluate(12345L)); } - [TestMethod] + [Test] public void TestEvaluateWithNull() { Assert.IsNull(this.Evaluate(new object[] { null })); } - [TestMethod] + [Test] public void TestEvaluateWithString() { Assert.AreEqual("12345", this.Evaluate("12345")); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "String() expects at least 1 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Date/AddDaysFunctionTests.cs b/Source/Expressive.Tests/Functions/Date/AddDaysFunctionTests.cs index 9e48a10..30ba973 100644 --- a/Source/Expressive.Tests/Functions/Date/AddDaysFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Date/AddDaysFunctionTests.cs @@ -2,44 +2,44 @@ using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Date; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Date { - [TestClass] + [TestFixture] public class AddDaysFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("AddDays", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestLeapYear() { Assert.AreEqual(new DateTime(2016, 02, 29), this.Evaluate(new DateTime(2016, 02, 27), 2)); } - [TestMethod] + [Test] public void TestWithBothNull() { Assert.IsNull(this.Evaluate(null, null)); } - [TestMethod] + [Test] public void TestWithFirstNull() { Assert.IsNull(this.Evaluate(null, 123)); } - [TestMethod] + [Test] public void TestWithSecondNull() { Assert.IsNull(this.Evaluate(DateTime.Now, null)); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "AddDays() takes only 2 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Date/AddHoursFunctionTests.cs b/Source/Expressive.Tests/Functions/Date/AddHoursFunctionTests.cs index 6d9ec0a..1196d11 100644 --- a/Source/Expressive.Tests/Functions/Date/AddHoursFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Date/AddHoursFunctionTests.cs @@ -2,45 +2,45 @@ using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Date; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Date { - [TestClass] + [TestFixture] public class AddHoursFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("AddHours", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestLeapYear() { Assert.AreEqual(new DateTime(2016, 02, 29, 01, 00, 00), this.Evaluate(new DateTime(2016, 02, 28, 23, 00, 00), 2)); } - [TestMethod] + [Test] public void TestWithBothNull() { Assert.IsNull(this.Evaluate(null, null)); } - [TestMethod] + [Test] public void TestWithFirstNull() { Assert.IsNull(this.Evaluate(null, 123)); } - [TestMethod] + [Test] public void TestWithSecondNull() { Assert.IsNull(this.Evaluate(DateTime.Now, null)); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "AddHours() takes only 2 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Date/AddMillisecondsFunctionTests.cs b/Source/Expressive.Tests/Functions/Date/AddMillisecondsFunctionTests.cs index 90d67d2..6039870 100644 --- a/Source/Expressive.Tests/Functions/Date/AddMillisecondsFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Date/AddMillisecondsFunctionTests.cs @@ -2,45 +2,45 @@ using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Date; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Date { - [TestClass] + [TestFixture] public class AddMillisecondsFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("AddMilliseconds", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestLeapYear() { Assert.AreEqual(new DateTime(2016, 02, 29, 00, 00, 01), this.Evaluate(new DateTime(2016, 02, 28, 23, 59, 59), 2000)); } - [TestMethod] + [Test] public void TestWithBothNull() { Assert.IsNull(this.Evaluate(null, null)); } - [TestMethod] + [Test] public void TestWithFirstNull() { Assert.IsNull(this.Evaluate(null, 123)); } - [TestMethod] + [Test] public void TestWithSecondNull() { Assert.IsNull(this.Evaluate(DateTime.Now, null)); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "AddMilliseconds() takes only 2 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Date/AddMinutesFunctionTests.cs b/Source/Expressive.Tests/Functions/Date/AddMinutesFunctionTests.cs index 0f3e26f..9fe0904 100644 --- a/Source/Expressive.Tests/Functions/Date/AddMinutesFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Date/AddMinutesFunctionTests.cs @@ -2,45 +2,45 @@ using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Date; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Date { - [TestClass] + [TestFixture] public class AddMinutesFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("AddMinutes", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestLeapYear() { Assert.AreEqual(new DateTime(2016, 02, 29, 00, 01, 00), this.Evaluate(new DateTime(2016, 02, 28, 23, 00, 00), 61)); } - [TestMethod] + [Test] public void TestWithBothNull() { Assert.IsNull(this.Evaluate(null, null)); } - [TestMethod] + [Test] public void TestWithFirstNull() { Assert.IsNull(this.Evaluate(null, 123)); } - [TestMethod] + [Test] public void TestWithSecondNull() { Assert.IsNull(this.Evaluate(DateTime.Now, null)); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "AddMinutes() takes only 2 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Date/AddMonthsFunctionTests.cs b/Source/Expressive.Tests/Functions/Date/AddMonthsFunctionTests.cs index b67d2b3..efc64f4 100644 --- a/Source/Expressive.Tests/Functions/Date/AddMonthsFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Date/AddMonthsFunctionTests.cs @@ -2,45 +2,45 @@ using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Date; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Date { - [TestClass] + [TestFixture] public class AddMonthsFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("AddMonths", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestLeapYear() { Assert.AreEqual(new DateTime(2016, 02, 29, 23, 00, 00), this.Evaluate(new DateTime(2016, 01, 29, 23, 00, 00), 1)); } - [TestMethod] + [Test] public void TestWithBothNull() { Assert.IsNull(this.Evaluate(null, null)); } - [TestMethod] + [Test] public void TestWithFirstNull() { Assert.IsNull(this.Evaluate(null, 123)); } - [TestMethod] + [Test] public void TestWithSecondNull() { Assert.IsNull(this.Evaluate(DateTime.Now, null)); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "AddMonths() takes only 2 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Date/AddSecondsFunctionTests.cs b/Source/Expressive.Tests/Functions/Date/AddSecondsFunctionTests.cs index a2dfe23..9e3561a 100644 --- a/Source/Expressive.Tests/Functions/Date/AddSecondsFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Date/AddSecondsFunctionTests.cs @@ -2,45 +2,45 @@ using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Date; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Date { - [TestClass] + [TestFixture] public class AddSecondsFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("AddSeconds", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestLeapYear() { Assert.AreEqual(new DateTime(2016, 02, 29, 00, 00, 05), this.Evaluate(new DateTime(2016, 02, 28, 23, 59, 40), 25)); } - [TestMethod] + [Test] public void TestWithBothNull() { Assert.IsNull(this.Evaluate(null, null)); } - [TestMethod] + [Test] public void TestWithFirstNull() { Assert.IsNull(this.Evaluate(null, 123)); } - [TestMethod] + [Test] public void TestWithSecondNull() { Assert.IsNull(this.Evaluate(DateTime.Now, null)); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "AddSeconds() takes only 2 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Date/AddYearsFunctionTests.cs b/Source/Expressive.Tests/Functions/Date/AddYearsFunctionTests.cs index 171e338..721a623 100644 --- a/Source/Expressive.Tests/Functions/Date/AddYearsFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Date/AddYearsFunctionTests.cs @@ -2,45 +2,45 @@ using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Date; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Date { - [TestClass] + [TestFixture] public class AddYearsFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("AddYears", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestLeapYear() { Assert.AreEqual(new DateTime(2017, 02, 28, 23, 00, 00), this.Evaluate(new DateTime(2016, 02, 29, 23, 00, 00), 1)); } - [TestMethod] + [Test] public void TestWithBothNull() { Assert.IsNull(this.Evaluate(null, null)); } - [TestMethod] + [Test] public void TestWithFirstNull() { Assert.IsNull(this.Evaluate(null, 123)); } - [TestMethod] + [Test] public void TestWithSecondNull() { Assert.IsNull(this.Evaluate(DateTime.Now, null)); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "AddYears() takes only 2 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Date/DayOfFunctionTests.cs b/Source/Expressive.Tests/Functions/Date/DayOfFunctionTests.cs index 188469b..2b8bdd7 100644 --- a/Source/Expressive.Tests/Functions/Date/DayOfFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Date/DayOfFunctionTests.cs @@ -2,32 +2,32 @@ using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Date; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Date { - [TestClass] + [TestFixture] public class DayOfFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("DayOf", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestWithNull() { Assert.IsNull(this.Evaluate(new object[] { null })); } - [TestMethod] + [Test] public void TestWithDateTime() { Assert.AreEqual(29, this.Evaluate(new DateTime(2016, 02, 29))); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "DayOf() takes only 1 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Date/DaysBetweenFunctionTests.cs b/Source/Expressive.Tests/Functions/Date/DaysBetweenFunctionTests.cs index e9a5aa6..4b6ad62 100644 --- a/Source/Expressive.Tests/Functions/Date/DaysBetweenFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Date/DaysBetweenFunctionTests.cs @@ -2,44 +2,44 @@ using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Date; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Date { - [TestClass] + [TestFixture] public class DaysBetweenFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("DaysBetween", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestValidValues() { Assert.AreEqual(2d, this.Evaluate(new DateTime(2016, 02, 27), new DateTime(2016, 02, 29))); } - [TestMethod] + [Test] public void TestWithBothNull() { Assert.IsNull(this.Evaluate(null, null)); } - [TestMethod] + [Test] public void TestWithFirstNull() { Assert.IsNull(this.Evaluate(null, 123)); } - [TestMethod] + [Test] public void TestWithSecondNull() { Assert.IsNull(this.Evaluate(DateTime.Now, null)); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "DaysBetween() takes only 2 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Date/HourOfFunctionTests.cs b/Source/Expressive.Tests/Functions/Date/HourOfFunctionTests.cs index a593d52..72cbba6 100644 --- a/Source/Expressive.Tests/Functions/Date/HourOfFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Date/HourOfFunctionTests.cs @@ -2,32 +2,32 @@ using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Date; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Date { - [TestClass] + [TestFixture] public class HourOfFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("HourOf", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestWithNull() { Assert.IsNull(this.Evaluate(new object[] { null })); } - [TestMethod] + [Test] public void TestWithDateTime() { Assert.AreEqual(12, this.Evaluate(new DateTime(2016, 02, 29, 12, 00, 00))); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "HourOf() takes only 1 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Date/HoursBetweenFunctionTests.cs b/Source/Expressive.Tests/Functions/Date/HoursBetweenFunctionTests.cs index 73cbe43..31da946 100644 --- a/Source/Expressive.Tests/Functions/Date/HoursBetweenFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Date/HoursBetweenFunctionTests.cs @@ -2,45 +2,45 @@ using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Date; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Date { - [TestClass] + [TestFixture] public class HoursBetweenFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("HoursBetween", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestValidValues() { Assert.AreEqual(48d, this.Evaluate(new DateTime(2016, 02, 27, 12, 00, 00), new DateTime(2016, 02, 29, 12, 00, 00))); } - [TestMethod] + [Test] public void TestWithBothNull() { Assert.IsNull(this.Evaluate(null, null)); } - [TestMethod] + [Test] public void TestWithFirstNull() { Assert.IsNull(this.Evaluate(null, 123)); } - [TestMethod] + [Test] public void TestWithSecondNull() { Assert.IsNull(this.Evaluate(DateTime.Now, null)); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "HoursBetween() takes only 2 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Date/MillisecondOfFunctionTests.cs b/Source/Expressive.Tests/Functions/Date/MillisecondOfFunctionTests.cs index 9de9f74..4e66b0b 100644 --- a/Source/Expressive.Tests/Functions/Date/MillisecondOfFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Date/MillisecondOfFunctionTests.cs @@ -2,32 +2,32 @@ using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Date; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Date { - [TestClass] + [TestFixture] public class MillisecondOfFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("MillisecondOf", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestWithNull() { Assert.IsNull(this.Evaluate(new object[] { null })); } - [TestMethod] + [Test] public void TestWithDateTime() { Assert.AreEqual(500, this.Evaluate(new DateTime(2016, 02, 29).AddMilliseconds(500))); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "MillisecondOf() takes only 1 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Date/MillisecondsBetweenFunctionTests.cs b/Source/Expressive.Tests/Functions/Date/MillisecondsBetweenFunctionTests.cs index 35df2bb..147f72c 100644 --- a/Source/Expressive.Tests/Functions/Date/MillisecondsBetweenFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Date/MillisecondsBetweenFunctionTests.cs @@ -2,20 +2,20 @@ using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Date; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Date { - [TestClass] + [TestFixture] public class MillisecondsBetweenFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("MillisecondsBetween", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestValidValues() { Assert.AreEqual(750d, @@ -23,25 +23,25 @@ public void TestValidValues() new DateTime(2016, 02, 27, 12, 00, 00).AddMilliseconds(750))); } - [TestMethod] + [Test] public void TestWithBothNull() { Assert.IsNull(this.Evaluate(null, null)); } - [TestMethod] + [Test] public void TestWithFirstNull() { Assert.IsNull(this.Evaluate(null, 123)); } - [TestMethod] + [Test] public void TestWithSecondNull() { Assert.IsNull(this.Evaluate(DateTime.Now, null)); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "MillisecondsBetween() takes only 2 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Date/MinuteOfFunctionTests.cs b/Source/Expressive.Tests/Functions/Date/MinuteOfFunctionTests.cs index 5d90358..a1db1e5 100644 --- a/Source/Expressive.Tests/Functions/Date/MinuteOfFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Date/MinuteOfFunctionTests.cs @@ -2,32 +2,32 @@ using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Date; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Date { - [TestClass] + [TestFixture] public class MinuteOfFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("MinuteOf", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestWithNull() { Assert.IsNull(this.Evaluate(new object[] { null })); } - [TestMethod] + [Test] public void TestWithDateTime() { Assert.AreEqual(34, this.Evaluate(new DateTime(2016, 02, 29, 12, 34, 00))); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "MinuteOf() takes only 1 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Date/MinutesBetweenFunctionTests.cs b/Source/Expressive.Tests/Functions/Date/MinutesBetweenFunctionTests.cs index 8ebec0d..1a9b41a 100644 --- a/Source/Expressive.Tests/Functions/Date/MinutesBetweenFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Date/MinutesBetweenFunctionTests.cs @@ -6,45 +6,45 @@ using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Date; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Date { - [TestClass] + [TestFixture] public class MinutesBetweenFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("MinutesBetween", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestValidValues() { Assert.AreEqual(2880d, this.Evaluate(new DateTime(2016, 02, 27, 12, 00, 00), new DateTime(2016, 02, 29, 12, 00, 00))); } - [TestMethod] + [Test] public void TestWithBothNull() { Assert.IsNull(this.Evaluate(null, null)); } - [TestMethod] + [Test] public void TestWithFirstNull() { Assert.IsNull(this.Evaluate(null, 123)); } - [TestMethod] + [Test] public void TestWithSecondNull() { Assert.IsNull(this.Evaluate(DateTime.Now, null)); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "MinutesBetween() takes only 2 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Date/MonthOfFunctionTests.cs b/Source/Expressive.Tests/Functions/Date/MonthOfFunctionTests.cs index f05b687..554fe56 100644 --- a/Source/Expressive.Tests/Functions/Date/MonthOfFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Date/MonthOfFunctionTests.cs @@ -2,32 +2,32 @@ using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Date; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Date { - [TestClass] + [TestFixture] public class MonthOfFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("MonthOf", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestWithNull() { Assert.IsNull(this.Evaluate(new object[] { null })); } - [TestMethod] + [Test] public void TestWithDateTime() { Assert.AreEqual(2, this.Evaluate(new DateTime(2016, 02, 29))); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "MonthOf() takes only 1 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Date/SecondOfFunctionTests.cs b/Source/Expressive.Tests/Functions/Date/SecondOfFunctionTests.cs index a865057..e06817b 100644 --- a/Source/Expressive.Tests/Functions/Date/SecondOfFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Date/SecondOfFunctionTests.cs @@ -2,32 +2,32 @@ using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Date; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Date { - [TestClass] + [TestFixture] public class SecondOfFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("SecondOf", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestWithNull() { Assert.IsNull(this.Evaluate(new object[] { null })); } - [TestMethod] + [Test] public void TestWithDateTime() { Assert.AreEqual(29, this.Evaluate(new DateTime(2016, 02, 29, 15, 00, 29))); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "SecondOf() takes only 1 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Date/SecondsBetweenFunctionTests.cs b/Source/Expressive.Tests/Functions/Date/SecondsBetweenFunctionTests.cs index 2a6b42c..d785279 100644 --- a/Source/Expressive.Tests/Functions/Date/SecondsBetweenFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Date/SecondsBetweenFunctionTests.cs @@ -2,20 +2,20 @@ using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Date; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Date { - [TestClass] + [TestFixture] public class SecondsBetweenFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("SecondsBetween", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestValidValues() { Assert.AreEqual(256d, @@ -23,25 +23,25 @@ public void TestValidValues() new DateTime(2016, 02, 27, 12, 00, 00).AddSeconds(256))); } - [TestMethod] + [Test] public void TestWithBothNull() { Assert.IsNull(this.Evaluate(null, null)); } - [TestMethod] + [Test] public void TestWithFirstNull() { Assert.IsNull(this.Evaluate(null, 123)); } - [TestMethod] + [Test] public void TestWithSecondNull() { Assert.IsNull(this.Evaluate(DateTime.Now, null)); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "SecondsBetween() takes only 2 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/Date/YearOfFunctionTests.cs b/Source/Expressive.Tests/Functions/Date/YearOfFunctionTests.cs index 97c6274..17bb77d 100644 --- a/Source/Expressive.Tests/Functions/Date/YearOfFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Date/YearOfFunctionTests.cs @@ -6,32 +6,32 @@ using Expressive.Exceptions; using Expressive.Functions; using Expressive.Functions.Date; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Date { - [TestClass] + [TestFixture] public class YearOfFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("YearOf", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestWithNull() { Assert.IsNull(this.Evaluate(new object[] { null })); } - [TestMethod] + [Test] public void TestWithDateTime() { Assert.AreEqual(2016, this.Evaluate(new DateTime(2016, 02, 29))); } - [TestMethod] + [Test] public void TestExpectedParameterCount() { this.AssertException(typeof(ParameterCountMismatchException), "YearOf() takes only 1 argument(s)"); diff --git a/Source/Expressive.Tests/Functions/FunctionBaseTestBase.cs b/Source/Expressive.Tests/Functions/FunctionBaseTestBase.cs index 32793ef..ac9b99a 100644 --- a/Source/Expressive.Tests/Functions/FunctionBaseTestBase.cs +++ b/Source/Expressive.Tests/Functions/FunctionBaseTestBase.cs @@ -1,9 +1,6 @@ using System; -using System.Collections.Generic; using System.Linq; -using Expressive.Expressions; using Expressive.Functions; -using Moq; using NUnit.Framework; namespace Expressive.Tests.Functions @@ -17,7 +14,7 @@ protected void AssertException(Type exceptionType, string exceptionMessage, para try { this.ActualFunction.Evaluate( - values?.Select(v => Mock.Of(e => e.Evaluate(It.IsAny>()) == v)).ToArray(), + values?.Select(v => MockExpression.ThatEvaluatesTo(v)).ToArray(), new Context(ExpressiveOptions.None)); } #pragma warning disable CA1031 // Do not catch general exception types - We will eventually switch to NUnit that should remove the need for this. @@ -35,7 +32,7 @@ protected void AssertException(Type exceptionType, string exceptionMessage, para protected object Evaluate(params object[] values) { return this.ActualFunction.Evaluate( - values.Select(v => Mock.Of(e => e.Evaluate(It.IsAny>()) == v)).ToArray(), + values.Select(v => MockExpression.ThatEvaluatesTo(v)).ToArray(), new Context(ExpressiveOptions.None)); } } diff --git a/Source/Expressive.Tests/Functions/Logical/InFunctionTests.cs b/Source/Expressive.Tests/Functions/Logical/InFunctionTests.cs index 2ce5fc7..f1619e5 100644 --- a/Source/Expressive.Tests/Functions/Logical/InFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Logical/InFunctionTests.cs @@ -1,13 +1,13 @@ using Expressive.Functions; using Expressive.Functions.Logical; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Logical { - [TestClass] + [TestFixture] public class InFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void ShouldReturnTrueIfItemIsInTheList() => Assert.IsTrue((bool)this.Evaluate(new object[] { "a", "b", "c", "a" })); #region FunctionBaseTests Members diff --git a/Source/Expressive.Tests/Functions/Mathematical/CountFunctionTests.cs b/Source/Expressive.Tests/Functions/Mathematical/CountFunctionTests.cs index b87008f..a335622 100644 --- a/Source/Expressive.Tests/Functions/Mathematical/CountFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Mathematical/CountFunctionTests.cs @@ -1,9 +1,7 @@ using System.Collections.Generic; using System.Linq; -using Expressive.Expressions; using Expressive.Functions; using Expressive.Functions.Mathematical; -using Moq; using NUnit.Framework; namespace Expressive.Tests.Functions.Mathematical @@ -46,7 +44,7 @@ private static IEnumerable CountFunctionData private static object Evaluate(IFunction function, params object[] values) { return function.Evaluate( - values.Select(v => Mock.Of(e => e.Evaluate(It.IsAny>()) == v)).ToArray(), + values.Select(v => MockExpression.ThatEvaluatesTo(v)).ToArray(), new Context(ExpressiveOptions.None)); } } diff --git a/Source/Expressive.Tests/Functions/Relational/MaxFunctionTests.cs b/Source/Expressive.Tests/Functions/Relational/MaxFunctionTests.cs index 936a647..6ac6e43 100644 --- a/Source/Expressive.Tests/Functions/Relational/MaxFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Relational/MaxFunctionTests.cs @@ -1,20 +1,20 @@ using System; using Expressive.Functions; using Expressive.Functions.Relational; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Relational { - [TestClass] + [TestFixture] public class MaxFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("Max", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestWithDates() { var min = new DateTime(2019, 06, 12); @@ -24,49 +24,49 @@ public void TestWithDates() Assert.AreEqual(max, this.Evaluate(middle, max, min)); } - [TestMethod] + [Test] public void TestWithDecimals() { Assert.AreEqual(12.5M, this.Evaluate(12.5M, 10.9M, 0.9M)); } - [TestMethod] + [Test] public void TestWithDoubles() { Assert.AreEqual(12.5, this.Evaluate(12.5, 10.9, 0.9)); } - [TestMethod] + [Test] public void TestWithIntegers() { Assert.AreEqual(125, this.Evaluate(125, 109, 0)); } - [TestMethod] + [Test] public void TestWithLongs() { Assert.AreEqual(long.MaxValue, this.Evaluate(long.MaxValue, 10L, long.MinValue)); } - [TestMethod] + [Test] public void TestWithNull() { Assert.AreEqual(null, this.Evaluate(long.MaxValue, 10L, long.MinValue, null)); } - [TestMethod] + [Test] public void TestWithParameters() { Assert.AreEqual(57, this.Evaluate(0, -10, 57, 45)); } - [TestMethod] + [Test] public void TestWithParametersAndNestedIEnumerable() { Assert.AreEqual(99, this.Evaluate(57, -10, new object[] { 57, 45, 99 }, 45)); } - [TestMethod] + [Test] public void TestWithParametersAndNull() { Assert.AreEqual(null, this.Evaluate(0, -10, 57, 45, null)); diff --git a/Source/Expressive.Tests/Functions/Relational/MinFunctionTests.cs b/Source/Expressive.Tests/Functions/Relational/MinFunctionTests.cs index 3242644..0f52807 100644 --- a/Source/Expressive.Tests/Functions/Relational/MinFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/Relational/MinFunctionTests.cs @@ -1,20 +1,20 @@ using System; using Expressive.Functions; using Expressive.Functions.Relational; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.Relational { - [TestClass] + [TestFixture] public class MinFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("Min", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestWithDates() { var min = new DateTime(2019, 06, 12); @@ -24,49 +24,49 @@ public void TestWithDates() Assert.AreEqual(min, this.Evaluate(middle, max, min)); } - [TestMethod] + [Test] public void TestWithDecimals() { Assert.AreEqual(0.9M, this.Evaluate(12.5M, 10.9M, 0.9M)); } - [TestMethod] + [Test] public void TestWithDoubles() { Assert.AreEqual(0.9, this.Evaluate(12.5, 10.9, 0.9)); } - [TestMethod] + [Test] public void TestWithIntegers() { Assert.AreEqual(0, this.Evaluate(125, 109, 0)); } - [TestMethod] + [Test] public void TestWithLongs() { Assert.AreEqual(long.MinValue, this.Evaluate(long.MaxValue, 10L, long.MinValue)); } - [TestMethod] + [Test] public void TestWithNull() { Assert.AreEqual(null, this.Evaluate(long.MaxValue, 10L, long.MinValue, null)); } - [TestMethod] + [Test] public void TestWithParameters() { Assert.AreEqual(-10, this.Evaluate(0, -10, 57, 45)); } - [TestMethod] + [Test] public void TestWithParametersAndNestedIEnumerable() { Assert.AreEqual(-10, this.Evaluate(57, -10, new object[] { 57, 45, 99 }, 45)); } - [TestMethod] + [Test] public void TestWithParametersAndNull() { Assert.AreEqual(null, this.Evaluate(0, -10, 57, 45, null)); diff --git a/Source/Expressive.Tests/Functions/String/ConcatFunctionTests.cs b/Source/Expressive.Tests/Functions/String/ConcatFunctionTests.cs index 82828f4..4174357 100644 --- a/Source/Expressive.Tests/Functions/String/ConcatFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/String/ConcatFunctionTests.cs @@ -1,20 +1,20 @@ using System; using Expressive.Functions; using Expressive.Functions.String; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.String { - [TestClass] + [TestFixture] public class ConcatFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("Concat", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestWith2Strings() { var left = "left"; @@ -23,7 +23,7 @@ public void TestWith2Strings() Assert.AreEqual(left+right, this.Evaluate(left, right)); } - [TestMethod] + [Test] public void TestWith3Strings() { var left = "left"; @@ -33,7 +33,7 @@ public void TestWith3Strings() Assert.AreEqual(left + middle + right, this.Evaluate(left, middle, right)); } - [TestMethod] + [Test] public void TestWithNumbers() { var left = 10; @@ -42,7 +42,7 @@ public void TestWithNumbers() Assert.AreEqual("101412.5", this.Evaluate(left, middle, right)); } - [TestMethod] + [Test] public void TestWithMixed() { var left = "left"; @@ -51,7 +51,7 @@ public void TestWithMixed() Assert.AreEqual("left14right", this.Evaluate(left, middle, right)); } - [TestMethod] + [Test] public void TestWithNestedArrays() { var left = "left"; @@ -61,7 +61,7 @@ public void TestWithNestedArrays() } - [TestMethod] + [Test] public void TestWithParametersAndNull() { diff --git a/Source/Expressive.Tests/Functions/String/IndexOfFunctionTests.cs b/Source/Expressive.Tests/Functions/String/IndexOfFunctionTests.cs index 27e6189..fb1b206 100644 --- a/Source/Expressive.Tests/Functions/String/IndexOfFunctionTests.cs +++ b/Source/Expressive.Tests/Functions/String/IndexOfFunctionTests.cs @@ -1,20 +1,20 @@ using System; using Expressive.Functions; using Expressive.Functions.String; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Functions.String { - [TestClass] + [TestFixture] public class IndexOfFunctionTests : FunctionBaseTestBase { - [TestMethod] + [Test] public void TestName() { Assert.AreEqual("IndexOf", this.ActualFunction.Name); } - [TestMethod] + [Test] public void TestWithStartString() { var left = "left"; @@ -25,7 +25,7 @@ public void TestWithStartString() } - [TestMethod] + [Test] public void TestWithMidString() { var left = "left"; @@ -34,7 +34,7 @@ public void TestWithMidString() Assert.AreEqual(2, this.Evaluate(left, right)); } - [TestMethod] + [Test] public void TestWithNotFound() { var left = "left"; @@ -43,7 +43,7 @@ public void TestWithNotFound() Assert.AreEqual(-1, this.Evaluate(left, right)); } - [TestMethod] + [Test] public void TestWithArray() { var left = new object[] { "left", 12, "right" }; diff --git a/Source/Expressive.Tests/Mocks/MockExpression.cs b/Source/Expressive.Tests/Mocks/MockExpression.cs new file mode 100644 index 0000000..917bc5d --- /dev/null +++ b/Source/Expressive.Tests/Mocks/MockExpression.cs @@ -0,0 +1,19 @@ +using Expressive.Expressions; +using System.Collections.Generic; + +namespace Expressive.Tests +{ + public class MockExpression : IExpression + { + private readonly object result; + + private MockExpression(object result) + { + this.result = result; + } + + public static MockExpression ThatEvaluatesTo(object result) => new MockExpression(result); + + public object Evaluate(IDictionary variables) => this.result; + } +} \ No newline at end of file diff --git a/Source/Expressive.Tests/Operators/Additive/PlusOperatorTests.cs b/Source/Expressive.Tests/Operators/Additive/PlusOperatorTests.cs index 1e96307..7174065 100644 --- a/Source/Expressive.Tests/Operators/Additive/PlusOperatorTests.cs +++ b/Source/Expressive.Tests/Operators/Additive/PlusOperatorTests.cs @@ -1,16 +1,13 @@ -using Expressive.Expressions; -using Expressive.Expressions.Binary.Additive; +using Expressive.Expressions.Binary.Additive; using Expressive.Expressions.Unary.Additive; using Expressive.Operators; using Expressive.Operators.Additive; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; +using NUnit.Framework; using System; -using System.Collections.Generic; namespace Expressive.Tests.Operators.Additive { - [TestClass] + [TestFixture] public class PlusOperatorTests : OperatorBaseTests { #region OperatorBaseTests Members @@ -23,7 +20,7 @@ public class PlusOperatorTests : OperatorBaseTests protected override string[] ExpectedTags => new[] { "+" }; - [TestMethod] + [Test] public override void TestGetInnerCaptiveTokens() { var op = this.Operator; @@ -43,7 +40,7 @@ public override void TestGetInnerCaptiveTokens() #endregion - [TestMethod] + [Test] public void TestBuildExpressionForUnaryWithLeftHandExpression() { var op = new PlusOperator(); @@ -52,15 +49,15 @@ public void TestBuildExpressionForUnaryWithLeftHandExpression() new Token("+", 1), new[] { - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object) null), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object) null) + MockExpression.ThatEvaluatesTo(null), + MockExpression.ThatEvaluatesTo(null) }, new Context(ExpressiveOptions.None)); - Assert.IsInstanceOfType(expression, typeof(PlusExpression)); + Assert.That(expression, Is.InstanceOf(typeof(PlusExpression))); } - [TestMethod] + [Test] public void TestBuildExpressionForUnaryWithRightHandExpression() { var op = new PlusOperator(); @@ -70,14 +67,14 @@ public void TestBuildExpressionForUnaryWithRightHandExpression() new[] { null, - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object) null) + MockExpression.ThatEvaluatesTo(null) }, new Context(ExpressiveOptions.None)); - Assert.IsInstanceOfType(expression, typeof(PlusExpression)); + Assert.That(expression, Is.InstanceOf(typeof(PlusExpression))); } - [TestMethod] + [Test] public void TestGetPrecedenceForUnary() { var op = new PlusOperator(); @@ -85,7 +82,7 @@ public void TestGetPrecedenceForUnary() Assert.AreEqual(OperatorPrecedence.UnaryPlus, op.GetPrecedence(null)); } - [TestMethod] + [Test] public void TestGetPrecedenceForBinary() { var op = new PlusOperator(); diff --git a/Source/Expressive.Tests/Operators/Additive/SubtractOperatorTests.cs b/Source/Expressive.Tests/Operators/Additive/SubtractOperatorTests.cs index f626d5e..1ac7d39 100644 --- a/Source/Expressive.Tests/Operators/Additive/SubtractOperatorTests.cs +++ b/Source/Expressive.Tests/Operators/Additive/SubtractOperatorTests.cs @@ -1,16 +1,13 @@ -using Expressive.Expressions; -using Expressive.Expressions.Binary.Additive; +using Expressive.Expressions.Binary.Additive; using Expressive.Expressions.Unary.Additive; using Expressive.Operators; using Expressive.Operators.Additive; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; +using NUnit.Framework; using System; -using System.Collections.Generic; namespace Expressive.Tests.Operators.Additive { - [TestClass] + [TestFixture] public class SubtractOperatorTests : OperatorBaseTests { #region OperatorBaseTests Members @@ -23,7 +20,7 @@ public class SubtractOperatorTests : OperatorBaseTests protected override string[] ExpectedTags => new[] { "-", "\u2212" }; - [TestMethod] + [Test] public override void TestGetInnerCaptiveTokens() { var op = this.Operator; @@ -43,7 +40,7 @@ public override void TestGetInnerCaptiveTokens() #endregion - [TestMethod] + [Test] public void TestBuildExpressionForUnaryWithLeftHandExpression() { var op = new SubtractOperator(); @@ -52,15 +49,15 @@ public void TestBuildExpressionForUnaryWithLeftHandExpression() new Token("+", 1), new[] { - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object) null), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object) null) + MockExpression.ThatEvaluatesTo(null), + MockExpression.ThatEvaluatesTo(null) }, new Context(ExpressiveOptions.None)); - Assert.IsInstanceOfType(expression, typeof(MinusExpression)); + Assert.That(expression, Is.InstanceOf(typeof(MinusExpression))); } - [TestMethod] + [Test] public void TestBuildExpressionForUnaryWithRightHandExpression() { var op = new SubtractOperator(); @@ -70,14 +67,14 @@ public void TestBuildExpressionForUnaryWithRightHandExpression() new[] { null, - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object) null) + MockExpression.ThatEvaluatesTo(null) }, new Context(ExpressiveOptions.None)); - Assert.IsInstanceOfType(expression, typeof(MinusExpression)); + Assert.That(expression, Is.InstanceOf(typeof(MinusExpression))); } - [TestMethod] + [Test] public void TestGetPrecedenceForUnary() { var op = new SubtractOperator(); @@ -85,7 +82,7 @@ public void TestGetPrecedenceForUnary() Assert.AreEqual(OperatorPrecedence.UnaryMinus, op.GetPrecedence(null)); } - [TestMethod] + [Test] public void TestGetPrecedenceForBinary() { var op = new SubtractOperator(); diff --git a/Source/Expressive.Tests/Operators/Bitwise/BitwiseAndOperatorTests.cs b/Source/Expressive.Tests/Operators/Bitwise/BitwiseAndOperatorTests.cs index ad1da4f..9fb4c9e 100644 --- a/Source/Expressive.Tests/Operators/Bitwise/BitwiseAndOperatorTests.cs +++ b/Source/Expressive.Tests/Operators/Bitwise/BitwiseAndOperatorTests.cs @@ -2,11 +2,11 @@ using Expressive.Expressions.Binary.Bitwise; using Expressive.Operators; using Expressive.Operators.Bitwise; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Operators.Bitwise { - [TestClass] + [TestFixture] public class BitwiseAndOperatorTests : OperatorBaseTests { #region OperatorBaseTests Members diff --git a/Source/Expressive.Tests/Operators/Bitwise/BitwiseExclusiveOrOperatorTests.cs b/Source/Expressive.Tests/Operators/Bitwise/BitwiseExclusiveOrOperatorTests.cs index 5b212ba..7fab469 100644 --- a/Source/Expressive.Tests/Operators/Bitwise/BitwiseExclusiveOrOperatorTests.cs +++ b/Source/Expressive.Tests/Operators/Bitwise/BitwiseExclusiveOrOperatorTests.cs @@ -2,11 +2,11 @@ using Expressive.Expressions.Binary.Bitwise; using Expressive.Operators; using Expressive.Operators.Bitwise; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Operators.Bitwise { - [TestClass] + [TestFixture] public class BitwiseExclusiveOrOperatorTests : OperatorBaseTests { #region OperatorBaseTests Members diff --git a/Source/Expressive.Tests/Operators/Bitwise/BitwiseOrOperatorTests.cs b/Source/Expressive.Tests/Operators/Bitwise/BitwiseOrOperatorTests.cs index 3ce315b..61c166a 100644 --- a/Source/Expressive.Tests/Operators/Bitwise/BitwiseOrOperatorTests.cs +++ b/Source/Expressive.Tests/Operators/Bitwise/BitwiseOrOperatorTests.cs @@ -2,11 +2,11 @@ using Expressive.Expressions.Binary.Bitwise; using Expressive.Operators; using Expressive.Operators.Bitwise; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Operators.Bitwise { - [TestClass] + [TestFixture] public class BitwiseOrOperatorTests : OperatorBaseTests { #region OperatorBaseTests Members diff --git a/Source/Expressive.Tests/Operators/Bitwise/LeftShiftOperatorTests.cs b/Source/Expressive.Tests/Operators/Bitwise/LeftShiftOperatorTests.cs index 9edb2f3..32b906a 100644 --- a/Source/Expressive.Tests/Operators/Bitwise/LeftShiftOperatorTests.cs +++ b/Source/Expressive.Tests/Operators/Bitwise/LeftShiftOperatorTests.cs @@ -2,11 +2,11 @@ using Expressive.Expressions.Binary.Bitwise; using Expressive.Operators; using Expressive.Operators.Bitwise; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Operators.Bitwise { - [TestClass] + [TestFixture] public class LeftShiftOperatorTests : OperatorBaseTests { #region OperatorBaseTests Members diff --git a/Source/Expressive.Tests/Operators/Bitwise/RightShiftOperatorTests.cs b/Source/Expressive.Tests/Operators/Bitwise/RightShiftOperatorTests.cs index d4b4061..a7c3b2e 100644 --- a/Source/Expressive.Tests/Operators/Bitwise/RightShiftOperatorTests.cs +++ b/Source/Expressive.Tests/Operators/Bitwise/RightShiftOperatorTests.cs @@ -2,11 +2,11 @@ using Expressive.Expressions.Binary.Bitwise; using Expressive.Operators; using Expressive.Operators.Bitwise; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Operators.Bitwise { - [TestClass] + [TestFixture] public class RightShiftOperatorTests : OperatorBaseTests { #region OperatorBaseTests Members diff --git a/Source/Expressive.Tests/Operators/Conditional/NullCoalescingOperatorTests.cs b/Source/Expressive.Tests/Operators/Conditional/NullCoalescingOperatorTests.cs index 39ccee3..4348272 100644 --- a/Source/Expressive.Tests/Operators/Conditional/NullCoalescingOperatorTests.cs +++ b/Source/Expressive.Tests/Operators/Conditional/NullCoalescingOperatorTests.cs @@ -2,11 +2,11 @@ using Expressive.Expressions.Binary.Conditional; using Expressive.Operators; using Expressive.Operators.Conditional; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Operators.Conditional { - [TestClass] + [TestFixture] public class NullCoalescingOperatorTests : OperatorBaseTests { #region OperatorBaseTests Members diff --git a/Source/Expressive.Tests/Operators/Grouping/ParenthesisCloseOperatorTests.cs b/Source/Expressive.Tests/Operators/Grouping/ParenthesisCloseOperatorTests.cs index f8cd412..1108cd8 100644 --- a/Source/Expressive.Tests/Operators/Grouping/ParenthesisCloseOperatorTests.cs +++ b/Source/Expressive.Tests/Operators/Grouping/ParenthesisCloseOperatorTests.cs @@ -2,11 +2,11 @@ using Expressive.Expressions; using Expressive.Operators; using Expressive.Operators.Grouping; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Operators.Grouping { - [TestClass] + [TestFixture] public class ParenthesisCloseOperatorTests : OperatorBaseTests { #region OperatorBaseTests Members diff --git a/Source/Expressive.Tests/Operators/Grouping/ParenthesisOpenOperatorTests.cs b/Source/Expressive.Tests/Operators/Grouping/ParenthesisOpenOperatorTests.cs index ccf8b47..6aa2dd5 100644 --- a/Source/Expressive.Tests/Operators/Grouping/ParenthesisOpenOperatorTests.cs +++ b/Source/Expressive.Tests/Operators/Grouping/ParenthesisOpenOperatorTests.cs @@ -6,11 +6,11 @@ using Expressive.Expressions; using Expressive.Operators; using Expressive.Operators.Grouping; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Operators.Grouping { - [TestClass] + [TestFixture] public class ParenthesisOpenOperatorTests : OperatorBaseTests { #region OperatorBaseTests Members @@ -23,7 +23,7 @@ public class ParenthesisOpenOperatorTests : OperatorBaseTests protected override string[] ExpectedTags => new[] { "(" }; - [TestMethod] + [Test] public override void TestGetCaptiveTokens() { var op = this.Operator; @@ -59,7 +59,7 @@ public override void TestGetCaptiveTokens() } } - [TestMethod] + [Test] public override void TestGetInnerCaptiveTokens() { var op = this.Operator; @@ -81,7 +81,7 @@ public override void TestGetInnerCaptiveTokens() #endregion - [TestMethod] + [Test] public void TestComplexGetCaptiveTokens() { var op = this.Operator; diff --git a/Source/Expressive.Tests/Operators/Logical/AndOperatorTests.cs b/Source/Expressive.Tests/Operators/Logical/AndOperatorTests.cs index cdecb87..d737f8b 100644 --- a/Source/Expressive.Tests/Operators/Logical/AndOperatorTests.cs +++ b/Source/Expressive.Tests/Operators/Logical/AndOperatorTests.cs @@ -2,11 +2,11 @@ using Expressive.Expressions.Binary.Logical; using Expressive.Operators; using Expressive.Operators.Logical; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Operators.Logical { - [TestClass] + [TestFixture] public class AndOperatorTests : OperatorBaseTests { #region OperatorBaseTests Members diff --git a/Source/Expressive.Tests/Operators/Logical/NotOperatorTests.cs b/Source/Expressive.Tests/Operators/Logical/NotOperatorTests.cs index 8206a1f..c706cb6 100644 --- a/Source/Expressive.Tests/Operators/Logical/NotOperatorTests.cs +++ b/Source/Expressive.Tests/Operators/Logical/NotOperatorTests.cs @@ -2,11 +2,11 @@ using Expressive.Expressions.Unary.Logical; using Expressive.Operators; using Expressive.Operators.Logical; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Operators.Logical { - [TestClass] + [TestFixture] public class NotOperatorTests : OperatorBaseTests { #region OperatorBaseTests Members diff --git a/Source/Expressive.Tests/Operators/Logical/OrOperatorTests.cs b/Source/Expressive.Tests/Operators/Logical/OrOperatorTests.cs index 8651576..f3a5b75 100644 --- a/Source/Expressive.Tests/Operators/Logical/OrOperatorTests.cs +++ b/Source/Expressive.Tests/Operators/Logical/OrOperatorTests.cs @@ -2,11 +2,11 @@ using Expressive.Expressions.Binary.Logical; using Expressive.Operators; using Expressive.Operators.Logical; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Operators.Logical { - [TestClass] + [TestFixture] public class OrOperatorTests : OperatorBaseTests { #region OperatorBaseTests Members diff --git a/Source/Expressive.Tests/Operators/Multiplicative/DivideOperatorTests.cs b/Source/Expressive.Tests/Operators/Multiplicative/DivideOperatorTests.cs index afa90bc..3ae47e2 100644 --- a/Source/Expressive.Tests/Operators/Multiplicative/DivideOperatorTests.cs +++ b/Source/Expressive.Tests/Operators/Multiplicative/DivideOperatorTests.cs @@ -2,11 +2,11 @@ using Expressive.Expressions.Binary.Multiplicative; using Expressive.Operators; using Expressive.Operators.Multiplicative; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Operators.Multiplicative { - [TestClass] + [TestFixture] public class DivideOperatorTests : OperatorBaseTests { #region OperatorBaseTests Members diff --git a/Source/Expressive.Tests/Operators/Multiplicative/ModulusOperatorTests.cs b/Source/Expressive.Tests/Operators/Multiplicative/ModulusOperatorTests.cs index 28f2679..cdf8c27 100644 --- a/Source/Expressive.Tests/Operators/Multiplicative/ModulusOperatorTests.cs +++ b/Source/Expressive.Tests/Operators/Multiplicative/ModulusOperatorTests.cs @@ -2,11 +2,11 @@ using Expressive.Expressions.Binary.Multiplicative; using Expressive.Operators; using Expressive.Operators.Multiplicative; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Operators.Multiplicative { - [TestClass] + [TestFixture] public class ModulusOperatorTests : OperatorBaseTests { #region OperatorBaseTests Members diff --git a/Source/Expressive.Tests/Operators/Multiplicative/MultiplyOperatorTests.cs b/Source/Expressive.Tests/Operators/Multiplicative/MultiplyOperatorTests.cs index 495d5fa..461eb39 100644 --- a/Source/Expressive.Tests/Operators/Multiplicative/MultiplyOperatorTests.cs +++ b/Source/Expressive.Tests/Operators/Multiplicative/MultiplyOperatorTests.cs @@ -2,11 +2,11 @@ using Expressive.Expressions.Binary.Multiplicative; using Expressive.Operators; using Expressive.Operators.Multiplicative; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Operators.Multiplicative { - [TestClass] + [TestFixture] public class MultiplyOperatorTests : OperatorBaseTests { #region OperatorBaseTests Members diff --git a/Source/Expressive.Tests/Operators/OperatorBaseTests.cs b/Source/Expressive.Tests/Operators/OperatorBaseTests.cs index 49dd405..9303784 100644 --- a/Source/Expressive.Tests/Operators/OperatorBaseTests.cs +++ b/Source/Expressive.Tests/Operators/OperatorBaseTests.cs @@ -1,14 +1,12 @@ -using Expressive.Expressions; -using Expressive.Operators; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; +using Expressive.Operators; +using NUnit.Framework; using System; using System.Collections.Generic; using System.Linq; namespace Expressive.Tests.Operators { - [TestClass] + [TestFixture] public abstract class OperatorBaseTests { internal abstract IOperator Operator { get; } @@ -21,7 +19,7 @@ public abstract class OperatorBaseTests protected abstract string[] ExpectedTags { get; } #pragma warning restore CA1819 // Properties should not return arrays - [TestMethod] + [Test] public void TestTags() { var operatorTags = this.Operator.Tags.ToArray(); @@ -34,7 +32,7 @@ public void TestTags() } } - [TestMethod] + [Test] public void TestBuildExpression() { var op = this.Operator; @@ -43,15 +41,15 @@ public void TestBuildExpression() new Token("1", 1), new[] { - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object) null), - Mock.Of(e => e.Evaluate(It.IsAny>()) == (object) null) + MockExpression.ThatEvaluatesTo(null), + MockExpression.ThatEvaluatesTo(null) }, new Context(ExpressiveOptions.None)); - Assert.IsInstanceOfType(expression, this.ExpectedExpressionType); + Assert.That(expression, Is.InstanceOf(this.ExpectedExpressionType)); } - [TestMethod] + [Test] public void TestCanGetCaptiveTokens() { var op = this.Operator; @@ -59,7 +57,7 @@ public void TestCanGetCaptiveTokens() Assert.IsTrue(op.CanGetCaptiveTokens(new Token("1", 0), new Token("+", 1), new Queue())); } - [TestMethod] + [Test] public virtual void TestGetCaptiveTokens() { var op = this.Operator; @@ -69,7 +67,7 @@ public virtual void TestGetCaptiveTokens() Assert.AreEqual(token, op.GetCaptiveTokens(new Token("1", 0), token, new Queue()).Single()); } - [TestMethod] + [Test] public virtual void TestGetInnerCaptiveTokens() { var op = this.Operator; @@ -87,7 +85,7 @@ public virtual void TestGetInnerCaptiveTokens() Assert.AreEqual(0, op.GetInnerCaptiveTokens(tokens).Length); } - [TestMethod] + [Test] public void TestGetPrecedence() { var op = this.Operator; diff --git a/Source/Expressive.Tests/Operators/Relational/EqualOperatorTests.cs b/Source/Expressive.Tests/Operators/Relational/EqualOperatorTests.cs index 71f03dd..fd83b77 100644 --- a/Source/Expressive.Tests/Operators/Relational/EqualOperatorTests.cs +++ b/Source/Expressive.Tests/Operators/Relational/EqualOperatorTests.cs @@ -2,11 +2,11 @@ using Expressive.Expressions.Binary.Relational; using Expressive.Operators; using Expressive.Operators.Relational; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Operators.Relational { - [TestClass] + [TestFixture] public class EqualOperatorTests : OperatorBaseTests { #region OperatorBaseTests Members diff --git a/Source/Expressive.Tests/Operators/Relational/GreaterThanOperatorTests.cs b/Source/Expressive.Tests/Operators/Relational/GreaterThanOperatorTests.cs index a4f5832..b7d789c 100644 --- a/Source/Expressive.Tests/Operators/Relational/GreaterThanOperatorTests.cs +++ b/Source/Expressive.Tests/Operators/Relational/GreaterThanOperatorTests.cs @@ -2,11 +2,11 @@ using Expressive.Expressions.Binary.Relational; using Expressive.Operators; using Expressive.Operators.Relational; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Operators.Relational { - [TestClass] + [TestFixture] public class GreaterThanOperatorTests : OperatorBaseTests { #region OperatorBaseTests Members diff --git a/Source/Expressive.Tests/Operators/Relational/GreaterThanOrEqualOperatorTests.cs b/Source/Expressive.Tests/Operators/Relational/GreaterThanOrEqualOperatorTests.cs index c7a191d..0504d64 100644 --- a/Source/Expressive.Tests/Operators/Relational/GreaterThanOrEqualOperatorTests.cs +++ b/Source/Expressive.Tests/Operators/Relational/GreaterThanOrEqualOperatorTests.cs @@ -2,11 +2,11 @@ using Expressive.Expressions.Binary.Relational; using Expressive.Operators; using Expressive.Operators.Relational; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Operators.Relational { - [TestClass] + [TestFixture] public class GreaterThanOrEqualOperatorTests : OperatorBaseTests { #region OperatorBaseTests Members diff --git a/Source/Expressive.Tests/Operators/Relational/LessThanOperatorTests.cs b/Source/Expressive.Tests/Operators/Relational/LessThanOperatorTests.cs index 5659f6a..2517b17 100644 --- a/Source/Expressive.Tests/Operators/Relational/LessThanOperatorTests.cs +++ b/Source/Expressive.Tests/Operators/Relational/LessThanOperatorTests.cs @@ -2,11 +2,11 @@ using Expressive.Expressions.Binary.Relational; using Expressive.Operators; using Expressive.Operators.Relational; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Operators.Relational { - [TestClass] + [TestFixture] public class LessThanOperatorTests : OperatorBaseTests { #region OperatorBaseTests Members diff --git a/Source/Expressive.Tests/Operators/Relational/LessThanOrEqualOperatorTests.cs b/Source/Expressive.Tests/Operators/Relational/LessThanOrEqualOperatorTests.cs index 825d647..a4af40b 100644 --- a/Source/Expressive.Tests/Operators/Relational/LessThanOrEqualOperatorTests.cs +++ b/Source/Expressive.Tests/Operators/Relational/LessThanOrEqualOperatorTests.cs @@ -2,11 +2,11 @@ using Expressive.Expressions.Binary.Relational; using Expressive.Operators; using Expressive.Operators.Relational; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Operators.Relational { - [TestClass] + [TestFixture] public class LessThanOrEqualOperatorTests : OperatorBaseTests { #region OperatorBaseTests Members diff --git a/Source/Expressive.Tests/Operators/Relational/NotEqualOperatorTests.cs b/Source/Expressive.Tests/Operators/Relational/NotEqualOperatorTests.cs index d9fb2dd..4bddd3f 100644 --- a/Source/Expressive.Tests/Operators/Relational/NotEqualOperatorTests.cs +++ b/Source/Expressive.Tests/Operators/Relational/NotEqualOperatorTests.cs @@ -2,11 +2,11 @@ using Expressive.Expressions.Binary.Relational; using Expressive.Operators; using Expressive.Operators.Relational; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Operators.Relational { - [TestClass] + [TestFixture] public class NotEqualOperatorTests : OperatorBaseTests { #region OperatorBaseTests Members diff --git a/Source/Expressive.Tests/Tokenisation/NumericTokenExtractorTests.cs b/Source/Expressive.Tests/Tokenisation/NumericTokenExtractorTests.cs index 4e7f58b..f84a3cf 100644 --- a/Source/Expressive.Tests/Tokenisation/NumericTokenExtractorTests.cs +++ b/Source/Expressive.Tests/Tokenisation/NumericTokenExtractorTests.cs @@ -1,13 +1,13 @@ using System.Globalization; using Expressive.Tokenisation; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; namespace Expressive.Tests.Tokenisation { - [TestClass] + [TestFixture] public class NumericTokenExtractorTests { - [TestMethod] + [Test] public void TestWithDecimalPlace() { var extractor = new NumericTokenExtractor(); @@ -18,7 +18,7 @@ public void TestWithDecimalPlace() Assert.AreEqual("123.45", token.CurrentToken); } - [TestMethod] + [Test] public void TestWithDecimalPlaceLeading() { var extractor = new NumericTokenExtractor(); @@ -29,7 +29,7 @@ public void TestWithDecimalPlaceLeading() Assert.AreEqual(".45", token.CurrentToken); } - [TestMethod] + [Test] public void TestWithDecimalPlaceAndNegativeSign() { var extractor = new NumericTokenExtractor(); @@ -40,7 +40,7 @@ public void TestWithDecimalPlaceAndNegativeSign() Assert.AreEqual("-123.45", token.CurrentToken); } - [TestMethod] + [Test] public void TestWithDecimalPlaceAndPositiveSign() { var extractor = new NumericTokenExtractor(); @@ -51,7 +51,7 @@ public void TestWithDecimalPlaceAndPositiveSign() Assert.AreEqual("+123.45", token.CurrentToken); } - [TestMethod] + [Test] public void TestWithInteger() { var extractor = new NumericTokenExtractor(); @@ -62,7 +62,7 @@ public void TestWithInteger() Assert.AreEqual("123", token.CurrentToken); } - [TestMethod] + [Test] public void TestWithIntegerAndNegativeSign() { var extractor = new NumericTokenExtractor(); @@ -73,7 +73,7 @@ public void TestWithIntegerAndNegativeSign() Assert.AreEqual("-123", token.CurrentToken); } - [TestMethod] + [Test] public void TestWithIntegerAndPositiveSign() { var extractor = new NumericTokenExtractor(); @@ -84,7 +84,7 @@ public void TestWithIntegerAndPositiveSign() Assert.AreEqual("+123", token.CurrentToken); } - [TestMethod] + [Test] public void TestWithInvalidNumber() { var extractor = new NumericTokenExtractor(); @@ -94,7 +94,7 @@ public void TestWithInvalidNumber() Assert.IsNull(token); } - [TestMethod] + [Test] public void TestWithMultipleDecimalPlaces() { var extractor = new NumericTokenExtractor(); @@ -105,7 +105,7 @@ public void TestWithMultipleDecimalPlaces() Assert.AreEqual("123.45", token.CurrentToken); } - [TestMethod] + [Test] public void TestWithScientificNotationAndNoOrderOfMagnitude() { var extractor = new NumericTokenExtractor(); @@ -116,7 +116,7 @@ public void TestWithScientificNotationAndNoOrderOfMagnitude() Assert.AreEqual("1.23", token.CurrentToken); } - [TestMethod] + [Test] public void TestWithScientificNotation() { var extractor = new NumericTokenExtractor(); @@ -127,7 +127,7 @@ public void TestWithScientificNotation() Assert.AreEqual("1.23e2", token.CurrentToken); } - [TestMethod] + [Test] public void TestWithScientificNotationAndNegativeSign() { var extractor = new NumericTokenExtractor(); @@ -138,7 +138,7 @@ public void TestWithScientificNotationAndNegativeSign() Assert.AreEqual("1.23e-2", token.CurrentToken); } - [TestMethod] + [Test] public void TestWithScientificNotationAndPositiveSign() { var extractor = new NumericTokenExtractor(); diff --git a/Source/Expressive.Tests/Tokenisation/TokeniserTests.cs b/Source/Expressive.Tests/Tokenisation/TokeniserTests.cs index a8177e1..afed6b9 100644 --- a/Source/Expressive.Tests/Tokenisation/TokeniserTests.cs +++ b/Source/Expressive.Tests/Tokenisation/TokeniserTests.cs @@ -1,15 +1,15 @@ using System; using System.Linq; using Expressive.Tokenisation; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using NUnit.Framework; using Moq; namespace Expressive.Tests.Tokenisation { - [TestClass] + [TestFixture] public class TokeniserTests { - [TestMethod] + [Test] public void TestTokeniseFirstMatchWins() { var context = new Context(ExpressiveOptions.None); @@ -40,7 +40,7 @@ public void TestTokeniseFirstMatchWins() Assert.AreEqual("hello world", tokens.First().CurrentToken); } - [TestMethod] + [Test] public void TestTokeniseWithNull() { var tokeniser = new Tokeniser(new Context(ExpressiveOptions.None), Enumerable.Empty()); @@ -49,7 +49,7 @@ public void TestTokeniseWithNull() Assert.IsNull(tokeniser.Tokenise(string.Empty)); } - [TestMethod] + [Test] public void TestTokeniseWithSimple() { var context = new Context(ExpressiveOptions.None); @@ -67,7 +67,7 @@ public void TestTokeniseWithSimple() Assert.AreEqual("world", tokens.Last().CurrentToken); } - [TestMethod] + [Test] public void TestTokeniseWithUnrecognised() { var context = new Context(ExpressiveOptions.None);