public void Valid_item_and_failed_IfMatch_throws_condition_failed() { TestContainer.Create(); Write(TestItem, Guid.Empty); ExpectConditionFailed(() => TryToRead(TestItem, StreamingCondition.IfMatch("asd"))); }
public void Valid_item_and_valid_IfNoneMatch_delete() { TestContainer.Create(); Write(TestItem, Guid.Empty); TestItem.Delete(StreamingCondition.IfNoneMatch("random")); TestItem.GetInfo().ShouldFail(); }
public void Valid_item_and_valid_match_wild_return() { TestContainer.Create(); var g = Guid.NewGuid(); Write(TestItem, g); ShouldHaveGuid(TestItem, g, StreamingCondition.IfMatch("*")); }
public void Valid_item_and_valid_IfNoneMatch_exact_return() { TestContainer.Create(); var g = Guid.NewGuid(); Write(TestItem, g); ShouldHaveGuid(TestItem, g, StreamingCondition.IfNoneMatch("none")); }
public void Valid_item_and_valid_IfMatch_exact_return() { TestContainer.Create(); var g = Guid.NewGuid(); Write(TestItem, g); var tag = TestItem.GetInfo().Value.ETag; ShouldHaveGuid(TestItem, g, StreamingCondition.IfMatch(tag)); }
protected void ShouldHaveBytes(IStreamingItem streamingItem, byte[] bytes, StreamingCondition condition = default(StreamingCondition)) { StreamingItemInfo streamingItemInfo = null; byte[] actualBytes = null; using (var ms = new MemoryStream()) { streamingItem.ReadInto((properties, stream) => { stream.CopyTo(ms); actualBytes = ms.ToArray(); streamingItemInfo = properties; }, condition); } Assert.AreEqual(bytes, actualBytes); Assert.That(streamingItemInfo.ETag, Is.Not.Empty); }
protected void ShouldHaveGuid(IStreamingItem streamingItem, Guid g, StreamingCondition condition = default(StreamingCondition)) { var set = false; Guid actual = Guid.Empty; StreamingItemInfo streamingItemInfo = null; streamingItem.ReadInto((properties, stream) => { var b = new byte[16]; stream.Read(b, 0, 16); actual = new Guid(b); set = true; streamingItemInfo = properties; }, condition); Assert.AreEqual(g, actual); Assert.That(streamingItemInfo.ETag, Is.Not.Empty); set = true; Assert.IsTrue(set); }
public void Valid_item_and_valid_IfNoneMatch_returns_info() { TestContainer.Create(); Write(TestItem, Guid.Empty); TestItem.GetInfo(StreamingCondition.IfNoneMatch("never")).ShouldPass(); }
public void Valid_item_and_failed_IfMatch_returns_empty() { TestContainer.Create(); Write(TestItem, Guid.Empty); TestItem.GetInfo(StreamingCondition.IfMatch("mismatch")).ShouldFail(); }
public void Conditional_append_works() { TestContainer.Create(); Write(TestItem, Guid.Empty, StreamingCondition.IfNoneMatch("tag")); }
public void Failed_IfMatch_throws_condition_failed() { TestContainer.Create(); ExpectConditionFailed(() => Write(TestItem, Guid.Empty, StreamingCondition.IfMatch("tag"))); }
public void Missing_item_and_valid_IfNoneMatch_succeed() { TestContainer.Create(); Write(TestItem, Guid.Empty, StreamingCondition.IfNoneMatch("none")); ShouldHaveGuid(TestItem, Guid.Empty); }
public void Missing_item_and_failed_IfMatch_throw_condition_failed() { TestContainer.Create(); ExpectConditionFailed(() => Write(TestItem, Guid.Empty, StreamingCondition.IfMatch("none"))); }
public void Missing_container_and_failed_IfMatch_throw_item_not_found() { ExpectContainerNotFound(() => Write(TestItem, Guid.Empty, StreamingCondition.IfMatch("none"))); }
protected void Write(IStreamingItem streamingItem, byte[] bytes, StreamingCondition condition = default(StreamingCondition)) { streamingItem.Write(stream => stream.Write(bytes, 0, bytes.Length), condition, WriteOptions); }
protected void TryToRead(IStreamingItem item, StreamingCondition condition = default(StreamingCondition)) { item.ReadInto((props, stream) => stream.Read(new byte[1], 0, 1), condition); }
protected void Write(IStreamingItem streamingItem, Guid g, StreamingCondition condition = default(StreamingCondition)) { streamingItem.Write(stream => stream.Write(g.ToByteArray(), 0, 16), condition, WriteOptions); }
public void Missing_item_and_IfMatch_throw_item_not_found() { TestContainer.Create(); ExpectItemNotFound(() => TryToRead(TestItem, StreamingCondition.IfMatch("mismatch"))); }
public void Missing_container_and_IfNoneMatch_throw_condition_failed() { ExpectContainerNotFound(() => TryToRead(TestItem, StreamingCondition.IfNoneMatch("mismatch"))); }
public void Missing_item_and_failed_IfMatch_work() { TestContainer.Create(); TestItem.Delete(StreamingCondition.IfMatch("some")); }