Interview Q&A

Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.

4608 total questions 4508 technical 100 career & HR 4272 from PDF library

Showing 26–50 of 103

Popular tracks

Mid PDF
How do you categorize tests in NUnit?

Short answer: Use the [Category("CategoryName")] attribute to group tests, allowing filtering by category during test runs. [Test, Category("Integration")] public void IntegrationTest() { } Real-world…

Testing Read answer
Junior PDF
What is the difference between [Test] and [TestCase] in NUnit?

Short answer: [Test] marks a standard test method without parameters. [TestCase] provides inline parameter values to run the test multiple times with different inputs. Real-world example (ShopNest) ShopNest unit tests co…

Testing Read answer
Mid PDF
How do you ignore tests conditionally in NUnit?

Short answer: Use [Ignore("Reason")] to skip tests unconditionally, or [Category] combined with test runner filters. For conditional ignoring, you can use Assume statements or custom logic inside tests. Real-wo…

Testing Read answer
Mid PDF
How do you run NUnit tests using the NUnit console runner?

Short answer: Download and use nunit3-console.exe from NUnit site: nunit3-console.exe YourTestAssembly.dll It runs all tests in the assembly and outputs results. Real-world example (ShopNest) ShopNest unit tests cover pr…

Testing Read answer
Mid PDF
Can NUnit tests be integrated with CI/CD pipelines?

Short answer: Yes, NUnit integrates seamlessly with CI/CD tools like Azure DevOps, Jenkins, GitHub Actions, and others using command-line runners or plugins, allowing automated test execution during builds and deployment…

Testing Read answer
Junior PDF
What is MSTest and when should you use it?

Short answer: MSTest is Microsoft's official unit testing framework for .NET. It’s tightly integrated with Visual Studio and is a good choice for teams using Microsoft tooling and wanting a straightforward, supported tes…

Testing Read answer
Mid PDF
How do you write a simple test method in MSTest?

Short answer: [TestClass] public class CalculatorTests { [TestMethod] public void Add_ReturnsSum() Example code { var calculator = new Calculator(); var result = calculator.Add(2, 3); Assert.AreEqual(5, result); } } Real…

Testing Read answer
Mid PDF
What are the differences between MSTest and other frameworks like NUnit and xUnit?

Short answer: MSTest is Microsoft's official framework; NUnit and xUnit are community-driven. MSTest uses [TestClass] and [TestMethod] attributes; xUnit uses [Fact], NUnit uses [Test]. MSTest has less flexibility in data…

Testing Read answer
Mid PDF
How do you use the [TestInitialize] and [TestCleanup]

