Skip to content

Commit

Permalink
fb
Browse files Browse the repository at this point in the history
  • Loading branch information
YunchuWang committed Jan 15, 2025
1 parent 02d5992 commit e0bd4e2
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public void UseDurableTaskScheduler_WithEndpointAndCredential_ShouldConfigureCor
ServiceProvider provider = services.BuildServiceProvider();
IOptions<GrpcDurableTaskClientOptions>? options = provider.GetService<IOptions<GrpcDurableTaskClientOptions>>();
options.Should().NotBeNull();

// Validate the configured options
var clientOptions = provider.GetRequiredService<IOptions<DurableTaskSchedulerClientOptions>>().Value;
clientOptions.EndpointAddress.Should().Be(ValidEndpoint);
clientOptions.TaskHubName.Should().Be(ValidTaskHub);
clientOptions.Credential.Should().BeOfType<DefaultAzureCredential>();
}

[Fact]
Expand All @@ -51,6 +57,12 @@ public void UseDurableTaskScheduler_WithConnectionString_ShouldConfigureCorrectl
ServiceProvider provider = services.BuildServiceProvider();
IOptions<GrpcDurableTaskClientOptions>? options = provider.GetService<IOptions<GrpcDurableTaskClientOptions>>();
options.Should().NotBeNull();

// Validate the configured options
var clientOptions = provider.GetRequiredService<IOptions<DurableTaskSchedulerClientOptions>>().Value;
clientOptions.EndpointAddress.Should().Be(ValidEndpoint);
clientOptions.TaskHubName.Should().Be(ValidTaskHub);
clientOptions.Credential.Should().BeOfType<DefaultAzureCredential>();
}

[Theory]
Expand Down Expand Up @@ -93,6 +105,13 @@ public void UseDurableTaskScheduler_WithNullCredential_ShouldSucceed()
// Act & Assert
Action action = () => mockBuilder.Object.UseDurableTaskScheduler(ValidEndpoint, ValidTaskHub, credential!);
action.Should().NotThrow();

// Validate the configured options
ServiceProvider provider = services.BuildServiceProvider();
var clientOptions = provider.GetRequiredService<IOptions<DurableTaskSchedulerClientOptions>>().Value;
clientOptions.EndpointAddress.Should().Be(ValidEndpoint);
clientOptions.TaskHubName.Should().Be(ValidTaskHub);
clientOptions.Credential.Should().BeNull();
}

[Fact]
Expand Down Expand Up @@ -149,5 +168,7 @@ public void UseDurableTaskScheduler_WithNamedOptions_ShouldConfigureCorrectly()
options.EndpointAddress.Should().Be(ValidEndpoint); // The https:// prefix is added by CreateChannel, not in the extension method
options.TaskHubName.Should().Be(ValidTaskHub);
options.Credential.Should().BeOfType<DefaultAzureCredential>();
options.ResourceId.Should().Be("https://durabletask.io");
options.AllowInsecureCredentials.Should().BeFalse();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ public void UseDurableTaskScheduler_WithEndpointAndCredential_ShouldConfigureCor
ServiceProvider provider = services.BuildServiceProvider();
IOptions<GrpcDurableTaskWorkerOptions>? options = provider.GetService<IOptions<GrpcDurableTaskWorkerOptions>>();
options.Should().NotBeNull();

// Validate the configured options
var workerOptions = provider.GetRequiredService<IOptions<DurableTaskSchedulerWorkerOptions>>().Value;
workerOptions.EndpointAddress.Should().Be(ValidEndpoint);
workerOptions.TaskHubName.Should().Be(ValidTaskHub);
workerOptions.Credential.Should().BeOfType<DefaultAzureCredential>();
workerOptions.ResourceId.Should().Be("https://durabletask.io");
workerOptions.AllowInsecureCredentials.Should().BeFalse();
}

[Fact]
Expand All @@ -51,6 +59,14 @@ public void UseDurableTaskScheduler_WithConnectionString_ShouldConfigureCorrectl
ServiceProvider provider = services.BuildServiceProvider();
IOptions<GrpcDurableTaskWorkerOptions>? options = provider.GetService<IOptions<GrpcDurableTaskWorkerOptions>>();
options.Should().NotBeNull();

// Validate the configured options
var workerOptions = provider.GetRequiredService<IOptions<DurableTaskSchedulerWorkerOptions>>().Value;
workerOptions.EndpointAddress.Should().Be(ValidEndpoint);
workerOptions.TaskHubName.Should().Be(ValidTaskHub);
workerOptions.Credential.Should().BeOfType<DefaultAzureCredential>();
workerOptions.ResourceId.Should().Be("https://durabletask.io");
workerOptions.AllowInsecureCredentials.Should().BeFalse();
}

[Theory]
Expand Down Expand Up @@ -93,6 +109,15 @@ public void UseDurableTaskScheduler_WithNullCredential_ShouldSucceed()
// Act & Assert
Action action = () => mockBuilder.Object.UseDurableTaskScheduler(ValidEndpoint, ValidTaskHub, credential!);
action.Should().NotThrow();

// Validate the configured options
ServiceProvider provider = services.BuildServiceProvider();
var workerOptions = provider.GetRequiredService<IOptions<DurableTaskSchedulerWorkerOptions>>().Value;
workerOptions.EndpointAddress.Should().Be(ValidEndpoint);
workerOptions.TaskHubName.Should().Be(ValidTaskHub);
workerOptions.Credential.Should().BeNull();
workerOptions.ResourceId.Should().Be("https://durabletask.io");
workerOptions.AllowInsecureCredentials.Should().BeFalse();
}

[Fact]
Expand Down Expand Up @@ -149,5 +174,7 @@ public void UseDurableTaskScheduler_WithNamedOptions_ShouldConfigureCorrectly()
options.EndpointAddress.Should().Be(ValidEndpoint); // The https:// prefix is added by CreateChannel, not in the extension method
options.TaskHubName.Should().Be(ValidTaskHub);
options.Credential.Should().BeOfType<DefaultAzureCredential>();
options.ResourceId.Should().Be("https://durabletask.io");
options.AllowInsecureCredentials.Should().BeFalse();
}
}

0 comments on commit e0bd4e2

Please sign in to comment.