Exemplo n.º 1
0
        private void AddRecentFile(string newFile)
        {
            if (_recentFiles.FirstOrDefault() == newFile)
            {
                return;
            }

            if (_recentFiles.FindAndMakeRecent(str => str == newFile) == null)
            {
                _recentFiles.Add(newFile);
            }

            var builder = new StringBuilder();

            foreach (var file in _recentFiles)
            {
                builder.Append(file);
                builder.Append(';');
            }
            builder.Length--;

            var persistance = ServiceRepository.Instance.FindService <IPersistantDataRepository>();

            persistance.SetValue("RecentFiles", builder.ToString());

            RecentFiles = _recentFiles.ToArray();
        }
Exemplo n.º 2
0
        public void TestFindAndMakeRecentTwoItems()
        {
            _buffer.Add("One");
            _buffer.Add("Two");
            Assert.That(_buffer.Count, Is.EqualTo(2));
            Assert.That(_buffer.ToArray(), Is.EquivalentTo(new[] { "Two", "One" }));

            Assert.That(_buffer.FindAndMakeRecent(i => i == "Two"), Is.EqualTo("Two"));
            Assert.That(_buffer.ToArray(), Is.EquivalentTo(new[] { "Two", "One" }));

            Assert.That(_buffer.FindAndMakeRecent(i => i == "One"), Is.EqualTo("One"));
            Assert.That(_buffer.ToArray(), Is.EquivalentTo(new[] { "One", "Two" }));
        }