public void ArithmeticMethods() { SqlInt16 Test64 = new SqlInt16(64); SqlInt16 Test0 = new SqlInt16(0); SqlInt16 Test164 = new SqlInt16(164); SqlInt16 TestMax = new SqlInt16(SqlInt16.MaxValue.Value); // Add() Assert.AreEqual((short)64, SqlInt16.Add(Test64, Test0).Value, "Test#1"); Assert.AreEqual((short)228, SqlInt16.Add(Test64, Test164).Value, "Test#2"); Assert.AreEqual((short)164, SqlInt16.Add(Test0, Test164).Value, "Test#3"); Assert.AreEqual((short)SqlInt16.MaxValue, SqlInt16.Add(TestMax, Test0).Value, "Test#4"); try { SqlInt16.Add(TestMax, Test64); Assert.Fail("Test#5"); } catch (OverflowException e) { Assert.AreEqual(typeof(OverflowException), e.GetType(), "Test#6"); } // Divide() Assert.AreEqual((short)2, SqlInt16.Divide(Test164, Test64).Value, "Test#7"); Assert.AreEqual((short)0, SqlInt16.Divide(Test64, Test164).Value, "Test#8"); try { SqlInt16.Divide(Test64, Test0); Assert.Fail("Test#9"); } catch (DivideByZeroException e) { Assert.AreEqual(typeof(DivideByZeroException), e.GetType(), "Test#10"); } // Mod() Assert.AreEqual((SqlInt16)36, SqlInt16.Mod(Test164, Test64), "Test#11"); Assert.AreEqual((SqlInt16)64, SqlInt16.Mod(Test64, Test164), "Test#12"); // Multiply() Assert.AreEqual((short)10496, SqlInt16.Multiply(Test64, Test164).Value, "Test#13"); Assert.AreEqual((short)0, SqlInt16.Multiply(Test64, Test0).Value, "Test#14"); try { SqlInt16.Multiply(TestMax, Test64); Assert.Fail("Test#15"); } catch (OverflowException e) { Assert.AreEqual(typeof(OverflowException), e.GetType(), "Test#16"); } // Subtract() Assert.AreEqual((short)100, SqlInt16.Subtract(Test164, Test64).Value, "Test#17"); try { SqlInt16.Subtract(SqlInt16.MinValue, Test164); Assert.Fail("Test#18"); } catch (OverflowException e) { Assert.AreEqual(typeof(OverflowException), e.GetType(), "Test#19"); } // Modulus () Assert.AreEqual((SqlInt16)36, SqlInt16.Modulus(Test164, Test64), "Test#20"); Assert.AreEqual((SqlInt16)64, SqlInt16.Modulus(Test64, Test164), "Test#21"); }
public void ArithmeticMethods() { SqlInt16 test64 = new SqlInt16(64); SqlInt16 test0 = new SqlInt16(0); SqlInt16 test164 = new SqlInt16(164); SqlInt16 testMax = new SqlInt16(SqlInt16.MaxValue.Value); // Add() Assert.Equal((short)64, SqlInt16.Add(test64, test0).Value); Assert.Equal((short)228, SqlInt16.Add(test64, test164).Value); Assert.Equal((short)164, SqlInt16.Add(test0, test164).Value); Assert.Equal((short)SqlInt16.MaxValue, SqlInt16.Add(testMax, test0).Value); Assert.Throws <OverflowException>(() => SqlInt16.Add(testMax, test64)); // Divide() Assert.Equal((short)2, SqlInt16.Divide(test164, test64).Value); Assert.Equal((short)0, SqlInt16.Divide(test64, test164).Value); Assert.Throws <DivideByZeroException>(() => SqlInt16.Divide(test64, test0)); // Mod() Assert.Equal((SqlInt16)36, SqlInt16.Mod(test164, test64)); Assert.Equal((SqlInt16)64, SqlInt16.Mod(test64, test164)); // Multiply() Assert.Equal((short)10496, SqlInt16.Multiply(test64, test164).Value); Assert.Equal((short)0, SqlInt16.Multiply(test64, test0).Value); Assert.Throws <OverflowException>(() => SqlInt16.Multiply(testMax, test64)); // Subtract() Assert.Equal((short)100, SqlInt16.Subtract(test164, test64).Value); Assert.Throws <OverflowException>(() => SqlInt16.Subtract(SqlInt16.MinValue, test164)); // Modulus () Assert.Equal((SqlInt16)36, SqlInt16.Modulus(test164, test64)); Assert.Equal((SqlInt16)64, SqlInt16.Modulus(test64, test164)); }
public void ArithmeticMethods() { SqlInt16 Test64 = new SqlInt16(64); SqlInt16 Test0 = new SqlInt16(0); SqlInt16 Test164 = new SqlInt16(164); SqlInt16 TestMax = new SqlInt16(SqlInt16.MaxValue.Value); // Add() Assert.Equal((short)64, SqlInt16.Add(Test64, Test0).Value); Assert.Equal((short)228, SqlInt16.Add(Test64, Test164).Value); Assert.Equal((short)164, SqlInt16.Add(Test0, Test164).Value); Assert.Equal((short)SqlInt16.MaxValue, SqlInt16.Add(TestMax, Test0).Value); try { SqlInt16.Add(TestMax, Test64); Assert.False(true); } catch (OverflowException e) { Assert.Equal(typeof(OverflowException), e.GetType()); } // Divide() Assert.Equal((short)2, SqlInt16.Divide(Test164, Test64).Value); Assert.Equal((short)0, SqlInt16.Divide(Test64, Test164).Value); try { SqlInt16.Divide(Test64, Test0); Assert.False(true); } catch (DivideByZeroException e) { Assert.Equal(typeof(DivideByZeroException), e.GetType()); } // Mod() Assert.Equal((SqlInt16)36, SqlInt16.Mod(Test164, Test64)); Assert.Equal((SqlInt16)64, SqlInt16.Mod(Test64, Test164)); // Multiply() Assert.Equal((short)10496, SqlInt16.Multiply(Test64, Test164).Value); Assert.Equal((short)0, SqlInt16.Multiply(Test64, Test0).Value); try { SqlInt16.Multiply(TestMax, Test64); Assert.False(true); } catch (OverflowException e) { Assert.Equal(typeof(OverflowException), e.GetType()); } // Subtract() Assert.Equal((short)100, SqlInt16.Subtract(Test164, Test64).Value); try { SqlInt16.Subtract(SqlInt16.MinValue, Test164); Assert.False(true); } catch (OverflowException e) { Assert.Equal(typeof(OverflowException), e.GetType()); } // Modulus () Assert.Equal((SqlInt16)36, SqlInt16.Modulus(Test164, Test64)); Assert.Equal((SqlInt16)64, SqlInt16.Modulus(Test64, Test164)); }