public void TestUniqueWithSave() { //new up the repository EntitiesRepository<Customer, NorthwindEntities> ctx = new EntitiesRepository<Customer, NorthwindEntities>(new NorthwindEntities()); //new up a specification Specification<Customer> cust_spec = new Specification<Customer>(c => c.Country == "Germany" && c.CustomerID == "KOENE"); var unique_german_cust = ctx.Unique("Customers", cust_spec); var rand_num = new Random(DateTime.Now.Year).Next(); unique_german_cust.Orders.Add(new Order() { ShipName = "Nikovshi" + rand_num.ToString() }); ctx.Save(); Assert.IsNotNull(unique_german_cust); Console.WriteLine("The Unique customer ID is : {0}", unique_german_cust.CustomerID); }
public void FailTestForUnique() { //new up the repository EntitiesRepository<Customer, NorthwindEntities> ctx = new EntitiesRepository<Customer, NorthwindEntities>(new NorthwindEntities()); //new up a specification Specification<Customer> cust_spec = new Specification<Customer>(c => c.Country == "Germany"); var unique_german_cust = ctx.Unique("Customers", cust_spec); Assert.IsNotNull(unique_german_cust); Console.WriteLine("The Unique customer ID is : {0}", unique_german_cust.CustomerID); }