public void CantParseMatrixFromInsufficientData() { Trap.Exception(() => MatrixFactory.ParseString <T>(@"1.0 2.0 3.0 4.0 5.0 7.0 8.0 9.0")) .ShouldBeInstanceOf <InvalidOperationException>(); }
public void CantSetElementPastCurrentIndex() { var bucket = new Bucket <int>(2); bucket.Add(42); Trap.Exception(() => bucket[1] = 1).ShouldBeInstanceOf <IndexOutOfRangeException>(); }
public void ReadPastEndThrows_Fact() { var mock = new MockIOBuffer(0x0a); var output = new byte[8]; var e = Trap.Exception(() => mock.ReadInto(output, 0, 4)); e.ShouldBeOfType(typeof(IndexOutOfRangeException)); }
public void CantRemoveElements() { var list = new ChunkedList <int>(); list.Add(42); Trap.Exception(() => list.Remove(42)).ShouldBeInstanceOf <NotSupportedException>(); }
public void ActionTask_StartingAContinuationThrows_Fact() { var continuation = Task.New(() => { }) .ContinueWith(previous => { }); continuation.HasStarted.ShouldBeFalse(); var exception = Trap.Exception(continuation.Start); exception.Message.ShouldEqual("Cannot explicitly start a continuation"); }
public void InputBufferNotQueued_Fact() { var bus = new MockI2CBus(); var device1 = new FakeDevice(bus, 0x01, 400); var temp = new byte[1]; var e = Trap.Exception(() => device1.Read(temp)); e.ShouldBeOfType(typeof(IndexOutOfRangeException)); }
public void CantAddMoreThanCapacity() { var bucket = new Bucket <int>(5); for (int i = 0; i < 5; i++) { bucket.Add(i); } Trap.Exception(() => bucket.Add(1)).ShouldBeInstanceOf <InvalidOperationException>(); }
public void CantUseWhenListEmpty() { var list = new ChunkedList <int>(); var en = list.GetEnumerator(); en.Count.ShouldEqual(0); en.MovePrev().ShouldBeFalse(); en.MoveNext().ShouldBeFalse(); Trap.Exception(() => en.FromFirst()).ShouldBeInstanceOf <InvalidOperationException>(); Trap.Exception(() => en.FromLast()).ShouldBeInstanceOf <InvalidOperationException>(); }
public void CantCopyToArrayOfSmallerSize() { var list = new ChunkedList <int>(); for (int i = 0; i < 10; i++) { list.Add(i); } var arr = new int[5]; Trap.Exception(() => list.CopyTo(arr, 0)).ShouldBeInstanceOf <ArgumentOutOfRangeException>(); }
public void RelativeFolder_Theory(FolderArgs args) { if (args.Expected == null) { Trap.Exception(() => new RelativeFolderPath(args.Source)) .ShouldNotBeNull(); } else { var folder = new RelativeFolderPath(args.Source); folder.ToString() .ShouldEqual(args.Expected); } }
public unsafe void CantAccesMatrixPointersWhenDisposed() { var m1 = MatrixFactory.Create <float>(2, 3); var ptrs = new MatrixPointersBag <float>(m1); fixed(void *fp1 = &m1.AsColumnMajorArray()[0]) { (ptrs[0].ToPointer() == fp1).ShouldBeTrue(); } ptrs.Dispose(); Trap.Exception(() => ptrs[0]).ShouldBeInstanceOf <ObjectDisposedException>(); }
public void AbsoluteFolder_Theory(FolderArgs args) { if (args.Expected == null) { Trap.Exception(() => new AbsoluteFolderPath(args.Source)) .ShouldNotBeNull(); } else { var folder = new AbsoluteFolderPath(args.Source); Debug.Print(folder.ToString()); folder.ToString() .ShouldEqual(args.Expected); } }
public void RelativeFile_Theory(FileArgs args) { if (args.Expected == null) { Trap.Exception(() => new RelativeFilePath(args.Source)) .ShouldNotBeNull(); } else { var file = new RelativeFilePath(args.Source); file.ToString() .ShouldEqual(args.Expected); file.FileExtension.ShouldEqual(args.Extension); } }
public void SubtractAbsoluteFile_Theory(TheoryArgs args) { AbsoluteFolderPath finish = args.LeftPath; AbsoluteFilePath start = args.RightPath; if (args.ExpectedPath == null) { Trap.Exception(() => { var _ = finish - start; }) .ShouldNotBeNull(); } else { RelativeFolderPath relative = finish - start; relative.ToString() .ShouldEqual(args.ExpectedPath); } }
public void AddRelativeFolderPath_Theory(TheoryArgs args) { AbsoluteFolderPath absoulte = args.LeftPath; RelativeFolderPath relative = args.RightPath; if (args.ExpectedPath == null) { Trap.Exception(() => { var _ = absoulte + relative; }) .ShouldNotBeNull(); } else { var combined = absoulte + relative; combined.ToString() .ShouldEqual(args.ExpectedPath); } }
public void CantAddRangeMoreThanCapacity() { var bucket = new Bucket <int>(5); Trap.Exception(() => bucket.AddRange(Enumerable.Range(0, 6).ToArray())).ShouldBeInstanceOf <InvalidOperationException>(); }
public void CantSplitMatrixColumnsWhenInvalidColumnCount() { Trap.Exception(() => Matrix3By6.SplitColumns(7)).ShouldBeInstanceOf <ArgumentOutOfRangeException>(); Trap.Exception(() => Matrix3By6.SplitColumns(5)).ShouldBeInstanceOf <ArgumentOutOfRangeException>(); }
public void CreateNullData_Fact() { var exception = Trap.Exception(() => { var buffer = new MockIOBuffer(null); }); exception.ShouldBeOfType(typeof(ArgumentNullException)); }