public void testMultiplyNumbers() { var math = new BasicMath(); var result = math.multiplyNumbers(5, 5); Assert.True(result == 25); }
public void testDivideNumbers() { var math = new BasicMath(); var result = math.divideNumbers(10, 2); Assert.True(result == 5); }
public void testSubtractNumbers() { var math = new BasicMath(); var result = math.subtractNumbers(5, 5); Assert.True(result == 0); }
public void BasicPathTests_StaticTests() { Assert.AreEqual(BasicMath.BasicOperation('+', 4, 7), 11); Assert.AreEqual(BasicMath.BasicOperation('-', 15, 18), -3); Assert.AreEqual(BasicMath.BasicOperation('*', 5, 5), 25); Assert.AreEqual(BasicMath.BasicOperation('/', 49, 7), 7); }
private void BtnMultiply_Click(object sender, EventArgs e) { //if Input call the Third Party library and perform the multiplication function if (CheckForInput(tbResult.Text)) { if (!(plusButtonClicked && multiplyButtonClicked && minusButtonClicked && divisionButtonClicked)) { valueHolder = double.Parse(tbResult.Text); } else { valueHolder = BasicMath.Multiplication(valueHolder, double.Parse(tbResult.Text)); } tbResult.Clear(); plusButtonClicked = false; minusButtonClicked = false; divisionButtonClicked = false; multiplyButtonClicked = true; } //if invalid input print error to user else { MessageBox.Show("Please enter valid input"); } isTotal = false; }
public static Rotation3 SphericalLinear(double t, double t1, Rotation3 r1, double t2, Rotation3 r2) { var q1 = r1.Quaternion; var q2 = r2.Quaternion; var dot = Quaternion.Dot(q1, q2); if (Quaternion.Dot(q1, q2) < 0) { q2 = -q2; dot = -dot; } var dt = t2 - t1; var angle = BasicMath.Acos(dot); Quaternion q; if (angle > BasicMath.Epsilon) { q = Math.Sin(angle * (t2 - t) / dt) * q1 + Math.Sin(angle * (t - t1) / dt) * q2; } else { q = ((t2 - t) * q1 + (t - t1) * q2) / dt; } return((Rotation3)q); }
public void testAddNumbers() { var math = new BasicMath(); var result = math.addNumbers(5, 5); Assert.True(result == 10); }
public static string FormatTimeDurationFlexible(double dt) { if (dt < 60) { return(DecimalUnitsFormatting.Format(dt, DecimalUnitsFormatting.MetricTimeFull, true)); } var secs = BasicMath.Round(dt); var secPart = secs % 60; var mins = secs / 60; if (mins < 60) { return(string.Format("{0:00}:{1:00}", mins, secPart)); } var minPart = mins % 60; var hours = mins / 60; if (hours < 24) { return(string.Format("{0:00}:{1:00}:{2:00}", hours, minPart, secPart)); } var days = ((double)hours) / 24.0; return(string.Format("{0:0.#}d", days)); }
public static TestAdd() { BasicMath bm = new BasicMath(); double res = bm.Add(10, 10); Assert.AreEqual(res, 20); }
public override void Processes(Partical input, float dt) { float amount = input.LifeTime / (input.Age + input.LifeTime); amount = 1 - amount; //get invers input.Colour = BasicMath.Lerp3(InitialColor, MiddleColour, MiddleColourPosition, EndColour, amount); }
public static GeoPoint3 EcefToGeodetic(Vector3 ecef, GeoDatum datum) { const double precision2 = 1e-6; const int maxIterations = 16; var norm = ecef.Norm; var phi = Math.Atan2(ecef.Y, ecef.X); var theta0 = BasicMath.Asin(ecef.Z / ecef.Norm); // first approximation var h0 = norm - datum.Semiminor; // first approximation var theta = theta0; var h = h0; var error2 = double.PositiveInfinity; for (var i = 0; i < maxIterations && error2 > precision2; i++) { var ecefPrime = new GeoPoint3(theta, phi, h).ToEcef(datum); var normPrime = ecefPrime.Norm; var thetaSphere = BasicMath.Asin(ecefPrime.Z / normPrime); var hSphere = normPrime - datum.Semiminor; theta += theta0 - thetaSphere; h += h0 - hSphere; error2 = Vector3.Distance2(ecef, ecefPrime); } return(new GeoPoint3(theta, phi, h)); }
public static Test_MultiplyMethod() { BasicMath bm = new BasicMath(); double res = bm.Multiply(10, 10); Assert.AreEqual(res, 100); }
public static Test_DivideMethod() { BasicMath bm = new BasicMath(); double res = bm.divide(10, 5); Assert.AreEqual(res, 2); }
public static Test_SubstractMethod() { BasicMath bm = new BasicMath(); double res = bm.Substract(10, 10); Assert.AreEqual(res, 0); }
public static double Distance2(Vector2 point, IClosedPolyline line) { var prevVector = line.Vertices.Last() - point; var prevNorm2 = prevVector.Norm2; var answer = prevNorm2; foreach (var vertex in line.Vertices) { var vector = vertex - point; var norm2 = vector.Norm2; var displacement = vector - prevVector; if ((prevVector * displacement) * (vector * displacement) > 0) { answer = Math.Min(answer, norm2); } else { answer = Math.Min(answer, BasicMath.Sqr(prevVector.Cross(vector)) / displacement.Norm2); } prevVector = vector; prevNorm2 = norm2; } return(answer); }
public override void Processes(Partical input, float dt) { float amount = input.LifeTime / (input.Age + input.LifeTime); amount = 1 - amount; //get invers input.Fade = BasicMath.Lerp3(InitialFade, MiddleStateFade, MiddleLifeTime, EndFade, amount); }
public static void ComputeEigenvalues(this SymmetricMatrix2 @this, out double low, out double high) { var halfTrace = @this.Trace() / 2; var disc = BasicMath.Sqrt(halfTrace * halfTrace - @this.Det()); low = halfTrace - disc; high = halfTrace + disc; }
static void Main(string[] args) { Console.WriteLine("Hello to Calc Test!"); Console.WriteLine(string.Format("{0} + {1} = {2}", 20, 22, BasicMath.Sum(20, 22))); Console.WriteLine(string.Format("{0} - {1} = {2}", 50, 8, BasicMath.Difference(50, 8))); Console.WriteLine(string.Format("{0} * {1} = {2}", 7, 6, BasicMath.Multiplication(7, 6))); Console.WriteLine(string.Format("{0} / {1} = {2}", 420, 10, BasicMath.Division(420, 10))); }
static void Main() { string[] args = Environment.GetCommandLineArgs(); /* foreach(var a in args) * { * Console.WriteLine(a); * } * * Console.ReadLine(); */ AreArgumentsValid(args); var Math = new BasicMath(); var advMath = new AdvMath(); switch (_operand.ToString()) { case "add": Console.WriteLine($"{_num1} + {_num2} = {Math.addNumbers(_num1, _num2)}"); break; case "sub": Console.WriteLine($"{_num1} - {_num2} = {Math.subtractNumbers(_num1, _num2)}"); break; case "mult": Console.WriteLine($"{_num1} * {_num2} = {Math.multiplyNumbers(_num1, _num2)}"); break; case "div": Console.WriteLine($"{_num1} / {_num2} = {Math.divideNumbers(_num1, _num2)}"); break; case "area": Console.WriteLine($"{_num1} * {_num2} H = {advMath.calculateArea(_num1, _num2)}."); break; case "avg": Console.WriteLine($"{_num1}, {_num2}, {_num3}, {_num4} = {advMath.calculateListAverage(_num1, _num2, _num3, _num4)}"); break; case "squared": Console.WriteLine($"{_num1}^2 = {advMath.calculateValueSquared(_num1)}"); break; case "pyth": Console.WriteLine($"{_num1}^2 + {_num2}^2 = {advMath.calculatePythagoreanTheorem(_num1, _num2)}"); break; default: Console.WriteLine($"{_operand} is not a valid operator. Please enter Add, Sub, Mul, Div, area, avg, squared, pyth"); break; } Console.ReadLine(); }
static GeoDatum() { var wgs84a = 6378137.0; var wgs84g = 1 / 298.257223563; var wgs84e = Math.Sqrt(1 - BasicMath.Sqr(1 - wgs84g)); _wgs84 = new GeoDatum(wgs84a, wgs84e); }
private void Dot() { Vector3 dir = target.position - transform.position; Vector3 normalizedA = BasicMath.Normalize(transform.up); Vector3 normalizedB = BasicMath.Normalize(dir); Debug.Log(BasicMath.Dot(normalizedA, normalizedB)); }
public void CanAddIntAndDecimal() { var firstNumber = 3; var secondNumber = 5.5m; var result = BasicMath.Addition(firstNumber, secondNumber); Assert.AreEqual(result, 8.5m); }
public void CanAddIntegers() { var firstNumber = 3; var secondNumber = 5; var result = BasicMath.Addition(firstNumber, secondNumber); Assert.AreEqual(result, 8); }
public void CanAddFloatAndDouble() { var firstNumber = 3.3f; var secondNumber = 5.5; var result = BasicMath.Addition(firstNumber, secondNumber); Assert.AreEqual(result, 8.8); }
public void DivideNumbers(double a, double b, double expected) { /// action BasicMath cal1 = new BasicMath(); double actual = cal1.Division(a, b); /// assertion Assert.Equal(expected, actual); }
public void MinusTest() { //Arrange BasicMath Math = new BasicMath(); //Act double minus = Math.Minus(10, 6); //Assert Assert.AreEqual(4, minus); }
public void AddNumbers(double a, double b, double expected) { // action BasicMath cal1 = new BasicMath(); double actual = cal1.Add(a, b); // assertion Assert.Equal(expected, actual); //Assert.Eq }
public void GangeTest() { //Arrange BasicMath Math = new BasicMath(); //Act double multi = Math.Gange(5, 6); //Assert Assert.AreEqual(30, multi); }
public void DividerTest() { //Arrange BasicMath Math = new BasicMath(); //Act double divi = Math.Divider(100, 2); //Assert Assert.AreEqual(50, divi); }
public void iAndenTest() { //Arrange BasicMath Math = new BasicMath(); //Act double i2 = Math.iAnden(10); //Assert Assert.AreEqual(100, i2); }
static void Main(string[] args) { Console.WriteLine(Fname); BasicMath bm = new BasicMath(); Console.WriteLine("sum = {0}", bm.Add(10.45, 243.39)); //different ways to create type instance //System.Object Type t = bm.GetType(); System.Reflection.MethodInfo mtInfo = t.GetMethod("Add"); Console.WriteLine("is Add public {0}", mtInfo.IsPublic); //typeof Type typo = typeof(BasicMath); //you don't need compile time info about the type //System.Type.GetType (static method) try { // Obtain type information for a type within an external assembly. //fully qualified name of the type, friendly name of the assembly Type sysType = System.Type.GetType("MathLibrary.BasicMath, MathLibrary", true, false); //Obtain type information for a nested class (add + for nested types) System.Type.GetType("MathLibrary.BasicMath+Trigonometry, MathLibrary", true, false); } catch(Exception e) { Console.WriteLine(e.Message); } /*“back tick” character (`) followed by a numerical value that represents the number of type parameters*/ //System.Collections.Generic.List<T> Type tInfo = System.Type.GetType("System.Collections.Generic.List`1, mscorlib", true, false); RedReflector rdr = new RedReflector(); rdr.ListMethods(tInfo); //rdr.ListProperties(tInfo); rdr.ListInterfaces(tInfo); rdr.ListStats(tInfo); //dynamically loading assembly ExternalAssemblyReflector ear = new ExternalAssemblyReflector(); //ear.DisplayTypesInAsm(Assembly.LoadFrom(@"G:\naynish\Pro C# 2010 and the .NET 4 Platform\ReflectionLateBindingAttributeBased\ConsoleApplication1\MathLibrary\bin\Debug\MathLibrary.dll")); String extPath = @"G:\naynish\Pro C# 2010 and the .NET 4 Platform\ReflectionLateBindingAttributeBased\ConsoleApplication1\SimpleEmployee\bin\Debug\SimpleEmployee.dll"; AssemblyName asmName = new AssemblyName(); //path including the extension asmName.Name = extPath; //LoadFrom because the assembly is not in the bin directory of ConsoleApplication1 ear.DisplayTypesInAsm(Assembly.LoadFrom(asmName.ToString())); //loading shared assemblies Assembly myAssembly = Assembly.Load(@"System.Windows.Forms, Version = 4.0.0.0, PublicKeyToken = b77a5c561934e089, Culture = """); ear.DisplayTypesInSharedAsm(myAssembly); AssemblyName customMyAssembly = new AssemblyName(); customMyAssembly.Name = "CustomLibrary"; Version v = new Version("1.0.0.0"); customMyAssembly.Version = v; Assembly a = Assembly.Load(customMyAssembly); ear.DisplayTypesInAsm(a); AttributeBased ab = new AttributeBased(); //ab.salary; (error on reflecting over this type using C# compiler) //reflect over an attributed type AssemblyName name = new AssemblyName(); name.Name = "AttributedEmployeeLibrary"; Assembly myAttr = Assembly.Load(name); Type tp = myAttr.GetType("AttributedEmployeeLibrary.VicePresident"); Object myInstance = Activator.CreateInstance(tp); MethodInfo info = tp.GetMethod("GetFname"); Console.WriteLine(info.Invoke(myInstance, null)); Object[] custAttr = tp.GetCustomAttributes(false); foreach (var item in custAttr) { Console.WriteLine(item); } foreach (Type item in myAttr.GetTypes()) { foreach (object item1 in item.GetCustomAttributes(myAttr.GetType("AttributedEmployeeLibrary.EmployeeDescriptionAttribute"), false)) { Console.WriteLine((myAttr.GetType("AttributedEmployeeLibrary.EmployeeDescriptionAttribute").GetProperty("Description")).GetValue(item1,null)); } } Console.ReadLine(); }