public void Count_DeclaredMethod_ReturnsCount()
        {
            var lazy       = new Lazy <IEnumerable <string> >(() => new[] { "SomeValue" });
            var collection = new LazyReadOnlyCollection <string>(lazy, 1);

            Assert.AreEqual(1, collection.Count);
        }
        public void Contains_UnknownValue_ReturnsFalse()
        {
            var lazy       = new Lazy <IEnumerable <string> >(() => new[] { "SomeValue" });
            var collection = new LazyReadOnlyCollection <string>(lazy, 1);

            Assert.IsFalse(collection.Contains("AnotherValue"));
        }
        public void Count_EnumerableExtensionMethod_ReturnsCount()
        {
            var lazy = new Lazy<IEnumerable<string>>(() => new[] { "SomeValue" });
            var collection = new LazyReadOnlyCollection<string>(lazy, 1);

            Assert.AreEqual(1, collection.Count());
        }
 internal AbstractArchive(ArchiveType type, IEnumerable <Stream> streams, Options options)
 {
     this.Type   = type;
     lazyVolumes =
         new LazyReadOnlyCollection <TVolume>(LoadVolumes(streams.Select <Stream, Stream>(CheckStreams), options));
     lazyEntries = new LazyReadOnlyCollection <TEntry>(LoadEntries(Volumes));
 }
Example #5
0
 internal AbstractArchive(ArchiveType type, IEnumerable <Stream> streams, ReaderOptions readerOptions)
 {
     Type          = type;
     ReaderOptions = readerOptions;
     lazyVolumes   = new LazyReadOnlyCollection <TVolume>(LoadVolumes(streams.Select(CheckStreams)));
     lazyEntries   = new LazyReadOnlyCollection <TEntry>(LoadEntries(Volumes));
 }
        public void Contains_UnknownValue_ReturnsFalse()
        {
            var lazy = new Lazy<IEnumerable<string>>(() => new[] { "SomeValue" });
            var collection = new LazyReadOnlyCollection<string>(lazy, 1);

            Assert.IsFalse(collection.Contains("AnotherValue"));
        }
Example #7
0
 internal AbstractArchive(ArchiveType type, IEnumerable <Stream> streams, Options options, string password)
 {
     Type        = type;
     Password    = password;
     lazyVolumes = new LazyReadOnlyCollection <TVolume>(LoadVolumes(CheckStreams(streams), options));
     lazyEntries = new LazyReadOnlyCollection <TEntry>(LoadEntries(Volumes));
 }
Example #8
0
 internal AbstractArchive(ArchiveType type, IEnumerable <Stream> streams, Options options, string password)
 {
     this.Type        = type;
     this.Password    = password;
     this.lazyVolumes = new LazyReadOnlyCollection <TVolume>(this.LoadVolumes(Enumerable.Select <Stream, Stream>(streams, new Func <Stream, Stream>(AbstractArchive <TEntry, TVolume> .CheckStreams)), options));
     this.lazyEntries = new LazyReadOnlyCollection <TEntry>(this.LoadEntries(this.Volumes));
 }
Example #9
0
 internal AbstractArchive(ArchiveType type, SourceStream srcStream)
 {
     Type          = type;
     ReaderOptions = srcStream.ReaderOptions;
     SrcStream     = srcStream;
     lazyVolumes   = new LazyReadOnlyCollection <TVolume>(LoadVolumes(SrcStream));
     lazyEntries   = new LazyReadOnlyCollection <TEntry>(LoadEntries(Volumes));
 }
Example #10
0
        protected CodeTreeNode(string text, ImageSource icon, IEnumerable <CodeTreeNode> childNodesSource)
        {
            this.Text       = text;
            this.Icon       = icon;
            this.childNodes = new LazyReadOnlyCollection <CodeTreeNode>(childNodesSource);

            this.visible = true;
        }
        public void ToList_CollectionWithoutItems_ReturnsList()
        {
            var lazy       = new Lazy <IEnumerable <string> >(() => new string[] {});
            var collection = new LazyReadOnlyCollection <string>(lazy, 0);

            var list = collection.ToList();

            Assert.AreEqual(0, list.Count);
        }
        public void ToList_CollectionWithItems_ReturnsList()
        {
            var lazy       = new Lazy <IEnumerable <string> >(() => new[] { "SomeValue" });
            var collection = new LazyReadOnlyCollection <string>(lazy, 1);

            var list = collection.ToList();

            Assert.AreEqual(1, list.Count);
        }
