public void SerializeAndDeserialize()
        {
            var mruCollection = new MostRecentlyUsedCollection();
            for (int i = 0; i <= mruCollection.MaximumSize; i++)
            {
                mruCollection.Add(
                    string.Format(
                        CultureInfo.InvariantCulture,
                        @"c:\temp\myfile{0}.txt",
                        i));
            }

            var converter = new MostRecentlyUsedCollectionConverter();
            var serializedCollection = converter.ConvertTo(null, CultureInfo.InvariantCulture, mruCollection, typeof(string));
            var deserializedCollection = converter.ConvertFrom(
                null,
                CultureInfo.InvariantCulture,
                serializedCollection) as MostRecentlyUsedCollection;

            Assert.That(deserializedCollection.Select(m => m.FilePath), Is.EquivalentTo(mruCollection.Select(m => m.FilePath)));
            Assert.That(deserializedCollection.Select(m => m.LastTimeOpened), Is.EquivalentTo(mruCollection.Select(m => m.LastTimeOpened)));
        }
示例#2
0
        public void SerializeAndDeserialize()
        {
            var mruCollection = new MostRecentlyUsedCollection();

            for (int i = 0; i <= mruCollection.MaximumSize; i++)
            {
                mruCollection.Add(
                    string.Format(
                        CultureInfo.InvariantCulture,
                        @"c:\temp\myfile{0}.txt",
                        i));
            }

            var converter              = new MostRecentlyUsedCollectionConverter();
            var serializedCollection   = converter.ConvertTo(null, CultureInfo.InvariantCulture, mruCollection, typeof(string));
            var deserializedCollection = converter.ConvertFrom(
                null,
                CultureInfo.InvariantCulture,
                serializedCollection) as MostRecentlyUsedCollection;

            Assert.That(deserializedCollection.Select(m => m.FilePath), Is.EquivalentTo(mruCollection.Select(m => m.FilePath)));
            Assert.That(deserializedCollection.Select(m => m.LastTimeOpened), Is.EquivalentTo(mruCollection.Select(m => m.LastTimeOpened)));
        }