public void GetChunk_OffsetOutOfRange_EmptyByteArray() { using (var e = new PushStorageEnvForTest()) { string text = "sample"; var bundleHelper = new PushStorageManager(e.PullDataFolderPath, "randomHash"); File.WriteAllText(bundleHelper.BundlePath, text); byte[] chunk = bundleHelper.GetChunk(10, 5); // offset is greater than string length Assert.That(chunk.Length, Is.EqualTo(0)); } }
public void GetChunk_LengthTooLarge_ReturnsAdjustedByteArray() { using (var e = new PushStorageEnvForTest()) { string text = "sample"; var bundleHelper = new PushStorageManager(e.PullDataFolderPath, "randomHash"); File.WriteAllText(bundleHelper.BundlePath, text); byte[] chunk = bundleHelper.GetChunk(3, 10); // offset is greater than string length Assert.That(Encoding.UTF8.GetString(chunk), Is.EqualTo("ple")); } }
public void GetChunk_MiddleBytes_Ok() { using (var e = new PushStorageEnvForTest()) { string text = "This is some sample text to be used by the push bundle helper tests"; var bundleHelper = new PushStorageManager(e.PullDataFolderPath, "randomHash"); File.WriteAllText(bundleHelper.BundlePath, text); byte[] chunk = bundleHelper.GetChunk(10, 5); Assert.That(Encoding.UTF8.GetString(chunk), Is.EqualTo("me sa")); } }
public PullHandlerApiServerForTest(HgRepository repo, ProgressForTest progress) { const string identifier = "PullHandlerApiServerForTest"; _storageFolder = new TemporaryFolder(identifier); _repo = repo; _progress = progress; _helper = new PushStorageManager(_storageFolder.Path, "randomHash"); Host = identifier; ProjectId = "SampleProject"; _executeCount = 0; _failCount = -1; _timeoutList = new List <int>(); _serverUnavailableList = new List <ServerUnavailableResponse>(); OriginalTip = ""; }