static void Main(string[] args) { Console.WriteLine("Moikka Visual Studiosta!"); Laskenta laskenta = new Laskenta(); int summa = laskenta.Summa(100, 234); Console.WriteLine("Summa on: " + summa); Console.ReadLine(); }
public void SummaTest() { int a = 100; int b = 200; Laskenta l = new Laskenta(); int summa = l.Summa(a, b); int odotettu = a + b; Assert.AreEqual(odotettu, summa); }
public void SummaTest() { int[] a = { -2, -1, 0, 1, 2, 3, -1, 1 }; int[] b = { -200, -100, 0, 100, 200, 300, 1, -1 }; for (int indeksi = 0; indeksi < a.Length; indeksi++) { int luku1 = a[indeksi]; int luku2 = b[indeksi]; Debug.WriteLine($"Testitapaus {indeksi}: luvut = {luku1}, {luku2}."); try { Laskenta l = new Laskenta(); int summa = l.Summa(luku1, luku2); if ((luku1 < 0) || (luku2 < 0)) { Assert.Fail(); } else { int odotettu = luku1 + luku2; Assert.AreEqual(odotettu, summa); } } catch (Exception ex) { if (!(ex is ArgumentOutOfRangeException)) { Assert.Fail(); } } } }