
Unit Testing & xUnit
xUnit framework, test cases, assertions, Moq, FluentAssertions, code coverage, TDD principles
1What is xUnit in the context of .NET?
What is xUnit in the context of .NET?
Antwoord
xUnit is an open-source unit testing framework for .NET, inspired by JUnit and NUnit. It uses attributes like [Fact] for simple tests and [Theory] for parameterized tests. xUnit encourages best practices like test isolation (each test creates a new test class instance) and avoids shared state via traditional Setup/Teardown methods.
2What is the difference between [Fact] and [Theory] in xUnit?
What is the difference between [Fact] and [Theory] in xUnit?
Antwoord
[Fact] decorates a simple test that runs once without parameters, while [Theory] decorates a parameterized test that runs multiple times with different values provided via [InlineData], [MemberData], or [ClassData]. Using [Theory] avoids code duplication when testing multiple similar scenarios with different data.
3How to use [InlineData] with [Theory] in xUnit?
How to use [InlineData] with [Theory] in xUnit?
Antwoord
[InlineData] provides data directly in the attribute for a [Theory] test, allowing the same test to run with different values. Each [InlineData] attribute represents a distinct test case. This approach is ideal for testing multiple simple scenarios without creating separate data classes, reducing boilerplate code.
What is the main advantage of Moq in .NET unit testing?
How to configure a mock with Moq so that a method returns a specific value?
+17 gespreksvragen
Andere .NET-sollicitatieonderwerpen
C# Basics
LINQ & Delegates
C# Language Essentials
ASP.NET Core Fundamentals
ASP.NET Core Request Lifecycle
Configuration & Settings
Application Lifecycle
Dependency Injection
Entity Framework Core
Minimal APIs
Web API Development
Async in ASP.NET Core
Authentication & Authorization
HttpClient & Networking
JSON Serialization
Entity Framework Core Advanced
C# Advanced Features
Clean Architecture
Logging, Monitoring & Observability
Integration Testing
Docker & Containerization
NuGet Package Management
Memory Management & GC
Reactive Programming
Async/await & Patterns
.NET Design Patterns
Performance Optimization
Security & Best Practices
SignalR & Real-time
Microservices Architecture
Beheers .NET voor je volgende gesprek
Krijg toegang tot alle vragen, flashcards, technische tests, code review-oefeningen en gespreksimulatoren.
Begin gratis