Junior — Middle
Have you created automated tests for C# code during development?
sobes.tech AI
Answer from AI
Yes, during development in C#, automatic tests are often created to verify the correctness of the code. Frameworks such as NUnit, MSTest, or xUnit are commonly used.
Here's a simple test example using NUnit:
using NUnit.Framework;
[TestFixture]
public class CalculatorTests
{
[Test]
public void Add_TwoNumbers_ReturnsSum()
{
var calculator = new Calculator();
int result = calculator.Add(2, 3);
Assert.AreEqual(5, result);
}
}
Automated tests help quickly identify errors and ensure stability when making changes.