public void EntityConflict_PropertyNames_ReadOnly() { string[] propertyNames = new[] { "Property1", "Property2", }; EntityConflict entityConflict = new EntityConflict(new MockEntity(), new MockEntity(), propertyNames, false); Assert.IsInstanceOfType(entityConflict.PropertyNames, typeof(ReadOnlyCollection <string>)); }
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); }
private async void MergingServiceOnMergingConflictsAquired() { _mergingConflicts = _mergingService.MergingConflicts; if (_mergingConflicts.ProjectConfict != null) { await ResolveProjectConflict(); } if (_mergingConflicts.TaskStatesConflicts.Any()) { var unconflictedTaskStates = (await _taskStateStorageService.GetAll()).ToList(); TaskStateConflict = new EntityConflict <TaskStatesCollectionViewModel> { OurValue = new TaskStatesCollectionViewModel(_mergingConflicts.TaskStatesConflicts.Select(x => x.OurValue).Where(x => x != null) .Concat(unconflictedTaskStates).Distinct().OrderBy(x => x.Position)), AncestorValue = new TaskStatesCollectionViewModel(_mergingConflicts.TaskStatesConflicts.Select(x => x.AncestorValue).Where(x => x != null) .Concat(unconflictedTaskStates).Distinct().OrderBy(x => x.Position)), TheirValue = new TaskStatesCollectionViewModel(_mergingConflicts.TaskStatesConflicts.Select(x => x.TheirValue).Where(x => x != null) .Concat(unconflictedTaskStates).Distinct().OrderBy(x => x.Position)) }; } else { TaskStateConflict = null; OnTaskStatesConflictResolved(); } IsLoading = false; }
public void EntityConflict_IsDeleted() { EntityConflict entityConflict = new EntityConflict(new MockEntity(), null, null, true); Assert.AreEqual(true, entityConflict.IsDeleted, "Expected 'IsDeleted' to be true."); ExceptionHelper.ExpectInvalidOperationException( () => entityConflict.PropertyNames.ToArray() /* touch 'PropertyNames' to get an exception */, Resource.EntityConflict_IsDeleteConflict); }
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 EntityConflict_PropertyNames() { string[] propertyNames = new[] { "Property1", "Property2" }; EntityConflict entityConflict = new EntityConflict(new MockEntity(), new MockEntity(), propertyNames, false); Assert.AreEqual(false, entityConflict.IsDeleted, "Expected 'IsDeleted' to be false."); Assert.IsNotNull(entityConflict.PropertyNames, "Expected 'PropertyNames' to not be null."); Assert.AreEqual(2, entityConflict.PropertyNames.Count(), "Expected 2 properties in 'PropertyNames'."); string[] confictMembers = entityConflict.PropertyNames.ToArray(); for (int i = 0; i < confictMembers.Length; i++) { Assert.AreEqual(propertyNames[i], confictMembers[i]); } }
private void OnTaskConflictResolved() { _mergingService.MarkMergedConflict(); _currentTaskConflictIndex++; IsOkButtonEnabled = false; if (_mergingConflicts.TaskConflicts.Count <= _currentTaskConflictIndex) { CurrentTaskConflictViewModel = null; } else { var currentTaskConflict = _mergingConflicts.TaskConflicts[_currentTaskConflictIndex]; CurrentTaskConflictViewModel = new EntityConflict <TaskContentViewModel> { OurValue = new TaskContentViewModel(currentTaskConflict.OurValue), TheirValue = new TaskContentViewModel(currentTaskConflict.TheirValue), AncestorValue = new TaskContentViewModel(currentTaskConflict.AncestorValue) }; } }
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); }
private void OnTaskStatesConflictResolved() { _mergingService.MarkMergedConflict(); IsOkButtonEnabled = false; TaskStateConflict = null; if (_mergingConflicts.TaskConflicts.Any()) { _currentTaskConflictIndex = 0; var currentTaskConflict = _mergingConflicts.TaskConflicts.First(); CurrentTaskConflictViewModel = new EntityConflict <TaskContentViewModel> { OurValue = new TaskContentViewModel(currentTaskConflict.OurValue), TheirValue = new TaskContentViewModel(currentTaskConflict.TheirValue), AncestorValue = new TaskContentViewModel(currentTaskConflict.AncestorValue) }; } else { CurrentTaskConflictViewModel = null; } }
public void EntityConflict_PropertyNames_ReadOnly() { string[] propertyNames = new[] { "Property1", "Property2", }; EntityConflict entityConflict = new EntityConflict(new MockEntity(), new MockEntity(), propertyNames, false); Assert.IsInstanceOfType(entityConflict.PropertyNames, typeof(ReadOnlyCollection<string>)); }
public void EntityConflict_PropertyNames() { string[] propertyNames = new[] { "Property1", "Property2" }; EntityConflict entityConflict = new EntityConflict(new MockEntity(), new MockEntity(), propertyNames, false); Assert.AreEqual(false, entityConflict.IsDeleted, "Expected 'IsDeleted' to be false."); Assert.IsNotNull(entityConflict.PropertyNames, "Expected 'PropertyNames' to not be null."); Assert.AreEqual(2, entityConflict.PropertyNames.Count(), "Expected 2 properties in 'PropertyNames'."); string[] confictMembers = entityConflict.PropertyNames.ToArray(); for(int i=0;i<confictMembers.Length;i++) { Assert.AreEqual(propertyNames[i], confictMembers[i]); } }