using System; using UnitTestSharp; namespace Blacklight.Core.UnitTests { public class StringHostClipboardTextTests : TestFixture { public class CtorTests : TestFixture { public void NullText_Throws() { CheckThrow(typeof(ArgumentNullException)); new StringHostClipboardText(null); } public void StartsUndisposed() { CheckFalse(new StringHostClipboardText("abc").IsDisposed); } } public class LengthTests : TestFixture { public void IsTheStringsLength() { CheckEqual(5, new StringHostClipboardText("hello").Length); } } public class GetChunkTests : TestFixture { public void ReadsFromTheStart() { var text = new StringHostClipboardText("hello"); CheckEqual("hello", text.GetChunk(0).ToString()); } public void ReadsFromAnIndexToTheEnd() { var text = new StringHostClipboardText("hello"); CheckEqual("llo", text.GetChunk(2).ToString()); } public void AStartAtTheLength_Throws() { var text = new StringHostClipboardText("hello"); CheckThrow(typeof(ArgumentOutOfRangeException)); text.GetChunk(5); } public void AfterDispose_Throws() { var text = new StringHostClipboardText("hello"); text.Dispose(); CheckThrow(typeof(ObjectDisposedException)); text.GetChunk(0); } } public class DisposeTests : TestFixture { public void MarksItDisposed() { var text = new StringHostClipboardText("hello"); text.Dispose(); CheckTrue(text.IsDisposed); } public void DisposingTwice_IsAllowed() { var text = new StringHostClipboardText("hello"); text.Dispose(); text.Dispose(); CheckTrue(text.IsDisposed); } } } }