Skip to content

Conversation

@nytian
Copy link
Contributor

@nytian nytian commented Jan 13, 2026

Adds two approaches for dependency injection in DurableTaskTestHost:

  1. ConfigureServices - Register services directly in test host options
  2. AddInMemoryDurableTask() - Integrate with existing hosts (e.g., WebApplicationFactory)

Copilot AI review requested due to automatic review settings January 13, 2026 05:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds dependency injection support to DurableTaskTestHost, enabling orchestrations and activities to resolve services from a DI container. The implementation provides two approaches: ConfigureServices for simple test scenarios and AddInMemoryDurableTask() for integration with existing hosts.

Changes:

  • Added Services property to DurableTaskTestHost and ConfigureServices option to DurableTaskTestHostOptions
  • Introduced AddInMemoryDurableTask() extension method for integrating with existing service collections
  • Created comprehensive test suites demonstrating both DI approaches
  • Updated README with detailed documentation and examples

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
src/InProcessTestHost/DurableTaskTestHost.cs Added Services property exposing worker host's service provider and ConfigureServices option
src/InProcessTestHost/DurableTaskTestExtensions.cs New extension methods for AddInMemoryDurableTask() and GetInMemoryOrchestrationService()
src/InProcessTestHost/README.md Comprehensive documentation update with examples for both DI approaches
test/InProcessTestHost.Tests/DependencyInjectionTests.cs New test suite for ConfigureServices approach with multiple DI scenarios
test/InProcessTestHost.Tests/WebApplicationFactoryIntegrationTests.cs New test suite for AddInMemoryDurableTask() integration approach
test/InProcessTestHost.Tests/WebApplicationFactoryTestHelpers.cs Test helper types for integration tests
Directory.Packages.props Added package references (currently unused)

Copilot AI review requested due to automatic review settings January 16, 2026 04:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 31 comments.

Comment on lines +11 to +39
public class User
{
public int Id { get; set; }
public string Name { get; set; } = "";
public string Email { get; set; } = "";
}

public class Order
{
public int Id { get; set; }
public int UserId { get; set; }
public decimal Amount { get; set; }
public string Status { get; set; } = "";
}

public class UserDto
{
public int Id { get; set; }
public string Name { get; set; } = "";
public string Email { get; set; } = "";
}

public class OrderInput
{
public int OrderId { get; set; }
public int UserId { get; set; }
}

public class OrderOutput
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to coding guidelines, all private classes that do not serve as base classes should be sealed. These test helper classes (User, InMemoryUserRepository, InMemoryOrderRepository, UserService, OrderService, PaymentService) do not serve as base classes and should be marked as sealed for better performance and clarity.

Suggested change
public class User
{
public int Id { get; set; }
public string Name { get; set; } = "";
public string Email { get; set; } = "";
}
public class Order
{
public int Id { get; set; }
public int UserId { get; set; }
public decimal Amount { get; set; }
public string Status { get; set; } = "";
}
public class UserDto
{
public int Id { get; set; }
public string Name { get; set; } = "";
public string Email { get; set; } = "";
}
public class OrderInput
{
public int OrderId { get; set; }
public int UserId { get; set; }
}
public class OrderOutput
public sealed class User
{
public int Id { get; set; }
public string Name { get; set; } = "";
public string Email { get; set; } = "";
}
public sealed class Order
{
public int Id { get; set; }
public int UserId { get; set; }
public decimal Amount { get; set; }
public string Status { get; set; } = "";
}
public sealed class UserDto
{
public int Id { get; set; }
public string Name { get; set; } = "";
public string Email { get; set; } = "";
}
public sealed class OrderInput
{
public int OrderId { get; set; }
public int UserId { get; set; }
}
public sealed class OrderOutput

Copilot uses AI. Check for mistakes.
User? GetById(int id);
}

public class InMemoryUserRepository : IUserRepository
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to coding guidelines, all private classes that do not serve as base classes should be sealed. These test helper classes (User, InMemoryUserRepository, InMemoryOrderRepository, UserService, OrderService, PaymentService) do not serve as base classes and should be marked as sealed for better performance and clarity.

