Ejemplo n.º 1
0
        public void CanTranslateRequestRangeToObjectRanges()
        {
            var blobs = new[]
            {
                new Blob(Range.ByLength(0L, 10L), "foo"),
                new Blob(Range.ByLength(10L, 10L), "foo"),
                new Blob(Range.ByLength(20L, 10L), "foo"),
                new Blob(Range.ByLength(0L, 15L), "bar"),
                new Blob(Range.ByLength(15L, 15L), "bar"),
            };
            var rt = new RequestToObjectRangeTranslator(
                new[]
            {
                new[] { Range.ByLength(5L, 5L) }.ToGrouping(blobs[0]),
                new[]
                {
                    Range.ByLength(10L, 5L),
                    Range.ByLength(17L, 3L),
                }.ToGrouping(blobs[1]),
                new[] { Range.ByLength(20L, 7L) }.ToGrouping(blobs[2]),
            }.ToLookup()
                );

            CollectionAssert.AreEqual(
                new[]
            {
                ContextRange.Create(Range.ByPosition(5L, 9L), "foo"),
            },
                rt.Translate(ContextRange.Create(Range.ByLength(0L, 5L), blobs[0])).ToArray()
                );
            CollectionAssert.AreEqual(
                new[]
            {
                ContextRange.Create(Range.ByPosition(10L, 14L), "foo"),
                ContextRange.Create(Range.ByPosition(17L, 19L), "foo"),
            },
                rt.Translate(ContextRange.Create(Range.ByLength(0L, 8L), blobs[1])).ToArray()
                );
            CollectionAssert.AreEqual(
                new[]
            {
                ContextRange.Create(Range.ByPosition(20L, 26L), "foo"),
            },
                rt.Translate(ContextRange.Create(Range.ByLength(0L, 8L), blobs[2])).ToArray()
                );
        }
 public void CanTranslateRequestRangeToObjectRanges()
 {
     var blobs = new[]
     {
         new Ds3.Helpers.Blob(Range.ByLength(0L, 10L), "foo"),
         new Ds3.Helpers.Blob(Range.ByLength(10L, 10L), "foo"),
         new Ds3.Helpers.Blob(Range.ByLength(20L, 10L), "foo"),
         new Ds3.Helpers.Blob(Range.ByLength(0L, 15L), "bar"),
         new Ds3.Helpers.Blob(Range.ByLength(15L, 15L), "bar"),
     };
     var rt = new RequestToObjectRangeTranslator(
         new[]
         {
             new[] {Range.ByLength(5L, 5L)}.ToGrouping(blobs[0]),
             new[]
             {
                 Range.ByLength(10L, 5L),
                 Range.ByLength(17L, 3L),
             }.ToGrouping(blobs[1]),
             new[] {Range.ByLength(20L, 7L)}.ToGrouping(blobs[2]),
         }.ToLookup()
     );
     CollectionAssert.AreEqual(
         new[]
         {
             ContextRange.Create(Range.ByPosition(5L, 9L), "foo"),
         },
         rt.Translate(ContextRange.Create(Range.ByLength(0L, 5L), blobs[0])).ToArray()
     );
     CollectionAssert.AreEqual(
         new[]
         {
             ContextRange.Create(Range.ByPosition(10L, 14L), "foo"),
             ContextRange.Create(Range.ByPosition(17L, 19L), "foo"),
         },
         rt.Translate(ContextRange.Create(Range.ByLength(0L, 8L), blobs[1])).ToArray()
     );
     CollectionAssert.AreEqual(
         new[]
         {
             ContextRange.Create(Range.ByPosition(20L, 26L), "foo"),
         },
         rt.Translate(ContextRange.Create(Range.ByLength(0L, 8L), blobs[2])).ToArray()
     );
 }