public void ListOfChanges_AfterSerialized_CanDeserialize() { var changeList = new List <ChangeWrapper> { new ChangeWrapper { Hash = "hash", Path = "path", Status = ChangeType.Moved } }; var responseWrapper = new ResponseWrapper <ChangeWrapper[]> { ResponseObject = changeList.ToArray() }; string xml = Serialization.SerializeResponse <ChangeWrapper[]>(responseWrapper); var deserializedResponse = Serialization.DeserializeResponse <ChangeWrapper[]> (xml); var deserializedChangelist = (ChangeWrapper[])deserializedResponse.ResponseObject; Assert.That(changeList.Count == deserializedChangelist.Length); for (int index = 0; index < changeList.Count; index++) { ChangeWrapper change = changeList[index]; Assert.That(change.Hash == deserializedChangelist[index].Hash); Assert.That(change.Path == deserializedChangelist[index].Path); Assert.That(change.Status == deserializedChangelist[index].Status); } }
private void ReportNewOrUpdateExistingChange(SledModifiedProjectChange change, ChangeWrapper existing) { var wrapper = new ChangeWrapper(change) { Category = UserCategory.Pending }; // Default category if (existing == null) { // Create node representing change var lstItem = new ListViewItem(wrapper.Change.ToString()) { Tag = wrapper }; // Set references wrapper.Item = lstItem; // Add to list m_lstChanges.Items.Add(lstItem); } else { // Update existing item existing.Update(change); } }
private static int CompareChangeWrapperToChangeWrapper(ChangeWrapper wrapper1, ChangeWrapper wrapper2) { // Check categories if (wrapper1.Category != wrapper2.Category) { return(CompareCategories(wrapper1.Category, wrapper2.Category)); } // Compare actual changes if (wrapper1.Change.ChangeType == wrapper2.Change.ChangeType) { var retval = 0; switch (wrapper1.Change.ChangeType) { case SledModifiedProjectChangeType.FileAdded: retval = CompareFileAddedChanges( wrapper1.Change as SledModifiedProjectFileAddedChange, wrapper2.Change as SledModifiedProjectFileAddedChange); break; case SledModifiedProjectChangeType.FileRemoved: retval = CompareFileRemovedChanges( wrapper1.Change as SledModifiedProjectFileRemovedChange, wrapper2.Change as SledModifiedProjectFileRemovedChange); break; } return(retval); } return(wrapper1.Change.ChangeType < wrapper2.Change.ChangeType ? -1 : 1); }
private static int CompareCategoryToChangeWrapper(UserCategory cat, ChangeWrapper wrapper) { if (cat == wrapper.Category) { return(-1); } return(CompareCategories(cat, wrapper.Category)); }
/// <summary> /// Helper method to convert a given ChangeWrapper object into the format Collab expects /// </summary> /// <param name="changeWrapper">ChangeWrapper containing Change info</param> /// <returns></returns> internal static ChangeItem ChangeWrapperToCollabChangeItem(ChangeWrapper changeWrapper) { CollabStates state; switch (changeWrapper.Status) { case ChangeType.Modified: state = CollabStates.kCollabCheckedOutLocal; break; case ChangeType.Added: state = CollabStates.kCollabAddedLocal; break; case ChangeType.Deleted: state = CollabStates.kCollabDeletedLocal; break; case ChangeType.Moved: case ChangeType.Renamed: state = CollabStates.kCollabMovedLocal; break; case ChangeType.Ignored: state = CollabStates.kCollabIgnored; break; default: state = CollabStates.kCollabNone; break; } if (changeWrapper.IsFolder) { state |= CollabStates.kCollabFolderMetaFile; state |= CollabStates.kCollabMetaFile; } return(new ChangeItem { Path = changeWrapper.Path, State = state, Hash = changeWrapper.Hash }); }
private static int CompareChangeWrapperToChangeWrapper(ChangeWrapper wrapper1, ChangeWrapper wrapper2) { // Check categories if (wrapper1.Category != wrapper2.Category) return CompareCategories(wrapper1.Category, wrapper2.Category); // Compare actual changes if (wrapper1.Change.ChangeType == wrapper2.Change.ChangeType) { var retval = 0; switch (wrapper1.Change.ChangeType) { case SledModifiedProjectChangeType.FileAdded: retval = CompareFileAddedChanges( wrapper1.Change as SledModifiedProjectFileAddedChange, wrapper2.Change as SledModifiedProjectFileAddedChange); break; case SledModifiedProjectChangeType.FileRemoved: retval = CompareFileRemovedChanges( wrapper1.Change as SledModifiedProjectFileRemovedChange, wrapper2.Change as SledModifiedProjectFileRemovedChange); break; } return retval; } return wrapper1.Change.ChangeType < wrapper2.Change.ChangeType ? -1 : 1; }
private static int CompareCategoryToChangeWrapper(UserCategory cat, ChangeWrapper wrapper) { if (cat == wrapper.Category) return -1; return CompareCategories(cat, wrapper.Category); }