public void TestBasicDuplicate_Decal() { ReadableDuplicateStream target = new ReadableDuplicateStream(_FS, 3, 4); target.CanWrite.Should().BeFalse(); target.CanRead.Should().BeTrue(); target.CanSeek.Should().BeTrue(); target.Length.Should().Be(2); var cpt = EnumerableFactory.CreateList(3, i => target.ReadByte()); cpt[2].Should().Be(-1); cpt.Take(2).Should().Equal(1,1); }
public void TestBasicDuplicate_Decal_Seek() { ReadableDuplicateStream target = new ReadableDuplicateStream(_FS, 2, 4); target.CanWrite.Should().BeFalse(); target.CanRead.Should().BeTrue(); target.CanSeek.Should().BeTrue(); target.Length.Should().Be(3); var cpt = EnumerableFactory.CreateListWhile(() => { int r = target.ReadByte(); return (r == -1) ? new Tuple<bool, byte>(false, 0) : new Tuple<bool, byte>(true,(byte)r); }); cpt.Count.Should().Be(3); cpt.Should().Equal((byte)0, (byte)1, (byte)1); target.ReadByte().Should().Be(-1); target.Seek(1, SeekOrigin.Begin); var cpt2 = EnumerableFactory.CreateListWhile(() => { int r = target.ReadByte(); return (r == -1) ? new Tuple<bool, byte>(false, 0) : new Tuple<bool, byte>(true, (byte)r); }); cpt2.Should().Equal((byte)1, (byte)1); target.Seek(-3, SeekOrigin.End); var cpt3 = EnumerableFactory.CreateListWhile(() => { int r = target.ReadByte(); return (r == -1) ? new Tuple<bool, byte>(false, 0) : new Tuple<bool, byte>(true, (byte)r); }); cpt3.Should().Equal((byte)0, (byte)1, (byte)1); }
public void TestBasicDuplicate_2() { ReadableDuplicateStream target = new ReadableDuplicateStream(_FS, 0, 5); target.CanWrite.Should().BeFalse(); target.CanRead.Should().BeTrue(); target.CanSeek.Should().BeTrue(); target.Length.Should().Be(5); var cpt = EnumerableFactory.CreateList(6, i => target.ReadByte()); cpt[5].Should().Be(-1); cpt.Take(5).Select(i=>(byte)i).Should().Equal(this.GetFirstbuffer()); }