217 lines
6.7 KiB
C#
217 lines
6.7 KiB
C#
using ConsoleApp1;
|
|
using Microsoft.Analytics.Interfaces;
|
|
using Microsoft.Analytics.Interfaces.Streaming;
|
|
using Microsoft.Analytics.Types.Sql;
|
|
using Microsoft.Analytics.UnitTest;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using PR1;
|
|
using System.Numerics;
|
|
|
|
namespace USqlCSharpUdoUnitTestProject1
|
|
{
|
|
[TestClass]
|
|
public class UnitTest1
|
|
{
|
|
Calculator Calculator1 = new Calculator();
|
|
public UnitTest1()
|
|
{
|
|
//
|
|
// TODO: Add constructor logic here
|
|
//
|
|
}
|
|
|
|
private TestContext testContextInstance;
|
|
|
|
/// <summary>
|
|
///Gets or sets the test context which provides
|
|
///information about and functionality for the current test run.
|
|
///</summary>
|
|
public TestContext TestContext
|
|
{
|
|
get
|
|
{
|
|
return testContextInstance;
|
|
}
|
|
set
|
|
{
|
|
testContextInstance = value;
|
|
}
|
|
}
|
|
|
|
#region Additional test attributes
|
|
//
|
|
// You can use the following additional attributes as you write your tests:
|
|
//
|
|
// Use ClassInitialize to run code before running the first test in the class
|
|
// [ClassInitialize()]
|
|
// public static void MyClassInitialize(TestContext testContext) { }
|
|
//
|
|
// Use ClassCleanup to run code after all tests in a class have run
|
|
// [ClassCleanup()]
|
|
// public static void MyClassCleanup() { }
|
|
//
|
|
// Use TestInitialize to run code before running each test
|
|
// [TestInitialize()]
|
|
// public void MyTestInitialize() { }
|
|
//
|
|
// Use TestCleanup to run code after each test has run
|
|
// [TestCleanup()]
|
|
// public void MyTestCleanup() { }
|
|
//
|
|
#endregion
|
|
|
|
[TestMethod]
|
|
public void TestMethod1()
|
|
{
|
|
double x = 2;
|
|
double y = 5;
|
|
|
|
double result1 = 7;
|
|
double result2 = -3;
|
|
double result3 = 10;
|
|
double result4 = 0.4;
|
|
|
|
Assert.AreEqual(Calculator1.Addiction(x, y), result1);
|
|
Assert.AreEqual(Calculator1.Subtraction(x, y), result2);
|
|
Assert.AreEqual(Calculator1.Multipliction(x, y), result3);
|
|
Assert.AreEqual(Calculator1.Division(x, y), result4);
|
|
}
|
|
[TestMethod]
|
|
public void TestMethod2()
|
|
{
|
|
double x = -2;
|
|
double y = -5;
|
|
|
|
double result1 = -7;
|
|
double result2 = 3;
|
|
double result3 = 10;
|
|
double result4 = 0.4;
|
|
|
|
Assert.AreEqual(Calculator1.Addiction(x, y), result1);
|
|
Assert.AreEqual(Calculator1.Subtraction(x, y), result2);
|
|
Assert.AreEqual(Calculator1.Multipliction(x, y), result3);
|
|
Assert.AreEqual(Calculator1.Division(x, y), result4);
|
|
}
|
|
[TestMethod]
|
|
public void TestMethod3()
|
|
{
|
|
double x = 2.5;
|
|
double y = 3.6;
|
|
|
|
double result1 = 6.1;
|
|
double result2 = -1.1;
|
|
double result3 = 9;
|
|
double result4 = 0.69444444444444444444444444444444;
|
|
|
|
Assert.AreEqual(Calculator1.Addiction(x, y), result1);
|
|
Assert.AreEqual(Calculator1.Subtraction(x, y), result2);
|
|
Assert.AreEqual(Calculator1.Multipliction(x, y), result3);
|
|
Assert.AreEqual(Calculator1.Division(x, y), result4);
|
|
}
|
|
[TestMethod]
|
|
public void TestMethod4()
|
|
{
|
|
double x = 4;
|
|
double y = 1;
|
|
|
|
double result = 4;
|
|
|
|
|
|
Assert.AreEqual(Calculator1.Division(x, y), result);
|
|
}
|
|
[TestMethod]
|
|
public void TestMethod5()
|
|
{
|
|
double x = 4;
|
|
double y = 0;
|
|
|
|
double result = double.PositiveInfinity;
|
|
|
|
|
|
Assert.AreEqual(Calculator1.Division(x, y), result);
|
|
}
|
|
[TestMethod]
|
|
public void TestMethod6()
|
|
{
|
|
double x = int.MaxValue;
|
|
double y = int.MaxValue;
|
|
|
|
double result1 = 4294967294;
|
|
double result2 = 0;
|
|
double result3 = 4611686014132420609;
|
|
double result4 = 1;
|
|
|
|
Assert.AreEqual(Calculator1.Addiction(x, y), result1);
|
|
Assert.AreEqual(Calculator1.Subtraction(x, y), result2);
|
|
Assert.AreEqual(Calculator1.Multipliction(x, y), result3);
|
|
Assert.AreEqual(Calculator1.Division(x, y), result4);
|
|
}
|
|
[TestMethod]
|
|
public void TestMethod7()
|
|
{
|
|
long x = int.MaxValue;
|
|
long y = int.MaxValue;
|
|
|
|
double result1 = 4294967294;
|
|
double result2 = 0;
|
|
double result3 = 4611686014132420609L;
|
|
double result4 = 1;
|
|
|
|
Assert.AreEqual(Calculator1.Addiction(x, y), result1);
|
|
Assert.AreEqual(Calculator1.Subtraction(x, y), result2);
|
|
Assert.AreEqual(Calculator1.Multipliction(x, y), result3);
|
|
Assert.AreEqual(Calculator1.Division(x, y), result4);
|
|
}
|
|
[TestMethod]
|
|
public void TestMethod8()
|
|
{
|
|
double x = 2.5;
|
|
double y = 3.6;
|
|
|
|
double result1 = 6.1;
|
|
double result2 = -1.1;
|
|
double result3 = 9;
|
|
double result4 = 0.69444444444444444444444444444444;
|
|
|
|
Assert.AreEqual(Calculator1.Addiction(x, y), result1);
|
|
Assert.AreEqual(Calculator1.Subtraction(x, y), result2);
|
|
Assert.AreEqual(Calculator1.Multipliction(x, y), result3);
|
|
Assert.AreEqual(Calculator1.Division(x, y), result4);
|
|
}
|
|
[TestMethod]
|
|
public void TestMethod9()
|
|
{
|
|
double large = double.MaxValue;
|
|
|
|
double result1 = 0;
|
|
double result2 = 1;
|
|
|
|
Assert.IsTrue(double.IsInfinity(Calculator1.Addiction(large, large)));
|
|
Assert.IsTrue(double.IsInfinity(Calculator1.Multipliction(large, large)));
|
|
Assert.AreEqual(Calculator1.Subtraction(large, large), result1);
|
|
Assert.AreEqual(Calculator1.Division(large, large), result2);
|
|
}
|
|
[TestMethod]
|
|
public void TestMethod10()
|
|
{
|
|
double x = 1e-308;
|
|
double y = 2e-308;
|
|
|
|
double result1 = 1e-320;
|
|
double result2 = -1e-308;
|
|
double result3 = 0;
|
|
double result4 = 0.5;
|
|
|
|
Assert.AreEqual(Calculator1.Addiction(x, y), result1);
|
|
Assert.AreEqual(Calculator1.Subtraction(x, y), result2);
|
|
Assert.AreEqual(Calculator1.Multipliction(x, y), result3);
|
|
Assert.AreEqual(Calculator1.Division(x, y), result4);
|
|
}
|
|
}
|
|
}
|