#region Imported Libraries using System; using System.Collections.Generic; using System.Linq; using System.Text; using NUnit; using NUnit.Framework; using System.Data.Objects; using Org.TechA.Data.Dsl2; #endregion #region Namespace Declaration namespace Org.TechA.Data.Dsl.Tests { [TestFixture] public class Class2 { [Test] public void prints_flattened_customer_and_orders_and_order_lines() { Console.WriteLine("**************prints_flattened_customer_and_orders_and_order_lines**************"); NorthwindLangQuery .BeginQuery() .Customers() .With_An_Id_Equal_To("ALFKI") .With_Orders_Shipped_From("Germany") .That() .Are() .Older_In_Years_By(2) .EndCustomerQuery() .Flatten_And_Print_To_Console_Window(); } [Test] public void prints_order_lines_grouped_by_customer_and_orders() { Console.WriteLine("**************prints_order_lines_grouped_by_customer_and_orders**************"); NorthwindLangQuery .BeginQuery() .Customers() .With_An_Id_Equal_To("ALFKI") .With_Orders_Shipped_From("Germany") .That() .Are() .Older_In_Years_By(2) .EndCustomerQuery() .Print_Customer_Orders_To_Console_Window(); } [Test] public void selects_customers_by_id() { Console.WriteLine("**************selects_customers_by_id**************"); var cust = NorthwindLangQuery .BeginQuery() .Customers() .With_An_Id_Equal_To("ALFKI") .EndCustomerQuery() .As_Unique_Where_Customers_Ids_Are_The_Same(); foreach (var c in cust) { Console.WriteLine(c.CompanyName); } } [Test] public void selects_orders_specified_by_age_of_orders_with_specified_freight_costs() { Console.WriteLine("**************selects_orders_specified_by_age_of_orders_with_specified_freight_costs**************"); var query = NorthwindLangQuery .BeginQuery() .Orders() .Older_In_Years_By(12) .With() .Freight_Costs_More_Than(360) .EndOrderQuery(); foreach (var o in query) { foreach (var ol in o.Order_Details) { Console.WriteLine(o.OrderID + " : " + o.Freight + " : " + ol.ProductID); } } } /// /// Would probably take a developers understanding of the data /// and structure of how the langauge queries work. /// [Test] public void selects_customers_by_id_for_advanced_users() { Console.WriteLine("**************selects_customers_by_id_for_advanced_users**************"); var cust = NorthwindLangQuery .BeginQuery() .Customers() .EndCustomerQuery() .As_Unique_Where((cLeft, cRight) => cLeft.CustomerID == cRight.CustomerID); foreach (var c in cust) { Console.WriteLine(c.CompanyName); } } } } #endregion