Copilot uses AI. Check for mistakes.
void Update(Order order);
}

public class InMemoryOrderRepository : IOrderRepository
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to coding guidelines, all private classes that do not serve as base classes should be sealed. These test helper classes (User, InMemoryUserRepository, InMemoryOrderRepository, UserService, OrderService, PaymentService) do not serve as base classes and should be marked as sealed for better performance and clarity.

Copilot uses AI. Check for mistakes.
UserDto? GetUser(int id);
}

public class UserService : IUserService
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to coding guidelines, all private classes that do not serve as base classes should be sealed. These test helper classes (User, InMemoryUserRepository, InMemoryOrderRepository, UserService, OrderService, PaymentService) do not serve as base classes and should be marked as sealed for better performance and clarity.

Copilot uses AI. Check for mistakes.
void UpdateStatus(int id, string status);
}

public class OrderService : IOrderService
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to coding guidelines, all private classes that do not serve as base classes should be sealed. These test helper classes (User, InMemoryUserRepository, InMemoryOrderRepository, UserService, OrderService, PaymentService) do not serve as base classes and should be marked as sealed for better performance and clarity.

Copilot uses AI. Check for mistakes.
public string Status { get; set; } = "";
}

public class UserDto
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to coding guidelines, all public classes should have XML documentation comments. These DTO and entity classes are missing XML documentation.

Copilot uses AI. Check for mistakes.
public string Email { get; set; } = "";
}

public class OrderInput
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to coding guidelines, all public classes should have XML documentation comments. These DTO and entity classes are missing XML documentation.

Copilot uses AI. Check for mistakes.
public int UserId { get; set; }
}

public class OrderOutput
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to coding guidelines, all public classes should have XML documentation comments. These DTO and entity classes are missing XML documentation.

Copilot uses AI. Check for mistakes.
Comment on lines +188 to +197

public class CalculatorInput
{
public int A { get; set; }
public int B { get; set; }
}

public class CalculatorOutput
{
public int Sum { get; set; }
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to coding guidelines, all public classes should have XML documentation comments. These DTO classes are missing XML documentation.

Suggested change
public class CalculatorInput
{
public int A { get; set; }
public int B { get; set; }
}
public class CalculatorOutput
{
public int Sum { get; set; }
/// <summary>
/// Represents input values for calculator orchestrator and activity tests.
/// </summary>
public class CalculatorInput
{
/// <summary>
/// Gets or sets the first operand value.
/// </summary>
public int A { get; set; }
/// <summary>
/// Gets or sets the second operand value.
/// </summary>
public int B { get; set; }
}
/// <summary>
/// Represents the calculated results for calculator orchestrator and activity tests.
/// </summary>
public class CalculatorOutput
{
/// <summary>
/// Gets or sets the sum of the input operands.
/// </summary>
public int Sum { get; set; }
/// <summary>
/// Gets or sets the product of the input operands.
/// </summary>

Copilot uses AI. Check for mistakes.
Comment on lines +188 to +197

public class CalculatorInput
{
public int A { get; set; }
public int B { get; set; }
}

public class CalculatorOutput
{
public int Sum { get; set; }
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to coding guidelines, all public classes should have XML documentation comments. These DTO classes are missing XML documentation.

Suggested change
public class CalculatorInput
{
public int A { get; set; }
public int B { get; set; }
}
public class CalculatorOutput
{
public int Sum { get; set; }
/// <summary>
/// Represents the input values for calculator operations in tests.
/// </summary>
public class CalculatorInput
{
/// <summary>
/// Gets or sets the first operand.
/// </summary>
public int A { get; set; }
/// <summary>
/// Gets or sets the second operand.
/// </summary>
public int B { get; set; }
}
/// <summary>
/// Represents the results of calculator operations in tests.
/// </summary>
public class CalculatorOutput
{
/// <summary>
/// Gets or sets the sum of the input operands.
/// </summary>
public int Sum { get; set; }
/// <summary>
/// Gets or sets the product of the input operands.
/// </summary>

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants