Files
BasicProgramming/MethodLibraryTests/BasicTests.cs

65 lines
1.7 KiB
C#

using MethodLibrary;
namespace BasicProgrammingTests;
public class BasicTests
{
private readonly Basic basic = new Basic();
[Theory]
[InlineData(30, 2, 4, 5)]
public void AddAndMultiply(int expected, int a, int b, int c)
{
Assert.Equal(expected, basic.AddAndMultiply(a, b, c));
}
[Theory]
[InlineData("T = 32F", 0)]
[InlineData("T = 212F", 100)]
[InlineData("Temperature below absolute zero!", -300)]
public void CToF(string expected, int input)
{
Assert.Equal(expected, basic.CtoF(input));
}
[Theory]
[InlineData(new double[] { 11.0, -5.0, 24.0, 0.375 }, 3, 8)]
public void ElementaryOperations(double[] expected, int a, int b)
{
var result = basic.ElementaryOperations(a, b);
Assert.Equal(expected, result);
}
[Theory]
[InlineData(true, 2 + 2, 2 * 2)]
[InlineData(false, 9 / 3, 16 - 1)]
public void IsResultTheSame(bool expected, int a, int b)
{
Assert.Equal(expected, basic.IsResultTheSame(a, b));
}
[Theory]
[InlineData(1, 8, 5, 2)]
public void ModuloOperations(int expected, int a, int b, int c)
{
Assert.Equal(expected, basic.ModuloOperations(a, b, c));
}
[Theory]
[InlineData(8, 2)]
[InlineData(-166.375, -5.5)]
public void CubeOf(double expected, double a)
{
Assert.Equal(expected, basic.CubeOf(a));
}
[Theory]
[InlineData(new int[] { 45, 87 }, 87, 45)]
[InlineData(new int[] {2, -13}, -13, 2)]
public void SwapTwoNumbers(int[] expected, int a, int b)
{
Assert.Equal(expected, basic.SwapTwoNumbers(a, b));
}
}