Remove() публичный Метод

Removes the specified recent file.
The argument recentFile must not be null. The argument recentFile was not found in the recent files list.
public Remove ( RecentFile recentFile ) : void
recentFile RecentFile The recent file to remove.
Результат void
Пример #1
0
        public void Remove()
        {
            RecentFileList recentFileList = new RecentFileList();

            AssertHelper.ExpectedException<ArgumentNullException>(() => recentFileList.Remove(null));

            recentFileList.AddFile("Doc1");
            recentFileList.AddFile("Doc2");
            recentFileList.AddFile("Doc3");

            RecentFile lastAdded = recentFileList.RecentFiles.First();

            recentFileList.Remove(recentFileList.RecentFiles.Last());
            Assert.IsTrue(recentFileList.RecentFiles.Select(f => f.Path).SequenceEqual(new[] { "Doc3", "Doc2" }));
            recentFileList.Remove(recentFileList.RecentFiles.First());
            Assert.IsTrue(recentFileList.RecentFiles.Select(f => f.Path).SequenceEqual(new[] { "Doc2" }));
            recentFileList.Remove(recentFileList.RecentFiles.First());
            Assert.IsTrue(!recentFileList.RecentFiles.Any());

            // Try to delete a RecentFile object which was already deleted.
            AssertHelper.ExpectedException<ArgumentException>(() => recentFileList.Remove(lastAdded));
        }