using System.Linq; public class Program { public static int FindSquaresInArray(int[] arr) { return arr.Sum(x => x * x); } }
- using System.Linq;
- public class Program
- {
public static int FindSquaresInArray(int[] arr){return arr.Sum(x => x * x);}}- public static int FindSquaresInArray(int[] arr)
- {
- return arr.Sum(x => x * x);
- }
- }
using NUnit.Framework; namespace Solution { [TestFixture] public class SolutionTest { [Test] public void TestEmptyArray() { int[] emptyArray = new int[0]; Assert.AreEqual(0, Program.FindSquaresInArray(emptyArray)); } [Test] public void TestArrayWithPositiveIntegers() { int[] positiveArray = { 1, 2, 3, 4, 5 }; Assert.AreEqual(55, Program.FindSquaresInArray(positiveArray)); } [Test] public void TestArrayWithSingleElement() { int[] singleElementArray = { 4 }; Assert.AreEqual(16, Program.FindSquaresInArray(singleElementArray)); } [Test] public void TestArrayWithAllZeros() { int[] zeroArray = { 0, 0, 0, 0 }; Assert.AreEqual(0, Program.FindSquaresInArray(zeroArray)); } } }
- using NUnit.Framework;
using System;- namespace Solution
- {
[TestFixture]public class SolutionTest{[Test]public void TestEmptyArray()- [TestFixture]
- public class SolutionTest
- {
int[] emptyArray = new int[0];Assert.AreEqual(0, Program.FindSquaresInArray(emptyArray));}[Test]public void TestArrayWithPositiveIntegers(){int[] positiveArray = { 1, 2, 3, 4, 5 };Assert.AreEqual(55, Program.FindSquaresInArray(positiveArray));}[Test]public void TestArrayWithSingleElement(){int[] singleElementArray = { 4 };Assert.AreEqual(16, Program.FindSquaresInArray(singleElementArray));}[Test]public void TestArrayWithAllZeros(){int[] zeroArray = { 0, 0, 0, 0 };Assert.AreEqual(0, Program.FindSquaresInArray(zeroArray));}}- [Test]
- public void TestEmptyArray()
- {
- int[] emptyArray = new int[0];
- Assert.AreEqual(0, Program.FindSquaresInArray(emptyArray));
- }
- [Test]
- public void TestArrayWithPositiveIntegers()
- {
- int[] positiveArray = { 1, 2, 3, 4, 5 };
- Assert.AreEqual(55, Program.FindSquaresInArray(positiveArray));
- }
- [Test]
- public void TestArrayWithSingleElement()
- {
- int[] singleElementArray = { 4 };
- Assert.AreEqual(16, Program.FindSquaresInArray(singleElementArray));
- }
- [Test]
- public void TestArrayWithAllZeros()
- {
- int[] zeroArray = { 0, 0, 0, 0 };
- Assert.AreEqual(0, Program.FindSquaresInArray(zeroArray));
- }
- }
- }