public void TestModifyForRetry2() { Stream stream = new MemoryStream(); stream.Position = 10; var currentTryBefore = 0; IEnumerable<Range> rages = new List<Range>(); ITransferrer transferrer = new ReadTransferrer(); BestEffort.ModifyForRetry(stream, 5, ref currentTryBefore, "Test", 10, ref rages, ref transferrer, new Ds3ContentLengthNotMatch("", 0, 0)); Assert.AreEqual(1, currentTryBefore); Assert.AreEqual(9, stream.Position); }
public void TestZeroRetries() { var client = new Mock<IDs3Client>(MockBehavior.Strict); MockHelpers.SetupGetObjectWithContentLengthMismatchException(client, "bar", 0L, "ABCDEFGHIJ", 20L, 10L); // The initial request is for all 20 bytes, but only the first 10 will be sent try { var stream = new MemoryStream(200); var exceptionTransferrer = new ReadTransferrer(); var decorator = new PartialDataTransferrerDecorator(exceptionTransferrer, 0); decorator.Transfer(client.Object, JobResponseStubs.BucketName, "bar", 0, JobResponseStubs.JobId, new List<Range>(), stream); Assert.Fail(); } catch (Ds3NoMoreRetriesException e) { Assert.AreEqual(0, e.Retries); } }
public void Test1Retries() { var client = new Mock<IDs3Client>(MockBehavior.Strict); MockHelpers.SetupGetObjectWithContentLengthMismatchException(client, "bar", 0L, "ABCDEFGHIJ", 20L, 10L); MockHelpers.SetupGetObjectWithContentLengthMismatchException(client, "bar", 0L, "ABCDEFGHIJ", 20L, 10L, Range.ByPosition(9, 19)); try { var stream = new MemoryStream(200); var exceptionTransferrer = new ReadTransferrer(); var decorator = new PartialDataTransferrerDecorator(exceptionTransferrer, 1); decorator.Transfer(client.Object, JobResponseStubs.BucketName, "bar", 0, JobResponseStubs.JobId, new List<Range>(), stream); Assert.Fail(); } catch (Ds3NoMoreRetriesException e) { Assert.AreEqual(1, e.Retries); } }
public void Test1Retries() { var client = new Mock<IDs3Client>(MockBehavior.Strict); MockHelpers.SetupGetObjectWithContentLengthMismatchException(client, "bar", 0L, "ABCDEFGHIJ", 20L, 10L); MockHelpers.SetupGetObjectWithContentLengthMismatchException(client, "bar", 0L, "ABCDEFGHIJ", 20L, 10L, Range.ByPosition(9, 19)); try { var stream = new MemoryStream(200); var exceptionTransferrer = new ReadTransferrer(); var retries = 1; var decorator = new PartialDataTransferrerDecorator(exceptionTransferrer, retries); decorator.Transfer(client.Object, JobResponseStubs.BucketName, "bar", 0, JobResponseStubs.JobId, new List<Range>(), stream, null, null, retries); Assert.Fail(); } catch (Ds3NoMoreRetransmitException ex) { var expectedMessage = string.Format(Resources.NoMoreRetransmitException, "1", "bar", "0"); Assert.AreEqual(expectedMessage, ex.Message); Assert.AreEqual(1, ex.Retries); } }