public void GetAllHasInDB() { List <PurchasePolicy> expected = new List <PurchasePolicy>(); expected.Add(UsernameEqualsLeaf2); expected.Add(UsernameEqualsLeaf); expected.Add(QuantityLessThanLeaf); expected.Add(QuantityGreaterThanLeaf); expected.Add(PriceLessThanLeaf); expected.Add(PriceGreaterThanLeaf); expected.Add(AddressEqualsLeaf); UsernameEqualsLeaf2.IsRoot = true; UsernameEqualsLeaf.IsRoot = true; QuantityLessThanLeaf.IsRoot = true; QuantityGreaterThanLeaf.IsRoot = true; PriceLessThanLeaf.IsRoot = true; PriceGreaterThanLeaf.IsRoot = true; AddressEqualsLeaf.IsRoot = true; datalayer.SavePolicy(UsernameEqualsLeaf2); datalayer.SavePolicy(UsernameEqualsLeaf); datalayer.SavePolicy(QuantityLessThanLeaf); datalayer.SavePolicy(QuantityGreaterThanLeaf); datalayer.SavePolicy(PriceLessThanLeaf); datalayer.SavePolicy(PriceGreaterThanLeaf); datalayer.SavePolicy(AddressEqualsLeaf); List <PurchasePolicy> found = datalayer.GetAllPolicies(); Assert.AreEqual(expected.Count, found.Count); PurchasePolicy[] foundaray = found.ToArray(); PurchasePolicy[] expectedaray = expected.ToArray(); for (int i = 0; i < expectedaray.Length; i++) { Assert.AreEqual(expectedaray[i], foundaray[i]); } }
public void AddPolicy(int policyId) { PurchasePolicy toAdd = GetPolicy(policyId); if (toAdd == null) { throw new MarketException(4, "No policies to save, try again."); } toAdd.IsRoot = true; toAdd.ID = RandomPolicyID(); Policies.Add(toAdd); SessionPolicies.Clear(); _dataLayer.SavePolicy(toAdd); }
public void SaveUsernameEqualsLeaf2() { UsernameEqualsLeaf2.IsRoot = true; datalayer.SavePolicy(UsernameEqualsLeaf2); Assert.AreEqual(UsernameEqualsLeaf2, datalayer.GetPolicy(PolicyType.Global, "bla")); }
public void RemoveUsernameEqualsLeaf2() { UsernameEqualsLeaf2.IsRoot = true; datalayer.SavePolicy(UsernameEqualsLeaf2); datalayer.RemovePolicy(UsernameEqualsLeaf2); Assert.IsNull(datalayer.GetPolicy(PolicyType.Global, "bla")); }