public void GetYearTest() { string expected = "GetYear([RegistrationDate])"; string actual = CriteriaBuilder.Build <TestContext, int>(c => c.RegistrationDate.Year).ToString(); Assert.AreEqual(expected, actual); }
public void AverageTest() { string expected = "[Accounts][].Avg([Amount]) = 75.0m"; string actual = CriteriaBuilder.Build <TestContext, bool>(c => c.Accounts.Average(a => a.Amount) == 75).ToString(); Assert.AreEqual(expected, actual); }
public void SingleWithExpressionTest() { string expected = "[Accounts][].Single([Amount])"; string actual = CriteriaBuilder.Build <TestContext, decimal>(c => c.Accounts.SingleOrDefault().Amount).ToString(); Assert.AreEqual(expected, actual); }
public void CountTest() { string expected = "[Accounts][].Count() > 1"; string actual = CriteriaBuilder.Build <TestContext, bool>(c => c.Accounts.Count() > 1).ToString(); Assert.AreEqual(expected, actual); }
public void SumTest() { string expected = "[Accounts][].Sum([Amount]) > 150.0m"; string actual = CriteriaBuilder.Build <TestContext, bool>(c => c.Accounts.Sum(a => a.Amount) > 150).ToString(); Assert.AreEqual(expected, actual); }
public void ToLongCastTest() { string expected = "ToLong([Angle])"; string actual = CriteriaBuilder.Build <TestContext, long>(c => (long)c.Angle).ToString(); Assert.AreEqual(expected, actual); }
public void StartsWithTest() { string expected = "StartsWith([Name], 'J')"; string actual = CriteriaBuilder.Build <TestContext, bool>(c => c.Name.StartsWith("J")).ToString(); Assert.AreEqual(expected, actual); }
public void PowerTest() { string expected = "Power([Angle], 2.0)"; string actual = CriteriaBuilder.Build <TestContext, double>(c => Math.Pow(c.Angle, 2)).ToString(); Assert.AreEqual(expected, actual); }
public void RemoveWithNumberToTest() { string expected = "Remove([Name], 2, 1)"; string actual = CriteriaBuilder.Build <TestContext, string>(c => c.Name.Remove(2, 1)).ToString(); Assert.AreEqual(expected, actual); }
public void PadLeftTest() { string expected = "PadLeft([Name], 10)"; string actual = CriteriaBuilder.Build <TestContext, string>(c => c.Name.PadLeft(10)).ToString(); Assert.AreEqual(expected, actual); }
public void PadRightCharacterTest() { string expected = "PadRight([Name], 10, '\u0066'c)"; string actual = CriteriaBuilder.Build <TestContext, string>(c => c.Name.PadRight(10, '\u0066')).ToString(); Assert.AreEqual(expected, actual); }
public void MinTest() { string expected = "Min([Angle], 0.5)"; string actual = CriteriaBuilder.Build <TestContext, double>(c => Math.Min(c.Angle, .5)).ToString(); Assert.AreEqual(expected, actual); }
public void IsNullOrEmptyTest() { string expected = "IsNullOrEmpty([Name])"; string actual = CriteriaBuilder.Build <TestContext, bool>(c => string.IsNullOrEmpty(c.Name)).ToString(); Assert.AreEqual(expected, actual); }
public void InsertTest() { string expected = "Insert([Name], 1, 'a')"; string actual = CriteriaBuilder.Build <TestContext, string>(c => c.Name.Insert(1, "a")).ToString(); Assert.AreEqual(expected, actual); }
public void LenTest() { string expected = "Len([Name]) > 3"; string actual = CriteriaBuilder.Build <TestContext, bool>(c => c.Name.Length > 3).ToString(); Assert.AreEqual(expected, actual); }
public void ReplaceTest() { string expected = "Replace([Name], 'oh', '**')"; string actual = CriteriaBuilder.Build <TestContext, string>(c => c.Name.Replace("oh", "**")).ToString(); Assert.AreEqual(expected, actual); }
public void ToIntCastTest() { string expected = "ToInt([Angle])"; string actual = CriteriaBuilder.Build <TestContext, int>(c => (int)c.Angle).ToString(); Assert.AreEqual(expected, actual); }
public void RoundWithDecimalPlacesTest() { string expected = "Round([Angle], 2)"; string actual = CriteriaBuilder.Build <TestContext, double>(c => Math.Round(c.Angle, 2)).ToString(); Assert.AreEqual(expected, actual); }
public void LowerTest() { string expected = "Lower([Name]) Like '%jo%'"; string actual = CriteriaBuilder.Build <TestContext, bool>(c => CustomFunctions.Like(c.Name.ToLower(), "%jo%")).ToString(); Assert.AreEqual(expected, actual); }
public void SignTest() { string expected = "Sign([Angle])"; string actual = CriteriaBuilder.Build <TestContext, int>(c => Math.Sign(c.Angle)).ToString(); Assert.AreEqual(expected, actual); }
public void AndTest() { string expected = "[Name] = 'John' And [Age] = 30"; string actual = CriteriaBuilder.Build <TestContext, bool>(c => c.Name == "John" && c.Age == 30).ToString(); Assert.AreEqual(expected, actual); }
public void TanhTest() { string expected = "Tanh([Angle])"; string actual = CriteriaBuilder.Build <TestContext, double>(c => Math.Tanh(c.Angle)).ToString(); Assert.AreEqual(expected, actual); }
public void ExistsTest() { string expected = "[Accounts][]"; string actual = CriteriaBuilder.Build <TestContext, bool>(c => c.Accounts.Any()).ToString(); Assert.AreEqual(expected, actual); }
public void ToDecimalCastTest() { string expected = "ToDecimal([Angle])"; string actual = CriteriaBuilder.Build <TestContext, decimal>(c => (decimal)c.Angle).ToString(); Assert.AreEqual(expected, actual); }
public void SingleTest() { string expected = "[Accounts][].Single() <> null"; string actual = CriteriaBuilder.Build <TestContext, bool>(c => c.Accounts.SingleOrDefault() != null).ToString(); Assert.AreEqual(expected, actual); }
public void ToDoubleCastTest() { string expected = "ToDouble([Age])"; string actual = CriteriaBuilder.Build <TestContext, double>(c => (double)c.Age).ToString(); Assert.AreEqual(expected, actual); }
public void SingleWithConditionTest() { string expected = "[Accounts][[Amount] > 10.0m].Single()"; string actual = CriteriaBuilder.Build <TestContext, Account>(c => c.Accounts.SingleOrDefault(a => a.Amount > 10)).ToString(); Assert.AreEqual(expected, actual); }
public void ToFloatTest() { string expected = "ToFloat([Angle])"; string actual = CriteriaBuilder.Build <TestContext, float>(c => Convert.ToSingle(c.Angle)).ToString(); Assert.AreEqual(expected, actual); }
public void ExistsWithConditionTest() { string expected = "[Accounts][[Amount] > 10.0m]"; string actual = CriteriaBuilder.Build <TestContext, bool>(c => c.Accounts.Any(a => a.Amount > 10)).ToString(); Assert.AreEqual(expected, actual); }
public void GetTimeOfDayTest() { string expected = "GetTimeOfDay([RegistrationDate])"; string actual = CriteriaBuilder.Build <TestContext, TimeSpan>(c => c.RegistrationDate.TimeOfDay).ToString(); Assert.AreEqual(expected, actual); }