Example #13
0
 /// <summary>
 /// Constructor with a FileInfo object to an existing file.
 /// </summary>
 /// <param name="fileInfo"></param>
 /// <param name="options"></param>
 internal RarArchive(FileInfo fileInfo, RarOptions options)
 {
     if (!fileInfo.Exists)
     {
         throw new ArgumentException("File does not exist: " + fileInfo.FullName);
     }
     lazyVolumes = new LazyReadOnlyCollection <RarArchiveVolume>(RarArchiveVolumeFactory.GetParts(fileInfo, options));
     lazyEntries = new LazyReadOnlyCollection <RarArchiveEntry>(RarArchiveEntry.GetEntries(this, Volumes));
 }
        public void GetNonGenericEnumerator_ReturnsEnumerator()
        {
            var lazy = new Lazy<IEnumerable<string>>(() => new[] { "SomeValue" });
            var collection = new LazyReadOnlyCollection<string>(lazy, 1);

            IEnumerator enumerator = ((IEnumerable)collection).GetEnumerator();

            Assert.IsNotNull(enumerator);
        }
Example #15
0
 /// <summary>
 /// Constructor with a FileInfo object to an existing file.
 /// </summary>
 /// <param name="fileInfo"></param>
 /// <param name="options"></param>
 internal RarArchive(FileInfo fileInfo, RarOptions options)
 {
     if (!fileInfo.Exists)
     {
         throw new ArgumentException("File does not exist: " + fileInfo.FullName);
     }
     lazyVolumes = new LazyReadOnlyCollection<RarArchiveVolume>(RarArchiveVolumeFactory.GetParts(fileInfo, options));
     lazyEntries = new LazyReadOnlyCollection<RarArchiveEntry>(RarArchiveEntry.GetEntries(this, Volumes));
 }
        public void GetNonGenericEnumerator_ReturnsEnumerator()
        {
            var lazy       = new Lazy <IEnumerable <string> >(() => new[] { "SomeValue" });
            var collection = new LazyReadOnlyCollection <string>(lazy, 1);

            IEnumerator enumerator = ((IEnumerable)collection).GetEnumerator();

            Assert.IsNotNull(enumerator);
        }
Example #17
0
 internal AbstractArchive(ArchiveType type, IEnumerable <Stream> streams, Options options)
 {
     this.Type = type;
     if (AbstractArchive <TEntry, TVolume> .< > f__mg$cache0 == null)
     {
         AbstractArchive <TEntry, TVolume> .< > f__mg$cache0 = new Func <Stream, Stream>(AbstractArchive <TEntry, TVolume> .CheckStreams);
     }
     this.lazyVolumes = new LazyReadOnlyCollection <TVolume>(this.LoadVolumes(streams.Select <Stream, Stream>(AbstractArchive <TEntry, TVolume> .< > f__mg$cache0), options));
     this.lazyEntries = new LazyReadOnlyCollection <TEntry>(this.LoadEntries(this.Volumes));
 }
Example #18
0
 internal AbstractArchive(ArchiveType type, FileInfo fileInfo, Options options)
 {
     this.Type = type;
     if (!fileInfo.Exists)
     {
         throw new ArgumentException("File does not exist: " + fileInfo.FullName);
     }
     options     = (Options)FlagUtility.SetFlag(options, Options.KeepStreamsOpen, false);
     lazyVolumes = new LazyReadOnlyCollection <TVolume>(LoadVolumes(fileInfo, options));
     lazyEntries = new LazyReadOnlyCollection <TEntry>(LoadEntries(Volumes));
 }
        /// <summary>
        /// Constructor with a FileInfo object to an existing file.
        /// </summary>
        /// <param name="fileInfo"></param>
        /// <param name="options"></param>
        internal AbstractArchive(FileInfo fileInfo, Options options)
        {
            if (!fileInfo.Exists)
            {
                throw new ArgumentException("File does not exist: " + fileInfo.FullName);
            }

            lazyVolumes = new LazyReadOnlyCollection <TVolume>(LoadVolumes(fileInfo, options));

            lazyEntries = new LazyReadOnlyCollection <TEntry>(LoadEntries(Volumes));
        }
        public void TestLazyForEachIsAppliedWhenEnumerating()
        {
            var source = Enumerable.Range(0, 10)
                                   .Select(i => new MutableClass { Text = i.ToString() });

            var collection = new LazyReadOnlyCollection<MutableClass>(source);
            collection.LazyForEach(m => m.Text = "changed");

            foreach (var item in collection) {
                Assert.AreEqual("changed", item.Text);
            }
        }
