public void AddInPlace_ShouldAdd() { var left = new[] {new[] {0.1, 0.2}, new[] {0.3, 0.4, 0.5 } }; var right = new[] {new[] {1.0, 2.0}, new[] {3.0, 4.0, 5.0 } }; var expected = new[] { new[] { 1.1, 2.2 }, new[] { 3.3, 4.4, 5.5 } }; left.AddInPlace(right); left.Should().NotBeNullOrEmpty(); left.Should().HaveCount(2); left[0].ShouldApproximatelyEqual(expected[0]); left[1].ShouldApproximatelyEqual(expected[1]); }
public void AddInPlace_IfSubLengthsDontMatch_ThrowArgumentExcetpion() { var target = new[] { new[] { 0.1, 0.2 }, new[] { 0.3 } }; var other = new[] { new[] { 1.0, 2.0 }, new[] { 3.0, 4.0 } }; Action action = () => target.AddInPlace(other); action.ShouldThrow<ArgumentException>() .WithMessage("*Argument 'other' and target array have mismatching sub-array at index 1; " + "target subarray length: 1, other subarray length: 2.*") .Where(e => e.ParamName == "other"); }
public void AddInPlace_IfOtherIsNull_ThrowArgumentNullException() { var target = new[] { new[] { 1.0, 2.0 }, new[] { 3.0, 4.0 } }; double[][] other = null; // ReSharper disable once ExpressionIsAlwaysNull Action action = () => target.AddInPlace(other); action.ShouldThrow<ArgumentNullException>() .Where(e => e.ParamName == "other"); }
public void AddInPlace_IfLengthsDontMatch_ThrowArgumentException() { var target = new[] { new[] { 0.1, 0.2 }, }; var other = new[] { new[] { 1.0, 2.0 }, new[] { 3.0, 4.0 } }; Action action = () => target.AddInPlace(other); action.ShouldThrow<ArgumentException>() .WithMessage("*Argument 'other' should have same length as the target array (1); was 2.*") .Where(e => e.ParamName == "other"); }