public void EntityConflict_Resolve() { TestEntityContainer ec = new TestEntityContainer(); EntitySet<Product> set = ec.Products; Product current = new Product { ProductID = 1, Color = "Red", ProductNumber = "1234" }; set.LoadEntity(current); // create a conflict and resolve current.Color += "X"; Product store = new Product { ProductID = 1, Color = "Red", ProductNumber = "4321" }; EntityConflict conflict = new EntityConflict(current, store, new string[] { "ProductNumber" }, false); current.EntityConflict = conflict; Assert.AreEqual(EntityState.Modified, current.EntityState); var originalState = conflict.OriginalEntity.ExtractState(); Assert.IsTrue((string)originalState["Color"] == "Red" && (string)originalState["ProductNumber"] == "1234"); conflict.Resolve(); // verify that calling Resolve multiple // times is a no-op conflict.Resolve(); conflict.Resolve(); // resolve should update the original state originalState = current.GetOriginal().ExtractState(); Assert.IsTrue((string)originalState["Color"] == "Red" && (string)originalState["ProductNumber"] == "4321"); // current state should not be modified Assert.AreEqual("RedX", current.Color); Assert.AreEqual("1234", current.ProductNumber); // the conflict should be cleared out Assert.IsNull(current.EntityConflict); }
public void EntityConflict_Resolve_DeleteConflict() { // create a delete conflict and attempt to resolve Product current = new Product { ProductID = 1, Color = "Red", ProductNumber = "1234" }; EntityConflict conflict = new EntityConflict(current, null, new string[] { "ProductNumber" }, true); Assert.IsTrue(conflict.IsDeleted); current.EntityConflict = conflict; ExceptionHelper.ExpectInvalidOperationException(delegate { conflict.Resolve(); }, Resource.EntityConflict_CannotResolveDeleteConflict); }
public void RemoveEventRelayed() { Product first = new Product(); Product second = new Product(); NotifyingCollection<Product> source = new NotifyingCollection<Product>() { first, second }; PagedEntityCollectionView<Product> view = new PagedEntityCollectionView<Product>(source); this.AssertCollectionChanged( () => source.Remove(first), view, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, first, 0), "when removing the first item."); }
public void AddEventRelayed() { Product first = new Product(); Product second = new Product(); NotifyingCollection<Product> source = new NotifyingCollection<Product>() { first, second }; PagedEntityCollectionView<Product> view = new PagedEntityCollectionView<Product>(source); Product third = new Product(); this.AssertCollectionChanged( () => source.Add(third), view, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, third, 2), "when adding the third item."); }
public void ResetEventRelayed() { Product first = new Product(); Product second = new Product(); NotifyingCollection<Product> source = new NotifyingCollection<Product>() { first, second }; PagedEntityCollectionView<Product> view = new PagedEntityCollectionView<Product>(source); this.AssertCollectionChanged( () => source.Reset(), view, new NotifyCollectionChangedEventArgs[] { new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset), new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset), // Bug 706239 }, "when resetting the collection."); }
partial void DeleteProduct(Product instance);
partial void UpdateProduct(Product instance);
partial void InsertProduct(Product instance);
private void detach_Products(Product entity) { this.SendPropertyChanging(); entity.ProductModel = null; }
private void attach_Products(Product entity) { this.SendPropertyChanging(); entity.ProductModel = this; }
private void detach_Products1(Product entity) { this.SendPropertyChanging(); entity.UnitMeasure1 = null; }
private void attach_Products(Product entity) { this.SendPropertyChanging(); entity.UnitMeasure = this; }
private void detach_Products(Product entity) { this.SendPropertyChanging(); entity.ProductSubcategory = null; }
public void BitwiseOperatorsNotSupported() { IQueryable<Product> prodQuery = new Product[0].AsQueryable(); // Bitwise NOT not supported NotSupportedException expectedException = null; try { QuerySerializer.Serialize(prodQuery.Where(p => ~p.ProductID != 0)); } catch (NotSupportedException e) { expectedException = e; } Assert.IsNotNull(expectedException); Assert.AreEqual(OpenRiaServices.DomainServices.Client.Services.Resource.QuerySerialization_BitwiseOperatorsNotSupported, expectedException.Message); // Bitwise AND not supported expectedException = null; try { QuerySerializer.Serialize(prodQuery.Where(p => (p.ProductID & 0x0F00) != 0)); } catch (NotSupportedException e) { expectedException = e; } Assert.IsNotNull(expectedException); Assert.AreEqual(OpenRiaServices.DomainServices.Client.Services.Resource.QuerySerialization_BitwiseOperatorsNotSupported, expectedException.Message); // Bitwise OR not supported expectedException = null; try { QuerySerializer.Serialize(prodQuery.Where(p => (p.ProductID | 0x0F00) != 0)); } catch (NotSupportedException e) { expectedException = e; } Assert.IsNotNull(expectedException); Assert.AreEqual(OpenRiaServices.DomainServices.Client.Services.Resource.QuerySerialization_BitwiseOperatorsNotSupported, expectedException.Message); // Bitwise XOR not supported expectedException = null; try { QuerySerializer.Serialize(prodQuery.Where(p => (p.ProductID ^ 0x0F00) != 0)); } catch (NotSupportedException e) { expectedException = e; } Assert.IsNotNull(expectedException); Assert.AreEqual(OpenRiaServices.DomainServices.Client.Services.Resource.QuerySerialization_BitwiseOperatorsNotSupported, expectedException.Message); // Bitwise Left Shift not supported expectedException = null; try { QuerySerializer.Serialize(prodQuery.Where(p => (p.ProductID << 3) != 0)); } catch (NotSupportedException e) { expectedException = e; } Assert.IsNotNull(expectedException); Assert.AreEqual(OpenRiaServices.DomainServices.Client.Services.Resource.QuerySerialization_BitwiseOperatorsNotSupported, expectedException.Message); // Bitwise Right Shift not supported expectedException = null; try { QuerySerializer.Serialize(prodQuery.Where(p => (p.ProductID >> 3) != 0)); } catch (NotSupportedException e) { expectedException = e; } Assert.IsNotNull(expectedException); Assert.AreEqual(OpenRiaServices.DomainServices.Client.Services.Resource.QuerySerialization_BitwiseOperatorsNotSupported, expectedException.Message); }
private bool FilterProduct(Product entity) { return (entity.ProductID == this.ProductID); }