Example #21
0
 internal AbstractArchive(ArchiveType type, FileInfo fileInfo, ReaderOptions readerOptions)
 {
     Type = type;
     if (!fileInfo.Exists)
     {
         throw new ArgumentException("File does not exist: " + fileInfo.FullName);
     }
     ReaderOptions = readerOptions;
     readerOptions.LeaveStreamOpen = false;
     lazyVolumes = new LazyReadOnlyCollection <TVolume>(LoadVolumes(fileInfo));
     lazyEntries = new LazyReadOnlyCollection <TEntry>(LoadEntries(Volumes));
 }
        public void TestLazyForEachIsAppliedWhenEnumerating()
        {
            var source = Enumerable.Range(0, 10)
                         .Select(i => new MutableClass {
                Text = i.ToString()
            });

            var collection = new LazyReadOnlyCollection <MutableClass>(source);

            collection.LazyForEach(m => m.Text = "changed");

            foreach (var item in collection)
            {
                Assert.AreEqual("changed", item.Text);
            }
        }
Example #23
0
 internal AbstractArchive(ArchiveType type)
 {
     Type        = type;
     lazyVolumes = new LazyReadOnlyCollection <TVolume>(Enumerable.Empty <TVolume>());
     lazyEntries = new LazyReadOnlyCollection <TEntry>(Enumerable.Empty <TEntry>());
 }
        public void ToList_CollectionWithItems_ReturnsList()
        {
            var lazy = new Lazy<IEnumerable<string>>(() => new[] { "SomeValue" });
            var collection = new LazyReadOnlyCollection<string>(lazy, 1);

            var list = collection.ToList();

            Assert.AreEqual(1, list.Count);
        }
        public void ToList_CollectionWithoutItems_ReturnsList()
        {
            var lazy = new Lazy<IEnumerable<string>>(() => new string[] {});
            var collection = new LazyReadOnlyCollection<string>(lazy, 0);

            var list = collection.ToList();

            Assert.AreEqual(0, list.Count);
        }
 /// <summary>
 /// Takes multiple seekable Streams for a multi-part archive
 /// </summary>
 /// <param name="streams"></param>
 /// <param name="options"></param>
 internal AbstractArchive(IEnumerable <Stream> streams, Options options)
 {
     lazyVolumes = new LazyReadOnlyCollection <TVolume>(LoadVolumes(streams, options));
     lazyEntries = new LazyReadOnlyCollection <TEntry>(LoadEntries(Volumes));
 }
Example #27
0
 /// <summary>
 /// Takes multiple seekable Streams for a multi-part archive
 /// </summary>
 /// <param name="streams"></param>
 /// <param name="options"></param>
 internal RarArchive(IEnumerable<Stream> streams, RarOptions options)
 {
     lazyVolumes = new LazyReadOnlyCollection<RarArchiveVolume>(RarArchiveVolumeFactory.GetParts(streams, options));
     lazyEntries = new LazyReadOnlyCollection<RarArchiveEntry>(RarArchiveEntry.GetEntries(this, Volumes));
 }
Example #28
0
 /// <summary>
 /// Takes multiple seekable Streams for a multi-part archive
 /// </summary>
 /// <param name="streams"></param>
 /// <param name="options"></param>
 internal RarArchive(IEnumerable <Stream> streams, RarOptions options)
 {
     lazyVolumes = new LazyReadOnlyCollection <RarArchiveVolume>(RarArchiveVolumeFactory.GetParts(streams, options));
     lazyEntries = new LazyReadOnlyCollection <RarArchiveEntry>(RarArchiveEntry.GetEntries(this, Volumes));
 }