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 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_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)); } }