From d342fb18796e7db7733861f19b41660f8d57703e Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Mon, 27 Mar 2017 07:57:45 -0700 Subject: [PATCH] Use Assert.Throws instead of ExpectedException Summary: Unity 5.6 doesn't have ExpectedException attribute. Closes https://github.com/facebook/yoga/pull/486 Reviewed By: astreet Differential Revision: D4739149 Pulled By: splhack fbshipit-source-id: 9cc486a094c6e159b46fa7938669fecbf523c666 --- csharp/tests/Facebook.Yoga/YogaNodeTest.cs | 27 +++++++++------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/csharp/tests/Facebook.Yoga/YogaNodeTest.cs b/csharp/tests/Facebook.Yoga/YogaNodeTest.cs index ab3b30bd..6ffdeb32 100644 --- a/csharp/tests/Facebook.Yoga/YogaNodeTest.cs +++ b/csharp/tests/Facebook.Yoga/YogaNodeTest.cs @@ -73,25 +73,22 @@ namespace Facebook.Yoga } [Test] - [ExpectedException("System.NullReferenceException")] public void TestRemoveAtFromEmpty() { YogaNode parent = new YogaNode(); - parent.RemoveAt(0); + Assert.Throws(() => parent.RemoveAt(0)); } [Test] - [ExpectedException("System.ArgumentOutOfRangeException")] public void TestRemoveAtOutOfRange() { YogaNode parent = new YogaNode(); YogaNode child = new YogaNode(); parent.Insert(0, child); - parent.RemoveAt(1); + Assert.Throws(() => parent.RemoveAt(1)); } [Test] - [ExpectedException("System.InvalidOperationException")] public void TestCannotAddChildToMultipleParents() { YogaNode parent1 = new YogaNode(); @@ -99,7 +96,7 @@ namespace Facebook.Yoga YogaNode child = new YogaNode(); parent1.Insert(0, child); - parent2.Insert(0, child); + Assert.Throws(() => parent2.Insert(0, child)); } [Test] @@ -113,23 +110,21 @@ namespace Facebook.Yoga } [Test] - [ExpectedException("System.InvalidOperationException")] public void TestResetParent() { YogaNode parent = new YogaNode(); YogaNode child = new YogaNode(); parent.Insert(0, child); - parent.Reset(); + Assert.Throws(() => parent.Reset()); } [Test] - [ExpectedException("System.InvalidOperationException")] public void TestResetChild() { YogaNode parent = new YogaNode(); YogaNode child = new YogaNode(); parent.Insert(0, child); - child.Reset(); + Assert.Throws(() => child.Reset()); } [Test] @@ -174,7 +169,6 @@ namespace Facebook.Yoga } [Test] - [ExpectedException("System.InvalidOperationException")] public void TestChildWithMeasureFunc() { YogaNode node = new YogaNode(); @@ -182,19 +176,20 @@ namespace Facebook.Yoga return MeasureOutput.Make(100, 150); }); YogaNode child = new YogaNode(); - node.Insert(0, child); + Assert.Throws(() => node.Insert(0, child)); } [Test] - [ExpectedException("System.InvalidOperationException")] public void TestMeasureFuncWithChild() { YogaNode node = new YogaNode(); YogaNode child = new YogaNode(); node.Insert(0, child); - node.SetMeasureFunction((_, width, widthMode, height, heightMode) => { - return MeasureOutput.Make(100, 150); - }); + Assert.Throws(() => + node.SetMeasureFunction((_, width, widthMode, height, heightMode) => { + return MeasureOutput.Make(100, 150); + }) + ); } [Test]