-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClusterDisposalTests.cs
More file actions
28 lines (23 loc) · 959 Bytes
/
ClusterDisposalTests.cs
File metadata and controls
28 lines (23 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using Couchbase.AnalyticsClient;
using Couchbase.AnalyticsClient.HTTP;
using Microsoft.Extensions.Logging;
using Moq;
using Xunit;
namespace Couchbase.Analytics.UnitTests;
public class ClusterDisposalTests
{
[Fact]
public void Cluster_Dispose_DisposesAllRegisteredSingletons()
{
var mockLoggerFactory = new Mock<ILoggerFactory>();
var cluster = Cluster.Create(
"http://localhost:8095",
new Credential("Administrator", "password"),
opts => opts.WithLogging(mockLoggerFactory.Object));
// Trigger the top-level Dispose, which must cascade down the DI structural tree
// and aggressively purge the singleton cache.
cluster.Dispose();
mockLoggerFactory.Verify(x => x.Dispose(), Times.Once, "The Cluster failed to actively dispose its registered singleton resources (like the logging framework and SocketsHttpHandler) during destruction!");
}
}