Short answer: ttributes? [TestInitialize] runs code before each test method to set up prerequisites. [TestCleanup] runs after each test method to clean up resources. [TestInitialize] public void Setup() { /* setup code *…

Testing Read answer
Mid PDF
How do you use the [TestInitialize] and [TestCleanup] attributes?

Short answer: [TestInitialize] runs code before each test method to set up prerequisites. [TestCleanup] runs after each test method to clean up resources. [TestInitialize] public void Setup() { /* setup code */ } [TestCl…

Testing Read answer
Mid PDF
How do you assert expected exceptions in MSTest?

Short answer: [TestMethod] [ExpectedException(typeof(DivideByZeroException))] public void Divide_ByZero_ThrowsException() Example code { var calculator = new Calculator(); calculator.Divide(10, 0); } Real-world example (…

Testing Read answer
Mid PDF
Can MSTest support data-driven testing?

Short answer: How? Yes, MSTest supports data-driven tests using [DataTestMethod] and [DataRow] attributes: [DataTestMethod] [DataRow(2, 3, 5)] [DataRow(10, 20, 30)] public void Add_ReturnsSum(int a, int b, int expected)…

Testing Read answer
Mid PDF
Can MSTest support data-driven testing? How?

Short answer: Yes, MSTest supports data-driven tests using [DataTestMethod] and [DataRow] ttributes: [DataTestMethod] [DataRow(2, 3, 5)] [DataRow(10, 20, 30)] public void Add_ReturnsSum(int a, int b, int expected) { var…

Testing Read answer
Mid PDF
How do you categorize or group tests in MSTest?

Short answer: Use the [TestCategory("CategoryName")] attribute to group tests for filtering. [TestMethod] [TestCategory("Integration")] public void IntegrationTest() { } Real-world example (ShopNest)…

Testing Read answer
Mid PDF
How do you ignore tests temporarily in MSTest?

Short answer: Use the [Ignore("Reason")] attribute on the test method or class. [Ignore("Test is temporarily disabled")] [TestMethod] public void SkippedTest() { } Real-world example (ShopNest) ShopNe…

Testing Read answer
Mid PDF
How to run MSTest tests via command line or Azure DevOps pipelines?

Short answer: Use dotnet test CLI for .NET Core MSTest projects: dotnet test YourTestProject.csproj In Azure DevOps, use the Visual Studio Test task or the DotNetCoreCLI task to run tests during builds and releases. Real…

Testing Read answer
Mid PDF
How do you mock dependencies when using MSTest?

Short answer: MSTest itself does not provide mocking capabilities. Use mocking libraries like Moq or NSubstitute alongside MSTest to mock dependencies. Example with Moq: var mockService = new Mock<IService>(); Exam…

Testing Read answer
Junior PDF
What is mocking and why is it important in unit testing?

Short answer: Mocking is creating fake objects that simulate the behavior of real dependencies. It’s important because it isolates the unit under test, avoids reliance on external systems, improves test speed, and allows…

Testing Read answer
Junior PDF
What is the Moq framework and how is it used in .NET?

Short answer: Moq is a popular, open-source mocking library for .NET that enables developers to create mock objects, set expectations, and verify interactions in unit tests, helping isolate dependencies easily. Real-worl…

Testing Read answer
Mid PDF
How do you create a mock object using Moq?

Short answer: var mockService = new Mock<IService>(); var service = mockService.Object; // use this in your test Example code var mockService = new Mock<IService>(); var service = mockService.Object; // use t…

Testing Read answer
Mid PDF
How do you set up method expectations in Moq?

Short answer: mockService.Setup(s => s.GetData()).Returns("Mocked Data"); This configures the mock to return "Mocked Data" when GetData() is called. Example code mockService.Setup(s => s.GetData…

Testing Read answer
Mid PDF
How do you verify that a method was called on a mock object?

Short answer: mockService.Verify(s => s.Save(), Times.Once); This asserts that Save() was called exactly once during the test. Example code mockService.Verify(s => s.Save(), Times.Once); This asserts that Save() wa…

Testing Read answer
Mid PDF
How do you mock properties using Moq?

Short answer: mockService.SetupGet(s => s.Name).Returns("MockName"); This sets up a mocked property getter to return a specific value. Example code mockService.SetupGet(s => s.Name).Returns("MockName…

Testing Read answer
Mid PDF
Can you mock methods with parameters?

Short answer: How? mockService.Setup(s => s.GetData(It.IsAny<int>())).Returns("Data"); You can specify argument matchers like It.IsAny<T>() to mock methods with parameters. Example code How? mock…

Testing Read answer
Mid PDF
Can you mock methods with parameters? How?

Short answer: mockService.Setup(s => s.GetData(It.IsAny<int>())).Returns("Data"); You can specify argument matchers like It.IsAny<T>() to mock methods with parameters. Explain a bit more mockServ…

Testing Read answer

Unit Testing C# Programming Tutorial · Testing

Short answer: Use the [Category("CategoryName")] attribute to group tests, allowing filtering by category during test runs. [Test, Category("Integration")] public void IntegrationTest() { }

Real-world example (ShopNest)

ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: [Test] marks a standard test method without parameters. [TestCase] provides inline parameter values to run the test multiple times with different inputs.

Real-world example (ShopNest)

ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: Use [Ignore("Reason")] to skip tests unconditionally, or [Category] combined with test runner filters. For conditional ignoring, you can use Assume statements or custom logic inside tests.

Real-world example (ShopNest)

ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: Download and use nunit3-console.exe from NUnit site: nunit3-console.exe YourTestAssembly.dll It runs all tests in the assembly and outputs results.

Real-world example (ShopNest)

ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: Yes, NUnit integrates seamlessly with CI/CD tools like Azure DevOps, Jenkins, GitHub Actions, and others using command-line runners or plugins, allowing automated test execution during builds and deployments. MSTest Framework

Real-world example (ShopNest)

ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: MSTest is Microsoft's official unit testing framework for .NET. It’s tightly integrated with Visual Studio and is a good choice for teams using Microsoft tooling and wanting a straightforward, supported testing solution without external dependencies.

Real-world example (ShopNest)

ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: [TestClass] public class CalculatorTests { [TestMethod] public void Add_ReturnsSum()

Example code

{
var calculator = new Calculator();
var result = calculator.Add(2, 3); Assert.AreEqual(5, result); }
}

Real-world example (ShopNest)

ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: MSTest is Microsoft's official framework; NUnit and xUnit are community-driven. MSTest uses [TestClass] and [TestMethod] attributes; xUnit uses [Fact], NUnit uses [Test]. MSTest has less flexibility in data-driven tests compared to NUnit’s [TestCase] and xUnit’s [Theory]. xUnit promotes constructor-based setup, MSTest uses [TestInitialize].

Real-world example (ShopNest)

ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: ttributes? [TestInitialize] runs code before each test method to set up prerequisites. [TestCleanup] runs after each test method to clean up resources. [TestInitialize] public void Setup() { /* setup code */ } [TestCleanup] public void Cleanup() { /* cleanup code */ }

Real-world example (ShopNest)

ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: [TestInitialize] runs code before each test method to set up prerequisites. [TestCleanup] runs after each test method to clean up resources. [TestInitialize] public void Setup() { /* setup code */ } [TestCleanup] public void Cleanup() { /* cleanup code */ }

Real-world example (ShopNest)

ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: [TestMethod] [ExpectedException(typeof(DivideByZeroException))] public void Divide_ByZero_ThrowsException()

Example code

{
var calculator = new Calculator(); calculator.Divide(10, 0); }

Real-world example (ShopNest)

Arrange a cart with 2 items → Act Checkout() → Assert total and that payment was called once.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: How? Yes, MSTest supports data-driven tests using [DataTestMethod] and [DataRow] attributes: [DataTestMethod] [DataRow(2, 3, 5)] [DataRow(10, 20, 30)] public void Add_ReturnsSum(int a, int b, int expected)

Example code

{
var calculator = new Calculator();
var result = calculator.Add(a, b); Assert.AreEqual(expected, result); }

Real-world example (ShopNest)

ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: Yes, MSTest supports data-driven tests using [DataTestMethod] and [DataRow] ttributes: [DataTestMethod] [DataRow(2, 3, 5)] [DataRow(10, 20, 30)] public void Add_ReturnsSum(int a, int b, int expected) { var calculator = new Calculator(); var result = calculator.Add(a, b); ssert.AreEqual(expected, result); } Yes, MSTest supports data-driven tests using… [DataTestMethod] and [DataRow] ttributes: [DataTestMethod]…

Explain a bit more

[DataRow(2, 3, 5)] [DataRow(10, 20, 30)] public void Add_ReturnsSum(int a, int b, int expected) { var calculator = new Calculator(); var result = calculator.Add(a, b); ssert.AreEqual(expected, result); }

Real-world example (ShopNest)

ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: Use the [TestCategory("CategoryName")] attribute to group tests for filtering. [TestMethod] [TestCategory("Integration")] public void IntegrationTest() { }

Real-world example (ShopNest)

ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: Use the [Ignore("Reason")] attribute on the test method or class. [Ignore("Test is temporarily disabled")] [TestMethod] public void SkippedTest() { }

Real-world example (ShopNest)

ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: Use dotnet test CLI for .NET Core MSTest projects: dotnet test YourTestProject.csproj In Azure DevOps, use the Visual Studio Test task or the DotNetCoreCLI task to run tests during builds and releases.

Real-world example (ShopNest)

ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: MSTest itself does not provide mocking capabilities. Use mocking libraries like Moq or NSubstitute alongside MSTest to mock dependencies. Example with Moq: var mockService = new Mock<IService>();

Example code

mockService.Setup(s => s.GetData()).Returns("Test Data"); Moq Framework (Mocking)

Real-world example (ShopNest)

When testing ShopNest’s order service, mock IPaymentGateway so tests do not call Razorpay.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: Mocking is creating fake objects that simulate the behavior of real dependencies. It’s important because it isolates the unit under test, avoids reliance on external systems, improves test speed, and allows testing specific scenarios and edge cases.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: Moq is a popular, open-source mocking library for .NET that enables developers to create mock objects, set expectations, and verify interactions in unit tests, helping isolate dependencies easily.

Real-world example (ShopNest)

ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: var mockService = new Mock<IService>(); var service = mockService.Object; // use this in your test

Example code

var mockService = new Mock<IService>();
var service = mockService.Object; // use this in your test

Real-world example (ShopNest)

When testing ShopNest’s order service, mock IPaymentGateway so tests do not call Razorpay.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: mockService.Setup(s => s.GetData()).Returns("Mocked Data"); This configures the mock to return "Mocked Data" when GetData() is called.

Example code

mockService.Setup(s => s.GetData()).Returns("Mocked Data"); This configures the mock to return "Mocked Data" when GetData() is called.

Real-world example (ShopNest)

ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: mockService.Verify(s => s.Save(), Times.Once); This asserts that Save() was called exactly once during the test.

Example code

mockService.Verify(s => s.Save(), Times.Once); This asserts that Save() was called exactly once during the test.

Real-world example (ShopNest)

When testing ShopNest’s order service, mock IPaymentGateway so tests do not call Razorpay.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: mockService.SetupGet(s => s.Name).Returns("MockName"); This sets up a mocked property getter to return a specific value.

Example code

mockService.SetupGet(s => s.Name).Returns("MockName"); This sets up a mocked property getter to return a specific value.

Real-world example (ShopNest)

When testing ShopNest’s order service, mock IPaymentGateway so tests do not call Razorpay.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: How? mockService.Setup(s => s.GetData(It.IsAny<int>())).Returns("Data"); You can specify argument matchers like It.IsAny<T>() to mock methods with parameters.

Example code

How? mockService.Setup(s => s.GetData(It.IsAny<int>())).Returns("Data"); You can specify argument matchers like It.IsAny<T>() to mock methods with parameters.

Real-world example (ShopNest)

When testing ShopNest’s order service, mock IPaymentGateway so tests do not call Razorpay.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Unit Testing C# Programming Tutorial · Testing

Short answer: mockService.Setup(s => s.GetData(It.IsAny<int>())).Returns("Data"); You can specify argument matchers like It.IsAny<T>() to mock methods with parameters.

Explain a bit more

mockService.Setup(s => s.GetData(It.IsAny<int>())).Returns("Data"); You can specify argument matchers like It.IsAny<T>() to mock methods with parameters. mockService.Setup(s => s.GetData(It.IsAny<int>())).Returns("Data"); You can specify argument matchers like It.IsAny<T>() to mock methods with parameters. mockService.Setup(s => s.GetData(It.IsAny<int>())).Returns("Data"); You can specify argument matchers like It.IsAny<T>() to mock methods with parameters.

Real-world example (ShopNest)

When testing ShopNest’s order service, mock IPaymentGateway so tests do not call Razorpay.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details