Here are the examples of the csharp api System.Collections.ObjectModel.Collection.RemoveAt(int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
622 Examples
19
Source : ViewsCollectionFixture.cs
with MIT License
from AvaloniaCommunity
with MIT License
from AvaloniaCommunity
[TestMethod]
public void OnRemoveNotifyCollectionChangedThenIndexProvided()
{
var originalCollection = new ObservableCollection<ItemMetadata>();
originalCollection.Add(new ItemMetadata("a"));
originalCollection.Add(new ItemMetadata("b"));
originalCollection.Add(new ItemMetadata("c"));
IViewsCollection viewsCollection = new ViewsCollection(originalCollection, (i) => true);
var eventTracker = new CollectionChangedTracker(viewsCollection);
originalCollection.RemoveAt(1);
var removeEvent = eventTracker.NotifyEvents.Single(e => e.Action == NotifyCollectionChangedAction.Remove);
replacedert.IsNotNull(removeEvent);
replacedert.AreEqual(1, removeEvent.OldStartingIndex);
}
19
Source : ViewsCollectionFixture.cs
with MIT License
from AvaloniaCommunity
with MIT License
from AvaloniaCommunity
[TestMethod]
public void OnRemoveOfFilterMatchingItemThenViewCollectionRelativeIndexProvided()
{
var originalCollection = new ObservableCollection<ItemMetadata>();
originalCollection.Add(new ItemMetadata("a"));
originalCollection.Add(new ItemMetadata("b"));
originalCollection.Add(new ItemMetadata("c"));
IViewsCollection viewsCollection = new ViewsCollection(originalCollection, (i) => !"b".Equals(i.Item));
var eventTracker = new CollectionChangedTracker(viewsCollection);
originalCollection.RemoveAt(2);
var removeEvent = eventTracker.NotifyEvents.Single(e => e.Action == NotifyCollectionChangedAction.Remove);
replacedert.IsNotNull(removeEvent);
replacedert.AreEqual(1, removeEvent.OldStartingIndex);
}
19
Source : ViewsCollectionFixture.cs
with MIT License
from AvaloniaCommunity
with MIT License
from AvaloniaCommunity
[TestMethod]
public void RemovingFromFilteredCollectionDoesNotThrow()
{
var originalCollection = new ObservableCollection<ItemMetadata>();
originalCollection.Add(new ItemMetadata("a"));
originalCollection.Add(new ItemMetadata("b"));
originalCollection.Add(new ItemMetadata("c"));
IViewsCollection viewsCollection = new ViewsCollection(originalCollection, (i) => true);
CollectionViewSource cvs = new CollectionViewSource {Source = viewsCollection};
var view = cvs.View;
try
{
originalCollection.RemoveAt(1);
}
catch (Exception ex)
{
replacedert.Fail(ex.Message);
}
}
19
Source : ModuleInfoGroup.cs
with MIT License
from AvaloniaCommunity
with MIT License
from AvaloniaCommunity
public void RemoveAt(int index)
{
this.modules.RemoveAt(index);
}
19
Source : ObserveAddRemoveCollection.cs
with MIT License
from AvaloniaUI
with MIT License
from AvaloniaUI
protected override void Sereplacedem(int index, T item)
{
_onRemove?.Invoke(this[index]);
try
{
_onAdd?.Invoke(item);
}
catch
{
// When adding the new item fails, just remove the old one
// (we cannot keep the old item since we already successfully called onRemove for it)
RemoveAt(index);
throw;
}
base.Sereplacedem(index, item);
}
19
Source : ConditionEditorViewModel.cs
with The Unlicense
from BAndysc
with The Unlicense
from BAndysc
private void DeleteItem()
{
if (SelectedParamIndex >= 0)
Source.Parameters.RemoveAt(SelectedParamIndex);
}
19
Source : TemplateDbTableEditorViewModel.cs
with The Unlicense
from BAndysc
with The Unlicense
from BAndysc
public override bool ForceRemoveEnreplacedy(DatabaseEnreplacedy enreplacedy)
{
var indexOfEnreplacedy = Enreplacedies.IndexOf(enreplacedy);
if (indexOfEnreplacedy == -1)
return false;
Enreplacedies.RemoveAt(indexOfEnreplacedy);
Header.RemoveAt(indexOfEnreplacedy);
foreach (var row in Rows.Items)
row.Cells.RemoveAt(indexOfEnreplacedy);
ReEvalVisibility();
return true;
}
19
Source : ConditionsDefinitionEditorViewModel.cs
with The Unlicense
from BAndysc
with The Unlicense
from BAndysc
private void DeleteItem()
{
if (SelectedIndex >= 0)
SourceItems.RemoveAt(SelectedIndex);
}
19
Source : ConditionSourceEditorViewModel.cs
with The Unlicense
from BAndysc
with The Unlicense
from BAndysc
private void DeleteSourceTarget()
{
if (SelectedTargetIndex >= 0)
Source.Targets.RemoveAt(SelectedTargetIndex);
}
19
Source : ConditionSourcesListEditorViewModel.cs
with The Unlicense
from BAndysc
with The Unlicense
from BAndysc
private void DeleteSource()
{
if (SelectedIndex >= 0)
SourceItems.RemoveAt(SelectedIndex);
}
19
Source : ConditionsEditorViewModel.cs
with The Unlicense
from BAndysc
with The Unlicense
from BAndysc
public void Drop(IDropInfo dropInfo)
{
if (dropInfo.Data is not ConditionViewModel data)
return;
int indexOf = Conditions.IndexOf(data);
int dropIndex = dropInfo.InsertIndex;
if (indexOf < dropIndex)
dropIndex--;
using var bulk = historyHandler.BulkEdit("Reorder conditions");
Conditions.RemoveAt(indexOf);
Conditions.Insert(dropIndex, data);
SelectedCondition = data;
}
19
Source : FunctionalExtensions.cs
with The Unlicense
from BAndysc
with The Unlicense
from BAndysc
public static void RemoveAll<T>(this ObservableCollection<T> collection)
{
for (int i = collection.Count - 1; i >= 0; --i)
collection.RemoveAt(i);
}
19
Source : MostRecentlySearchedService.cs
with The Unlicense
from BAndysc
with The Unlicense
from BAndysc
public void Add(string search)
{
mostRecentlySearched.Remove(search);
if (mostRecentlySearched.Count > MaxMostRecentlySearched)
mostRecentlySearched.RemoveAt(mostRecentlySearched.Count - 1);
mostRecentlySearched.Insert(0, search);
userSettings.Update(new Data(){MostRecentlySearched = mostRecentlySearched});
}
19
Source : SmartDataDefinesListViewModel.cs
with The Unlicense
from BAndysc
with The Unlicense
from BAndysc
private void DeleteSelectedItem()
{
if (SelectedItemIndex >= 0)
DefinesItems.RemoveAt(SelectedItemIndex);
}
19
Source : SmartDataEventsEditorViewModel.cs
with The Unlicense
from BAndysc
with The Unlicense
from BAndysc
private void DeleteItem()
{
switch (SelectedTab)
{
case 0:
if (SelectedParamIndex >= 0)
Source.Parameters.RemoveAt(SelectedParamIndex);
break;
case 1:
break;
case 2:
if (SelectedDescRuleIndex >= 0)
Source.DescriptionRules.RemoveAt(SelectedDescRuleIndex);
break;
}
}
19
Source : SmartDataTargetsEditorViewModel.cs
with The Unlicense
from BAndysc
with The Unlicense
from BAndysc
public void DeleteParam()
{
if (SelectedParamIndex >= 0)
Source.Parameters.RemoveAt(SelectedParamIndex);
}
19
Source : SolutionManager.cs
with The Unlicense
from BAndysc
with The Unlicense
from BAndysc
private void RemoveDuplicates(ObservableCollection<ISolutionItem> items, HashSet<ISolutionItem> added)
{
for (var index = items.Count - 1; index >= 0; index--)
{
var i = items[index];
if (i.Items != null)
RemoveDuplicates(i.Items, added);
if (!added.Add(items[index]))
items.RemoveAt(index);
}
}
19
Source : SmartDataActionsEditorViewModel.cs
with The Unlicense
from BAndysc
with The Unlicense
from BAndysc
private void DeleteSelectedParam()
{
if (SelectedParamIndex >= 0)
Source.Parameters.RemoveAt(selectedParamIndex);
}
19
Source : SmartScriptSolutionItem.cs
with The Unlicense
from BAndysc
with The Unlicense
from BAndysc
public void UpdateDependants(HashSet<long> usedTimed)
{
for (int i = Items.Count - 1; i >= 0; --i)
{
if (!usedTimed.Contains(((SmartScriptSolutionItem) Items[i]).Entry))
Items.RemoveAt(i);
else
usedTimed.Remove(((SmartScriptSolutionItem) Items[i]).Entry);
}
foreach (var t in usedTimed)
{
Items.Add(new SmartScriptSolutionItem((int)t, SmartScriptType.TimedActionList));
}
}
19
Source : SessionToolViewModel.cs
with The Unlicense
from BAndysc
with The Unlicense
from BAndysc
SubscribeAction(session =>
{
inHandler = true;
CurrentSolutionItems.Clear();
SelectedItem = null;
currentSessionStream?.Dispose();
currentSessionStream = null;
if (session == null)
{
SelectedSession = null;
inHandler = false;
return;
}
SelectedSession = Sessions.FirstOrDefault(s => s.FileName == session.FileName);
currentSessionStream = session
.ToStream(session.Select(t => t.Item1))
.SubscribeAction(ev =>
{
if (ev.Type == CollectionEventType.Add)
{
CurrentSolutionItems.Add(new SolutionItemViewModel(iconRegistry, nameRegistry, ev.Item));
}
else if (ev.Type == CollectionEventType.Remove)
{
CurrentSolutionItems.RemoveAt(ev.Index);
}
});
inHandler = false;
}
19
Source : HistoryManager.cs
with The Unlicense
from BAndysc
with The Unlicense
from BAndysc
private void EnsureLimits()
{
if (limit.HasValue && Past.Count == limit.Value)
Past.RemoveAt(0);
}
19
Source : HistoryManager.cs
with The Unlicense
from BAndysc
with The Unlicense
from BAndysc
public void Undo()
{
if (Past.Count == 0)
throw new NothingToUndoException();
IHistoryAction action = Past[^1];
Past.RemoveAt(Past.Count - 1);
Future.Insert(0, action);
acceptNew = false;
action.Undo();
acceptNew = true;
RecalculateValues();
}
19
Source : HistoryManager.cs
with The Unlicense
from BAndysc
with The Unlicense
from BAndysc
public void Redo()
{
if (Future.Count == 0)
throw new NothingToRedoException();
IHistoryAction action = Future[0];
Future.RemoveAt(0);
Past.Add(action);
acceptNew = false;
action.Redo();
acceptNew = true;
RecalculateValues();
}
19
Source : RecentFileList.cs
with MIT License
from barry-jones
with MIT License
from barry-jones
public void AddFile(RecentFile file)
{
RecentFile alreadyExisting = null;
// Check for and do not re-add an already stored file, just move its position
foreach(RecentFile current in this)
{
if(current.Filename == file.Filename)
{
alreadyExisting = current;
break;
}
}
if(alreadyExisting != null)
{
this.Remove(alreadyExisting);
this.Insert(0, alreadyExisting);
}
else
{
this.Insert(0, file);
if(this.Count > 10)
{
this.RemoveAt(this.Count - 1);
}
}
}
19
Source : ViewModel.cs
with MIT License
from beto-rodriguez
with MIT License
from beto-rodriguez
public void RemoveFirsreplacedem()
{
if (observableValues.Count < 2) return;
observableValues.RemoveAt(0);
}
19
Source : ViewModel.cs
with MIT License
from beto-rodriguez
with MIT License
from beto-rodriguez
private async Task ReadData()
{
await Task.Delay(1000);
while (true)
{
//Trace.WriteLine(
// $"Thread id: {Thread.CurrentThread.ManagedThreadId}");
await Task.Delay(_delay);
lock (Sync)
{
_values.Add(new ObservableValue(_r.Next(0, 10)));
_values.RemoveAt(0);
}
}
}
19
Source : ViewModel.cs
with MIT License
from beto-rodriguez
with MIT License
from beto-rodriguez
public void RemoveFirsreplacedem()
{
if (_observableValues.Count == 0) return;
_observableValues.RemoveAt(0);
}
19
Source : ViewModel.cs
with MIT License
from beto-rodriguez
with MIT License
from beto-rodriguez
public void RemoveLastSeries()
{
if (Series.Count == 1) return;
Series.RemoveAt(Series.Count - 1);
}
19
Source : ViewModel.cs
with MIT License
from beto-rodriguez
with MIT License
from beto-rodriguez
public void RemoveFirsreplacedem()
{
_observableValues.RemoveAt(0);
}
19
Source : MainWindow.xaml.cs
with GNU General Public License v3.0
from BigBang1112
with GNU General Public License v3.0
from BigBang1112
private async void buttonConvert_Click(object sender, RoutedEventArgs e)
{
var sheetMgr = new SheetManager(Sheets[0], new Sheet[] { Sheets[1] });
sheetMgr.UpdateDefinitions();
Directory.CreateDirectory("output");
textBlockProgress.Text = $"Conversion progress: 0/{Maps.Count}";
var conversions = new List<Task>();
var ignoreMediaTracker = checkBoxIgnoreMediaTracker.IsChecked.GetValueOrDefault();
checkBoxIgnoreMediaTracker.IsEnabled = false;
var clreplacedicMod = checkBoxClreplacedicMod.IsChecked.GetValueOrDefault();
checkBoxClreplacedicMod.IsEnabled = false;
foreach (var map in Maps)
{
var converter = new Converter()
{
Parameters = new ConverterParameters
{
Definitions = sheetMgr.Definitions,
ItemSkinPacks = sheetMgr.ItemSkinPacks,
IgnoreMediaTracker = ignoreMediaTracker,
ClreplacedicMod = clreplacedicMod
}
};
conversions.Add(Task.Run(() =>
{
converter.EmbedManager.CopyUsedEmbed(map.Map, sheetMgr.Definitions, converter.Parameters);
var chunk01F = map.Map.GetChunk<CGameCtnChallenge.Chunk0304301F>();
int version;
if (chunk01F.Version <= 1)
version = GameVersion.TMUF;
else
version = GameVersion.TM2;
try
{
converter.Convert(map.Map, version);
map.GBX.Save($"output/{System.IO.Path.GetFileNameWithoutExtension(System.IO.Path.GetFileNameWithoutExtension(map.GBX.FileName))}.Map.Gbx");
map.Converted = true;
textBlockProgress.Dispatcher.Invoke(() =>
textBlockProgress.Text = $"Conversion progress: {conversions.Where(x => x.IsCompleted).Count()}/{Maps.Count}"
);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Exception while converting", MessageBoxButton.OK, MessageBoxImage.Error);
}
}));
}
await Task.WhenAll(conversions);
textBlockProgress.Text = $"Conversion progress: {Maps.Count}/{Maps.Count}";
checkBoxIgnoreMediaTracker.IsEnabled = true;
checkBoxClreplacedicMod.IsEnabled = true;
MessageBox.Show("Conversion completed, your map(s) are available in the 'output' folder.\nPlease calculate shadows and resave your map(s)!", "Conversion completed!");
for (var i = Maps.Count - 1; i >= 0; i--)
if (Maps[i].Converted)
Maps.RemoveAt(i);
}
19
Source : MainWindow.xaml.cs
with GNU General Public License v3.0
from BigBang1112
with GNU General Public License v3.0
from BigBang1112
private void listViewMaps_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Delete)
{
while (listViewMaps.SelectedIndex > -1)
{
Maps.RemoveAt(listViewMaps.SelectedIndex);
}
}
}
19
Source : WpfLogEventSink.cs
with GNU General Public License v3.0
from Bililive
with GNU General Public License v3.0
from Bililive
private void AddLogToCollection(LogModel model)
{
try
{
Logs.Add(model);
while (Logs.Count > MAX_LINE)
Logs.RemoveAt(0);
}
catch (Exception) { }
}
19
Source : VeryObservableCollection.cs
with GNU General Public License v2.0
from BlackTasty
with GNU General Public License v2.0
from BlackTasty
public new void Clear()
{
try
{
base.Clear();
}
catch
{
observeChanges = false;
for (int i = 0; i < Count; i++)
RemoveAt(0);
observeChanges = true;
}
}
19
Source : VeryObservableCollection.cs
with GNU General Public License v2.0
from BlackTasty
with GNU General Public License v2.0
from BlackTasty
public void RemoveRange(int startIndex, int range)
{
observeChanges = false;
for (int i = startIndex; i < range; i++)
{
RemoveAt(startIndex);
}
observeChanges = true;
}
19
Source : FixedColorCollection.cs
with BSD 3-Clause "New" or "Revised" License
from Bluegrams
with BSD 3-Clause "New" or "Revised" License
from Bluegrams
public new void Add(Color item)
{
if (this.Count >= MaxLength)
this.RemoveAt(0);
base.Add(item);
}
19
Source : FixedColorCollection.cs
with BSD 3-Clause "New" or "Revised" License
from Bluegrams
with BSD 3-Clause "New" or "Revised" License
from Bluegrams
public new void Insert(int index, Color item)
{
if (this.Count >= MaxLength)
this.RemoveAt(this.Count - 1);
base.Insert(index, item);
}
19
Source : ImageEllipseRoiPicker.cs
with MIT License
from bonsai-rx
with MIT License
from bonsai-rx
void Canvas_KeyDown(object sender, KeyEventArgs e)
{
if (dragging) return;
if (e.KeyCode == Keys.PageUp) ImageScale += ScaleIncrement;
if (e.KeyCode == Keys.PageDown) ImageScale -= ScaleIncrement;
if (e.Control && e.KeyCode == Keys.Z) commandExecutor.Undo();
if (e.Control && e.KeyCode == Keys.Y) commandExecutor.Redo();
if (e.Control && e.KeyCode == Keys.V)
{
var roiText = (string)Clipboard.GetData(DataFormats.Text);
try
{
var mousePosition = PointToClient(MousePosition);
var offset = NormalizedLocation(mousePosition.X, mousePosition.Y);
var roiData = (float[])ArrayConvert.ToArray(roiText, 1, typeof(float));
var center = new Point2f(offset.X, offset.Y);
var size = new Size2f(roiData[0], roiData[1]);
var roi = new RotatedRect(center, size, 0);
var selection = selectedRoi;
commandExecutor.Execute(
() => AddRegion(roi),
() => { regions.Remove(roi); SelectedRegion = selection; });
}
catch (ArgumentException) { }
catch (InvalidCastException) { }
catch (FormatException) { }
}
if (selectedRoi.HasValue)
{
if (e.Control && e.KeyCode == Keys.C)
{
var roi = regions[selectedRoi.Value];
var roiData = new[] { roi.Size.Width, roi.Size.Height };
Clipboard.SetData(DataFormats.Text, ArrayConvert.ToString(roiData));
}
if (e.KeyCode == Keys.Delete)
{
var selection = selectedRoi.Value;
var region = regions[selection];
commandExecutor.Execute(
() => { regions.RemoveAt(selection); SelectedRegion = null; },
() => { regions.Insert(selection, region); SelectedRegion = selection; });
}
}
}
19
Source : ImageRoiPicker.cs
with MIT License
from bonsai-rx
with MIT License
from bonsai-rx
void Canvas_KeyDown(object sender, KeyEventArgs e)
{
if (dragging) return;
if (e.KeyCode == Keys.PageUp) ImageScale += ScaleIncrement;
if (e.KeyCode == Keys.PageDown) ImageScale -= ScaleIncrement;
if (e.Control && e.KeyCode == Keys.Z) commandExecutor.Undo();
if (e.Control && e.KeyCode == Keys.Y) commandExecutor.Redo();
if (e.Control && e.KeyCode == Keys.V)
{
var roiText = (string)Clipboard.GetData(DataFormats.Text);
try
{
var mousePosition = PointToClient(MousePosition);
var offset = NormalizedLocation(mousePosition.X, mousePosition.Y);
var roiData = (int[])ArrayConvert.ToArray(roiText, 1, typeof(int));
var roi = new Point[roiData.Length / 2];
for (int i = 0, k = 0; i < roi.Length && k < roiData.Length; i++, k += 2)
{
roi[i].X = roiData[k + 0] - roiData[0] + offset.X;
roi[i].Y = roiData[k + 1] - roiData[1] + offset.Y;
}
var selection = selectedRoi;
commandExecutor.Execute(
() => AddRegion(roi),
() => { regions.Remove(roi); SelectedRegion = selection; });
}
catch (ArgumentException) { }
catch (InvalidCastException) { }
catch (FormatException) { }
}
if (selectedRoi.HasValue)
{
if (e.Control && e.KeyCode == Keys.C)
{
var roi = regions[selectedRoi.Value];
var roiData = new int[roi.Length * 2];
for (int i = 0, k = 0; i < roi.Length && k < roiData.Length; i++, k += 2)
{
roiData[k + 0] = roi[i].X;
roiData[k + 1] = roi[i].Y;
}
Clipboard.SetData(DataFormats.Text, ArrayConvert.ToString(roiData));
}
if (e.KeyCode == Keys.Delete)
{
var selection = selectedRoi.Value;
var region = regions[selection];
commandExecutor.Execute(
() => { regions.RemoveAt(selection); SelectedRegion = null; },
() => { regions.Insert(selection, region); SelectedRegion = selection; });
}
}
}
19
Source : PingMonitorHostViewModel.cs
with GNU General Public License v3.0
from BornToBeRoot
with GNU General Public License v3.0
from BornToBeRoot
private void RemoveHost(int hostId)
{
var index = -1;
foreach (var host in Hosts)
{
if (host.HostId == hostId)
index = Hosts.IndexOf(host);
}
if (index != -1)
{
Hosts[index].CloseView();
Hosts.RemoveAt(index);
}
}
19
Source : JoystickMode.xaml.cs
with GNU General Public License v3.0
from BrianLima
with GNU General Public License v3.0
from BrianLima
private void Item_Click(object sender, RoutedEventArgs e)
{
//Using the Uid to store the index of this item on the StackPanel
//Surelly not be a good practice, but it prevents the need of a lot of ((type)sender).Parent
int index = int.Parse(((MenuItem)sender).Uid);
StackColors.Children.RemoveAt(index);
buttonsToColors.RemoveAt(index);
joystickHelper.SaveJoystickButtons(buttonsToColors.ToList(), guids[combo_joysticks.SelectedIndex]);
}
19
Source : Window1.xaml.cs
with MIT License
from bstollnitz
with MIT License
from bstollnitz
void DelegateUIThreadNotWorking_Thread2()
{
Thread.Sleep(100); // do a little work
beginInvokePlaces.RemoveAt(0);
}
19
Source : Window1.xaml.cs
with MIT License
from bstollnitz
with MIT License
from bstollnitz
public void ClearSubKeys(RegistryKeyHolder3 parentKeyHolder)
{
int indexToRemove = this.allKeys.IndexOf(parentKeyHolder) + 1;
while ((indexToRemove < this.allKeys.Count) && (this.allKeys[indexToRemove].Level > parentKeyHolder.Level))
{
this.allKeys.RemoveAt(indexToRemove);
this.DataItemsCount--;
}
}
19
Source : ViewModel.cs
with MIT License
from bstollnitz
with MIT License
from bstollnitz
protected override void RemoveItem(int index)
{
base.RemoveItem(index);
originalCollection.RemoveAt(index);
}
19
Source : Window1.xaml.cs
with MIT License
from bstollnitz
with MIT License
from bstollnitz
void LockingOperations_Thread2()
{
lock (lockObject)
{
Thread.Sleep(100); // do a little work
invokePlaces.RemoveAt(0);
}
}
19
Source : Page1.xaml.cs
with MIT License
from bstollnitz
with MIT License
from bstollnitz
private void RemoveButton_Click(object sender, RoutedEventArgs e)
{
int index = random.Next(this.cities.Count);
this.cities.RemoveAt(index);
}
19
Source : Window1.xaml.cs
with MIT License
from bstollnitz
with MIT License
from bstollnitz
void CrashMe()
{
throwPlaces.RemoveAt(0);
}
19
Source : Window1.xaml.cs
with MIT License
from bstollnitz
with MIT License
from bstollnitz
void DontCrashMe()
{
beginInvokePlaces.RemoveAt(0);
}
19
Source : AdaptiveCollection.cs
with MIT License
from CalciumFramework
with MIT License
from CalciumFramework
protected override void RemoveItem(int index)
{
if (ignoreChanges)
{
base.RemoveItem(index);
return;
}
monitoredCollection.RemoveAt(index);
}
19
Source : AdaptiveCollectionTests.cs
with MIT License
from CalciumFramework
with MIT License
from CalciumFramework
[TestMethod]
public void AdaptiveCollection_ShouldRemoveOuterItem()
{
const int itemCount = 10;
(ObservableCollection<int> observableCollection, AdaptiveCollection<AttachableStringMock<int>, int> adaptiveCollection) = CreateCollection(itemCount);
NotifyCollectionChangedEventArgs eventArgs = null;
adaptiveCollection.CollectionChanged += (sender, e) => { eventArgs = e; };
void PerformRemoveTest(int removeIndex)
{
int length = observableCollection.Count;
var attachedItemToRemove = adaptiveCollection[removeIndex];
observableCollection.RemoveAt(removeIndex);
replacedert.AreEqual(length - 1, observableCollection.Count);
replacedert.AreEqual(length - 1, adaptiveCollection.Count);
replacedertEqualStrings(observableCollection, adaptiveCollection);
replacedert.IsNotNull(eventArgs);
replacedert.AreEqual(NotifyCollectionChangedAction.Remove, eventArgs.Action);
replacedert.AreEqual(eventArgs.OldItems[0], attachedItemToRemove);
}
PerformRemoveTest(0);
PerformRemoveTest(observableCollection.Count - 1);
PerformRemoveTest(observableCollection.Count / 2);
}
19
Source : ReadOnlyAdaptiveCollectionTests.cs
with MIT License
from CalciumFramework
with MIT License
from CalciumFramework
[TestMethod]
public void ReadOnlyAdaptiveCollection_ShouldRemoveItem()
{
const int itemCount = 10;
(ObservableCollection<int> observableCollection, ReadOnlyAdaptiveCollection<AttachableStringMock<int>, int> adaptiveCollection) = CreateCollection(itemCount);
NotifyCollectionChangedEventArgs eventArgs = null;
adaptiveCollection.CollectionChanged += (sender, e) => { eventArgs = e; };
void PerformRemoveTest(int removeIndex)
{
int length = observableCollection.Count;
var attachedItemToRemove = adaptiveCollection[removeIndex];
observableCollection.RemoveAt(removeIndex);
replacedert.AreEqual(length - 1, observableCollection.Count);
replacedert.AreEqual(length - 1, adaptiveCollection.Count);
replacedertEqualStrings(observableCollection, adaptiveCollection);
replacedert.IsNotNull(eventArgs);
replacedert.AreEqual(NotifyCollectionChangedAction.Remove, eventArgs.Action);
replacedert.AreEqual(eventArgs.OldItems[0], attachedItemToRemove);
}
PerformRemoveTest(0);
PerformRemoveTest(observableCollection.Count - 1);
PerformRemoveTest(observableCollection.Count / 2);
}
See More Examples