mirror of
https://github.com/AlexMacocian/SystemExtensions.git
synced 2026-07-15 14:19:29 +00:00
Replace Moq with NSubstitute (#51)
This commit is contained in:
+6
-8
@@ -1,6 +1,6 @@
|
|||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Moq;
|
using NSubstitute;
|
||||||
using System;
|
using System;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
|
|
||||||
@@ -10,8 +10,8 @@ namespace SystemExtensions.DependencyInjection.Tests.Configuration;
|
|||||||
public class LiveOptionsResolverTests
|
public class LiveOptionsResolverTests
|
||||||
{
|
{
|
||||||
private readonly LiveOptionsResolver liveOptionsResolver = new();
|
private readonly LiveOptionsResolver liveOptionsResolver = new();
|
||||||
private readonly Mock<Slim.IServiceProvider> serviceProviderMock = new();
|
private readonly Slim.IServiceProvider serviceProviderMock = Substitute.For<Slim.IServiceProvider>();
|
||||||
private readonly Mock<IOptionsManager> optionsManagerMock = new();
|
private readonly IOptionsManager optionsManagerMock = Substitute.For<IOptionsManager>();
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CanResolve_ILiveOptions_ReturnsTrue()
|
public void CanResolve_ILiveOptions_ReturnsTrue()
|
||||||
@@ -41,7 +41,7 @@ public class LiveOptionsResolverTests
|
|||||||
{
|
{
|
||||||
this.SetupServiceProvider();
|
this.SetupServiceProvider();
|
||||||
|
|
||||||
var liveOptions = this.liveOptionsResolver.Resolve(this.serviceProviderMock.Object, typeof(ILiveOptions<string>));
|
var liveOptions = this.liveOptionsResolver.Resolve(this.serviceProviderMock, typeof(ILiveOptions<string>));
|
||||||
|
|
||||||
liveOptions.Should().BeAssignableTo<ILiveOptions<string>>();
|
liveOptions.Should().BeAssignableTo<ILiveOptions<string>>();
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ public class LiveOptionsResolverTests
|
|||||||
|
|
||||||
Action action = new(() =>
|
Action action = new(() =>
|
||||||
{
|
{
|
||||||
this.liveOptionsResolver.Resolve(this.serviceProviderMock.Object, typeof(string));
|
this.liveOptionsResolver.Resolve(this.serviceProviderMock, typeof(string));
|
||||||
});
|
});
|
||||||
|
|
||||||
action.Should().Throw<Exception>();
|
action.Should().Throw<Exception>();
|
||||||
@@ -61,8 +61,6 @@ public class LiveOptionsResolverTests
|
|||||||
|
|
||||||
private void SetupServiceProvider()
|
private void SetupServiceProvider()
|
||||||
{
|
{
|
||||||
this.serviceProviderMock
|
this.serviceProviderMock.GetService<IOptionsManager>().Returns(this.optionsManagerMock);
|
||||||
.Setup(u => u.GetService<IOptionsManager>())
|
|
||||||
.Returns(this.optionsManagerMock.Object);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-8
@@ -1,6 +1,6 @@
|
|||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Moq;
|
using NSubstitute;
|
||||||
using System;
|
using System;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
|
|
||||||
@@ -10,8 +10,8 @@ namespace SystemExtensions.DependencyInjection.Tests.Configuration;
|
|||||||
public class LiveUpdateableOptionsResolverTests
|
public class LiveUpdateableOptionsResolverTests
|
||||||
{
|
{
|
||||||
private readonly LiveUpdateableOptionsResolver liveUpdateableOptionsResolver = new();
|
private readonly LiveUpdateableOptionsResolver liveUpdateableOptionsResolver = new();
|
||||||
private readonly Mock<Slim.IServiceProvider> serviceProviderMock = new();
|
private readonly Slim.IServiceProvider serviceProviderMock = Substitute.For<Slim.IServiceProvider>();
|
||||||
private readonly Mock<IOptionsManager> optionsManagerMock = new();
|
private readonly IOptionsManager optionsManagerMock = Substitute.For<IOptionsManager>();
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CanResolve_ILiveUpdateableOptions_ReturnsTrue()
|
public void CanResolve_ILiveUpdateableOptions_ReturnsTrue()
|
||||||
@@ -41,7 +41,7 @@ public class LiveUpdateableOptionsResolverTests
|
|||||||
{
|
{
|
||||||
this.SetupServiceProvider();
|
this.SetupServiceProvider();
|
||||||
|
|
||||||
var liveOptions = this.liveUpdateableOptionsResolver.Resolve(this.serviceProviderMock.Object, typeof(ILiveUpdateableOptions<string>));
|
var liveOptions = this.liveUpdateableOptionsResolver.Resolve(this.serviceProviderMock, typeof(ILiveUpdateableOptions<string>));
|
||||||
|
|
||||||
liveOptions.Should().BeAssignableTo<ILiveUpdateableOptions<string>>();
|
liveOptions.Should().BeAssignableTo<ILiveUpdateableOptions<string>>();
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ public class LiveUpdateableOptionsResolverTests
|
|||||||
|
|
||||||
Action action = new(() =>
|
Action action = new(() =>
|
||||||
{
|
{
|
||||||
this.liveUpdateableOptionsResolver.Resolve(this.serviceProviderMock.Object, typeof(string));
|
this.liveUpdateableOptionsResolver.Resolve(this.serviceProviderMock, typeof(string));
|
||||||
});
|
});
|
||||||
|
|
||||||
action.Should().Throw<Exception>();
|
action.Should().Throw<Exception>();
|
||||||
@@ -61,8 +61,6 @@ public class LiveUpdateableOptionsResolverTests
|
|||||||
|
|
||||||
private void SetupServiceProvider()
|
private void SetupServiceProvider()
|
||||||
{
|
{
|
||||||
this.serviceProviderMock
|
this.serviceProviderMock.GetService<IOptionsManager>().Returns(this.optionsManagerMock);
|
||||||
.Setup(u => u.GetService<IOptionsManager>())
|
|
||||||
.Returns(this.optionsManagerMock.Object);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-11
@@ -1,6 +1,6 @@
|
|||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Moq;
|
using NSubstitute;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
|
|
||||||
namespace SystemExtensions.DependencyInjection.Tests.Configuration;
|
namespace SystemExtensions.DependencyInjection.Tests.Configuration;
|
||||||
@@ -9,20 +9,18 @@ namespace SystemExtensions.DependencyInjection.Tests.Configuration;
|
|||||||
public class LiveUpdateableOptionsWrapperTests
|
public class LiveUpdateableOptionsWrapperTests
|
||||||
{
|
{
|
||||||
private LiveUpdateableOptionsWrapper<string> optionsWrapper;
|
private LiveUpdateableOptionsWrapper<string> optionsWrapper;
|
||||||
private readonly Mock<IOptionsManager> optionsManagerMock = new();
|
private readonly IOptionsManager optionsManagerMock = Substitute.For<IOptionsManager>();
|
||||||
|
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void TestInitialize()
|
public void TestInitialize()
|
||||||
{
|
{
|
||||||
this.optionsWrapper = new LiveUpdateableOptionsWrapper<string>(this.optionsManagerMock.Object);
|
this.optionsWrapper = new LiveUpdateableOptionsWrapper<string>(this.optionsManagerMock);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void GetValue_ReturnsValue()
|
public void GetValue_ReturnsValue()
|
||||||
{
|
{
|
||||||
this.optionsManagerMock
|
this.optionsManagerMock.GetOptions<string>().Returns("hello");
|
||||||
.Setup(u => u.GetOptions<string>())
|
|
||||||
.Returns("hello");
|
|
||||||
|
|
||||||
var value = this.optionsWrapper.Value;
|
var value = this.optionsWrapper.Value;
|
||||||
|
|
||||||
@@ -32,12 +30,8 @@ public class LiveUpdateableOptionsWrapperTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void UpdateOption_CallsOptionsManager()
|
public void UpdateOption_CallsOptionsManager()
|
||||||
{
|
{
|
||||||
this.optionsManagerMock
|
|
||||||
.Setup(u => u.UpdateOptions<string>(It.IsAny<string>()))
|
|
||||||
.Verifiable();
|
|
||||||
|
|
||||||
this.optionsWrapper.UpdateOption();
|
this.optionsWrapper.UpdateOption();
|
||||||
|
|
||||||
this.optionsManagerMock.Verify();
|
this.optionsManagerMock.ReceivedWithAnyArgs().UpdateOptions(Arg.Any<string>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Moq;
|
using NSubstitute;
|
||||||
using System;
|
using System;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
|
|
||||||
@@ -11,9 +11,9 @@ namespace SystemExtensions.DependencyInjection.Tests.Configuration;
|
|||||||
public class OptionsResolverTests
|
public class OptionsResolverTests
|
||||||
{
|
{
|
||||||
private readonly OptionsResolver optionsResolver = new();
|
private readonly OptionsResolver optionsResolver = new();
|
||||||
private readonly Mock<Slim.IServiceProvider> serviceProviderMock = new();
|
private readonly Slim.IServiceProvider serviceProviderMock = Substitute.For<Slim.IServiceProvider>();
|
||||||
|
|
||||||
public Mock<IOptionsManager> OptionsManagerMock { get; } = new();
|
public IOptionsManager OptionsManagerMock { get; } = Substitute.For<IOptionsManager>();
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CanResolve_ILiveOptions_ReturnsTrue()
|
public void CanResolve_ILiveOptions_ReturnsTrue()
|
||||||
@@ -43,7 +43,7 @@ public class OptionsResolverTests
|
|||||||
{
|
{
|
||||||
this.SetupServiceProvider();
|
this.SetupServiceProvider();
|
||||||
|
|
||||||
var liveOptions = this.optionsResolver.Resolve(this.serviceProviderMock.Object, typeof(IOptions<string>));
|
var liveOptions = this.optionsResolver.Resolve(this.serviceProviderMock, typeof(IOptions<string>));
|
||||||
|
|
||||||
liveOptions.Should().BeAssignableTo<IOptions<string>>();
|
liveOptions.Should().BeAssignableTo<IOptions<string>>();
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@ public class OptionsResolverTests
|
|||||||
|
|
||||||
Action action = new(() =>
|
Action action = new(() =>
|
||||||
{
|
{
|
||||||
this.optionsResolver.Resolve(this.serviceProviderMock.Object, typeof(string));
|
this.optionsResolver.Resolve(this.serviceProviderMock, typeof(string));
|
||||||
});
|
});
|
||||||
|
|
||||||
action.Should().Throw<Exception>();
|
action.Should().Throw<Exception>();
|
||||||
@@ -63,8 +63,6 @@ public class OptionsResolverTests
|
|||||||
|
|
||||||
private void SetupServiceProvider()
|
private void SetupServiceProvider()
|
||||||
{
|
{
|
||||||
this.serviceProviderMock
|
this.serviceProviderMock.GetService<IOptionsManager>().Returns(this.OptionsManagerMock);
|
||||||
.Setup(u => u.GetService<IOptionsManager>())
|
|
||||||
.Returns(this.OptionsManagerMock.Object);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-8
@@ -1,6 +1,6 @@
|
|||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Moq;
|
using NSubstitute;
|
||||||
using System;
|
using System;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
|
|
||||||
@@ -10,8 +10,8 @@ namespace SystemExtensions.DependencyInjection.Tests.Configuration;
|
|||||||
public class UpdateableOptionsResolverTests
|
public class UpdateableOptionsResolverTests
|
||||||
{
|
{
|
||||||
private readonly UpdateableOptionsResolver updateableOptionsResolver = new();
|
private readonly UpdateableOptionsResolver updateableOptionsResolver = new();
|
||||||
private readonly Mock<Slim.IServiceProvider> serviceProviderMock = new();
|
private readonly Slim.IServiceProvider serviceProviderMock = Substitute.For<Slim.IServiceProvider>();
|
||||||
private readonly Mock<IOptionsManager> optionsManagerMock = new();
|
private readonly IOptionsManager optionsManagerMock = Substitute.For<IOptionsManager>();
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CanResolve_ILiveOptions_ReturnsTrue()
|
public void CanResolve_ILiveOptions_ReturnsTrue()
|
||||||
@@ -41,7 +41,7 @@ public class UpdateableOptionsResolverTests
|
|||||||
{
|
{
|
||||||
this.SetupServiceProvider();
|
this.SetupServiceProvider();
|
||||||
|
|
||||||
var liveOptions = this.updateableOptionsResolver.Resolve(this.serviceProviderMock.Object, typeof(IUpdateableOptions<string>));
|
var liveOptions = this.updateableOptionsResolver.Resolve(this.serviceProviderMock, typeof(IUpdateableOptions<string>));
|
||||||
|
|
||||||
liveOptions.Should().BeAssignableTo<IUpdateableOptions<string>>();
|
liveOptions.Should().BeAssignableTo<IUpdateableOptions<string>>();
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ public class UpdateableOptionsResolverTests
|
|||||||
|
|
||||||
Action action = new(() =>
|
Action action = new(() =>
|
||||||
{
|
{
|
||||||
this.updateableOptionsResolver.Resolve(this.serviceProviderMock.Object, typeof(string));
|
this.updateableOptionsResolver.Resolve(this.serviceProviderMock, typeof(string));
|
||||||
});
|
});
|
||||||
|
|
||||||
action.Should().Throw<Exception>();
|
action.Should().Throw<Exception>();
|
||||||
@@ -61,8 +61,6 @@ public class UpdateableOptionsResolverTests
|
|||||||
|
|
||||||
private void SetupServiceProvider()
|
private void SetupServiceProvider()
|
||||||
{
|
{
|
||||||
this.serviceProviderMock
|
this.serviceProviderMock.GetService<IOptionsManager>().Returns(this.optionsManagerMock);
|
||||||
.Setup(u => u.GetService<IOptionsManager>())
|
|
||||||
.Returns(this.optionsManagerMock.Object);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-11
@@ -1,6 +1,7 @@
|
|||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Moq;
|
using NSubstitute;
|
||||||
|
using NSubstitute.ExceptionExtensions;
|
||||||
using System;
|
using System;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
using System.Extensions.Configuration;
|
using System.Extensions.Configuration;
|
||||||
@@ -13,20 +14,18 @@ public class UpdateableOptionsWrapperTests
|
|||||||
private const string Value = "hello";
|
private const string Value = "hello";
|
||||||
|
|
||||||
private UpdateableOptionsWrapper<string> optionsWrapper;
|
private UpdateableOptionsWrapper<string> optionsWrapper;
|
||||||
private readonly Mock<IOptionsManager> optionsManagerMock = new();
|
private readonly IOptionsManager optionsManagerMock = Substitute.For<IOptionsManager>();
|
||||||
|
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void TestInitialize()
|
public void TestInitialize()
|
||||||
{
|
{
|
||||||
this.optionsWrapper = new UpdateableOptionsWrapper<string>(this.optionsManagerMock.Object, Value);
|
this.optionsWrapper = new UpdateableOptionsWrapper<string>(this.optionsManagerMock, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void GetValue_ReturnsValue()
|
public void GetValue_ReturnsValue()
|
||||||
{
|
{
|
||||||
this.optionsManagerMock
|
this.optionsManagerMock.GetOptions<string>().Throws<Exception>();
|
||||||
.Setup(u => u.GetOptions<string>())
|
|
||||||
.Throws<Exception>();
|
|
||||||
|
|
||||||
var value = this.optionsWrapper.Value;
|
var value = this.optionsWrapper.Value;
|
||||||
|
|
||||||
@@ -36,12 +35,8 @@ public class UpdateableOptionsWrapperTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void UpdateOption_CallsOptionsManager()
|
public void UpdateOption_CallsOptionsManager()
|
||||||
{
|
{
|
||||||
this.optionsManagerMock
|
|
||||||
.Setup(u => u.UpdateOptions<string>(It.IsAny<string>()))
|
|
||||||
.Verifiable();
|
|
||||||
|
|
||||||
this.optionsWrapper.UpdateOption();
|
this.optionsWrapper.UpdateOption();
|
||||||
|
|
||||||
this.optionsManagerMock.Verify();
|
this.optionsManagerMock.ReceivedWithAnyArgs().UpdateOptions(Arg.Any<string>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Moq;
|
using NSubstitute;
|
||||||
|
using NSubstitute.ExceptionExtensions;
|
||||||
using Slim;
|
using Slim;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -17,12 +18,12 @@ public sealed class HttpClientBuilderTests
|
|||||||
private const string SomeValue = "SomeValue";
|
private const string SomeValue = "SomeValue";
|
||||||
|
|
||||||
private readonly HttpClientBuilder<object> httpClientBuilder;
|
private readonly HttpClientBuilder<object> httpClientBuilder;
|
||||||
private readonly Mock<IServiceProducer> serviceProducerMock = new();
|
private readonly IServiceProducer serviceProducerMock = Substitute.For<IServiceProducer>();
|
||||||
private readonly Uri baseAddress = new("http://contoso.co");
|
private readonly Uri baseAddress = new("http://contoso.co");
|
||||||
|
|
||||||
public HttpClientBuilderTests()
|
public HttpClientBuilderTests()
|
||||||
{
|
{
|
||||||
this.httpClientBuilder = new HttpClientBuilder<object>(this.serviceProducerMock.Object);
|
this.httpClientBuilder = new HttpClientBuilder<object>(this.serviceProducerMock);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@@ -62,26 +63,25 @@ public sealed class HttpClientBuilderTests
|
|||||||
{
|
{
|
||||||
var producer = this.httpClientBuilder.Build();
|
var producer = this.httpClientBuilder.Build();
|
||||||
|
|
||||||
producer.Should().Be(this.serviceProducerMock.Object);
|
producer.Should().Be(this.serviceProducerMock);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Build_RegistersWithServiceProducer()
|
public void Build_RegistersWithServiceProducer()
|
||||||
{
|
{
|
||||||
this.serviceProducerMock.Setup(u => u.RegisterScoped(It.IsAny<Func<Slim.IServiceProvider, IHttpClient<object>>>(), false));
|
|
||||||
|
|
||||||
this.httpClientBuilder.Build();
|
this.httpClientBuilder.Build();
|
||||||
|
|
||||||
this.serviceProducerMock.Verify();
|
this.serviceProducerMock.Received().RegisterScoped(Arg.Any<Func<Slim.IServiceProvider, IHttpClient<object>>>(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Build_CreatesExpectedClient()
|
public void Build_CreatesExpectedClient()
|
||||||
{
|
{
|
||||||
this.serviceProducerMock.Setup(u => u.RegisterScoped(It.IsAny<Func<Slim.IServiceProvider, IHttpClient<object>>>(), false))
|
this.serviceProducerMock.When(u => u.RegisterScoped(Arg.Any<Func<Slim.IServiceProvider, IHttpClient<object>>>(), false))
|
||||||
.Callback<Func<Slim.IServiceProvider, IHttpClient<object>>, bool>((factory, _) =>
|
.Do(callInfo =>
|
||||||
{
|
{
|
||||||
var client = factory(new Mock<Slim.IServiceProvider>().Object);
|
var factory = callInfo.ArgAt<Func<Slim.IServiceProvider, IHttpClient<object>>>(0);
|
||||||
|
var client = factory(Substitute.For<Slim.IServiceProvider>());
|
||||||
client.BaseAddress.Should().BeNull();
|
client.BaseAddress.Should().BeNull();
|
||||||
client.DefaultRequestHeaders.Should().BeEmpty();
|
client.DefaultRequestHeaders.Should().BeEmpty();
|
||||||
client.MaxResponseContentBufferSize.Should().Be(2147483647L);
|
client.MaxResponseContentBufferSize.Should().Be(2147483647L);
|
||||||
@@ -89,15 +89,17 @@ public sealed class HttpClientBuilderTests
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.httpClientBuilder.Build();
|
this.httpClientBuilder.Build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Build_WithBaseAddress_ReturnsClientWithBaseAddress()
|
public void Build_WithBaseAddress_ReturnsClientWithBaseAddress()
|
||||||
{
|
{
|
||||||
this.serviceProducerMock.Setup(u => u.RegisterScoped(It.IsAny<Func<Slim.IServiceProvider, IHttpClient<object>>>(), false))
|
this.serviceProducerMock.When(u => u.RegisterScoped(Arg.Any<Func<Slim.IServiceProvider, IHttpClient<object>>>(), false))
|
||||||
.Callback<Func<Slim.IServiceProvider, IHttpClient<object>>, bool>((factory, _) =>
|
.Do(callInfo =>
|
||||||
{
|
{
|
||||||
var client = factory(new Mock<Slim.IServiceProvider>().Object);
|
var factory = callInfo.ArgAt<Func<Slim.IServiceProvider, IHttpClient<object>>>(0);
|
||||||
|
var client = factory(Substitute.For<Slim.IServiceProvider>());
|
||||||
client.BaseAddress.Should().Be(this.baseAddress);
|
client.BaseAddress.Should().Be(this.baseAddress);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -108,12 +110,12 @@ public sealed class HttpClientBuilderTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Build_WithDefaultRequestHeaders_CallsFactory()
|
public void Build_WithDefaultRequestHeaders_CallsFactory()
|
||||||
{
|
{
|
||||||
this.serviceProducerMock.Setup(u => u.RegisterScoped(It.IsAny<Func<Slim.IServiceProvider, IHttpClient<object>>>(), false))
|
this.serviceProducerMock.When(u => u.RegisterScoped(Arg.Any<Func<Slim.IServiceProvider, IHttpClient<object>>>(), false))
|
||||||
.Callback<Func<Slim.IServiceProvider, IHttpClient<object>>, bool>((factory, _) =>
|
.Do(callInfo =>
|
||||||
{
|
{
|
||||||
var client = factory(new Mock<Slim.IServiceProvider>().Object);
|
var factory = callInfo.ArgAt<Func<Slim.IServiceProvider, IHttpClient<object>>>(0);
|
||||||
|
var client = factory(Substitute.For<Slim.IServiceProvider>());
|
||||||
client.DefaultRequestHeaders.TryGetValues(SomeHeader, out var values);
|
client.DefaultRequestHeaders.TryGetValues(SomeHeader, out var values);
|
||||||
|
|
||||||
values.Should().HaveCount(1);
|
values.Should().HaveCount(1);
|
||||||
values.FirstOrDefault().Should().Be(SomeValue);
|
values.FirstOrDefault().Should().Be(SomeValue);
|
||||||
});
|
});
|
||||||
@@ -127,10 +129,11 @@ public sealed class HttpClientBuilderTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Build_WithMaxResponseBufferSize_ReturnsClientWithMaxResponseBufferSize()
|
public void Build_WithMaxResponseBufferSize_ReturnsClientWithMaxResponseBufferSize()
|
||||||
{
|
{
|
||||||
this.serviceProducerMock.Setup(u => u.RegisterScoped(It.IsAny<Func<Slim.IServiceProvider, IHttpClient<object>>>(), false))
|
this.serviceProducerMock.When(u => u.RegisterScoped(Arg.Any<Func<Slim.IServiceProvider, IHttpClient<object>>>(), false))
|
||||||
.Callback<Func<Slim.IServiceProvider, IHttpClient<object>>, bool>((factory, _) =>
|
.Do(callInfo =>
|
||||||
{
|
{
|
||||||
var client = factory(new Mock<Slim.IServiceProvider>().Object);
|
var factory = callInfo.ArgAt<Func<Slim.IServiceProvider, IHttpClient<object>>>(0);
|
||||||
|
var client = factory(Substitute.For<Slim.IServiceProvider>());
|
||||||
client.MaxResponseContentBufferSize.Should().Be(100);
|
client.MaxResponseContentBufferSize.Should().Be(100);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -141,10 +144,11 @@ public sealed class HttpClientBuilderTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Build_WithTimeout_ReturnsClientWithTimeout()
|
public void Build_WithTimeout_ReturnsClientWithTimeout()
|
||||||
{
|
{
|
||||||
this.serviceProducerMock.Setup(u => u.RegisterScoped(It.IsAny<Func<Slim.IServiceProvider, IHttpClient<object>>>(), false))
|
this.serviceProducerMock.When(u => u.RegisterScoped(Arg.Any<Func<Slim.IServiceProvider, IHttpClient<object>>>(), false))
|
||||||
.Callback<Func<Slim.IServiceProvider, IHttpClient<object>>, bool>((factory, _) =>
|
.Do(callInfo =>
|
||||||
{
|
{
|
||||||
var client = factory(new Mock<Slim.IServiceProvider>().Object);
|
var factory = callInfo.ArgAt<Func<Slim.IServiceProvider, IHttpClient<object>>>(0);
|
||||||
|
var client = factory(Substitute.For<Slim.IServiceProvider>());
|
||||||
client.Timeout.Should().Be(TimeSpan.FromSeconds(5));
|
client.Timeout.Should().Be(TimeSpan.FromSeconds(5));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -156,10 +160,11 @@ public sealed class HttpClientBuilderTests
|
|||||||
public void Build_WithMessageHandler_CallsMessageHandler()
|
public void Build_WithMessageHandler_CallsMessageHandler()
|
||||||
{
|
{
|
||||||
var handlerMock = new HttpMessageHandlerMock();
|
var handlerMock = new HttpMessageHandlerMock();
|
||||||
this.serviceProducerMock.Setup(u => u.RegisterScoped(It.IsAny<Func<Slim.IServiceProvider, IHttpClient<object>>>(), false))
|
this.serviceProducerMock.When(u => u.RegisterScoped(Arg.Any<Func<Slim.IServiceProvider, IHttpClient<object>>>(), false))
|
||||||
.Callback<Func<Slim.IServiceProvider, IHttpClient<object>>, bool>(async (factory, _) =>
|
.Do(async callInfo =>
|
||||||
{
|
{
|
||||||
var client = factory(new Mock<Slim.IServiceProvider>().Object);
|
var factory = callInfo.ArgAt<Func<Slim.IServiceProvider, IHttpClient<object>>>(0);
|
||||||
|
var client = factory(Substitute.For<Slim.IServiceProvider>());
|
||||||
await client.GetAsync(this.baseAddress);
|
await client.GetAsync(this.baseAddress);
|
||||||
handlerMock.Called.Should().BeTrue();
|
handlerMock.Called.Should().BeTrue();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Moq;
|
using NSubstitute;
|
||||||
using System;
|
using System;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ namespace SystemExtensions.DependencyInjection.Tests.Http;
|
|||||||
public class HttpClientResolverTests
|
public class HttpClientResolverTests
|
||||||
{
|
{
|
||||||
private readonly HttpClientResolver httpClientResolver = new();
|
private readonly HttpClientResolver httpClientResolver = new();
|
||||||
private readonly Mock<Slim.IServiceProvider> serviceProviderMock = new();
|
private readonly Slim.IServiceProvider serviceProviderMock = Substitute.For<Slim.IServiceProvider>();
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CanResolve_IHttpClient_ReturnsTrue()
|
public void CanResolve_IHttpClient_ReturnsTrue()
|
||||||
@@ -38,7 +38,7 @@ public class HttpClientResolverTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Resolve_TypedClient_ReturnsIHttpClient()
|
public void Resolve_TypedClient_ReturnsIHttpClient()
|
||||||
{
|
{
|
||||||
var client = this.httpClientResolver.Resolve(this.serviceProviderMock.Object, typeof(IHttpClient<string>));
|
var client = this.httpClientResolver.Resolve(this.serviceProviderMock, typeof(IHttpClient<string>));
|
||||||
|
|
||||||
client.Should().BeAssignableTo<IHttpClient<string>>();
|
client.Should().BeAssignableTo<IHttpClient<string>>();
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,7 @@ public class HttpClientResolverTests
|
|||||||
{
|
{
|
||||||
Action action = new(() =>
|
Action action = new(() =>
|
||||||
{
|
{
|
||||||
this.httpClientResolver.Resolve(this.serviceProviderMock.Object, typeof(IHttpClient<>));
|
this.httpClientResolver.Resolve(this.serviceProviderMock, typeof(IHttpClient<>));
|
||||||
});
|
});
|
||||||
|
|
||||||
action.Should().Throw<Exception>();
|
action.Should().Throw<Exception>();
|
||||||
@@ -59,7 +59,7 @@ public class HttpClientResolverTests
|
|||||||
{
|
{
|
||||||
Action action = new(() =>
|
Action action = new(() =>
|
||||||
{
|
{
|
||||||
this.httpClientResolver.Resolve(this.serviceProviderMock.Object, typeof(string));
|
this.httpClientResolver.Resolve(this.serviceProviderMock, typeof(string));
|
||||||
});
|
});
|
||||||
|
|
||||||
action.Should().Throw<Exception>();
|
action.Should().Throw<Exception>();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Moq;
|
using NSubstitute;
|
||||||
using System.Logging;
|
using System.Logging;
|
||||||
|
|
||||||
namespace SystemExtensions.DependencyInjection.Tests.Logging;
|
namespace SystemExtensions.DependencyInjection.Tests.Logging;
|
||||||
@@ -8,13 +8,13 @@ namespace SystemExtensions.DependencyInjection.Tests.Logging;
|
|||||||
[TestClass]
|
[TestClass]
|
||||||
public class CVLoggerProviderTests
|
public class CVLoggerProviderTests
|
||||||
{
|
{
|
||||||
private readonly Mock<ILogsWriter> logsWriterMock = new();
|
private readonly ILogsWriter logsWriterMock = Substitute.For<ILogsWriter>();
|
||||||
private CVLoggerProvider cVLoggerProvider;
|
private CVLoggerProvider cVLoggerProvider;
|
||||||
|
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void TestInitialize()
|
public void TestInitialize()
|
||||||
{
|
{
|
||||||
this.cVLoggerProvider = new CVLoggerProvider(this.logsWriterMock.Object);
|
this.cVLoggerProvider = new CVLoggerProvider(this.logsWriterMock);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@@ -30,13 +30,6 @@ public class CVLoggerProviderTests
|
|||||||
{
|
{
|
||||||
this.cVLoggerProvider.LogEntry(new Log());
|
this.cVLoggerProvider.LogEntry(new Log());
|
||||||
|
|
||||||
this.logsWriterMock.Verify();
|
this.logsWriterMock.ReceivedWithAnyArgs().WriteLog(Arg.Any<Log>());
|
||||||
}
|
|
||||||
|
|
||||||
private void SetupLogsWriter()
|
|
||||||
{
|
|
||||||
this.logsWriterMock
|
|
||||||
.Setup(u => u.WriteLog(It.IsAny<Log>()))
|
|
||||||
.Verifiable();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Moq;
|
using NSubstitute;
|
||||||
using System;
|
using System;
|
||||||
using System.Logging;
|
using System.Logging;
|
||||||
|
|
||||||
@@ -10,13 +10,13 @@ namespace SystemExtensions.DependencyInjection.Tests.Logging;
|
|||||||
[TestClass]
|
[TestClass]
|
||||||
public class CVLoggerTests
|
public class CVLoggerTests
|
||||||
{
|
{
|
||||||
private readonly Mock<ICVLoggerProvider> cvLoggerProviderMock = new();
|
private readonly ICVLoggerProvider cvLoggerProviderMock = Substitute.For<ICVLoggerProvider>();
|
||||||
private CVLogger cVLogger;
|
private CVLogger cVLogger;
|
||||||
|
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void TestInitialize()
|
public void TestInitialize()
|
||||||
{
|
{
|
||||||
this.cVLogger = new CVLogger(string.Empty, this.cvLoggerProviderMock.Object);
|
this.cVLogger = new CVLogger(string.Empty, this.cvLoggerProviderMock);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@@ -59,17 +59,8 @@ public class CVLoggerTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Log_CallsLogsProvider()
|
public void Log_CallsLogsProvider()
|
||||||
{
|
{
|
||||||
this.SetupLoggerProvider();
|
|
||||||
|
|
||||||
this.cVLogger.Log(LogLevel.Debug, new EventId(), "Some message", new Exception(), new Func<string, Exception, string>((s, e) => string.Empty));
|
this.cVLogger.Log(LogLevel.Debug, new EventId(), "Some message", new Exception(), new Func<string, Exception, string>((s, e) => string.Empty));
|
||||||
|
|
||||||
this.cvLoggerProviderMock.Verify();
|
this.cvLoggerProviderMock.ReceivedWithAnyArgs().LogEntry(Arg.Any<Log>());
|
||||||
}
|
|
||||||
|
|
||||||
private void SetupLoggerProvider()
|
|
||||||
{
|
|
||||||
this.cvLoggerProviderMock
|
|
||||||
.Setup(u => u.LogEntry(It.IsAny<Log>()))
|
|
||||||
.Verifiable();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Moq;
|
using NSubstitute;
|
||||||
using System;
|
using System;
|
||||||
using System.Logging;
|
using System.Logging;
|
||||||
|
|
||||||
@@ -10,9 +10,9 @@ namespace SystemExtensions.DependencyInjection.Tests.Logging;
|
|||||||
[TestClass]
|
[TestClass]
|
||||||
public class LoggerResolverTests
|
public class LoggerResolverTests
|
||||||
{
|
{
|
||||||
private readonly Mock<Slim.IServiceProvider> serviceProviderMock = new();
|
private readonly Slim.IServiceProvider serviceProviderMock = Substitute.For<Slim.IServiceProvider>();
|
||||||
private readonly Mock<ILoggerFactory> loggerFactoryMock = new();
|
private readonly ILoggerFactory loggerFactoryMock = Substitute.For<ILoggerFactory>();
|
||||||
private readonly Mock<ILogger> loggerMock = new();
|
private readonly ILogger loggerMock = Substitute.For<ILogger>();
|
||||||
private readonly LoggerResolver loggerResolver = new();
|
private readonly LoggerResolver loggerResolver = new();
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@@ -53,7 +53,7 @@ public class LoggerResolverTests
|
|||||||
{
|
{
|
||||||
this.SetupIServiceProvider();
|
this.SetupIServiceProvider();
|
||||||
|
|
||||||
var logger = this.loggerResolver.Resolve(this.serviceProviderMock.Object, typeof(ILogger));
|
var logger = this.loggerResolver.Resolve(this.serviceProviderMock, typeof(ILogger));
|
||||||
|
|
||||||
logger.Should().BeAssignableTo<ILogger>();
|
logger.Should().BeAssignableTo<ILogger>();
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ public class LoggerResolverTests
|
|||||||
{
|
{
|
||||||
this.SetupIServiceProvider();
|
this.SetupIServiceProvider();
|
||||||
|
|
||||||
var logger = this.loggerResolver.Resolve(this.serviceProviderMock.Object, typeof(ILogger<string>));
|
var logger = this.loggerResolver.Resolve(this.serviceProviderMock, typeof(ILogger<string>));
|
||||||
|
|
||||||
logger.Should().BeAssignableTo<ILogger<string>>();
|
logger.Should().BeAssignableTo<ILogger<string>>();
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@ public class LoggerResolverTests
|
|||||||
|
|
||||||
Action action = new(() =>
|
Action action = new(() =>
|
||||||
{
|
{
|
||||||
this.loggerResolver.Resolve(this.serviceProviderMock.Object, typeof(string));
|
this.loggerResolver.Resolve(this.serviceProviderMock, typeof(string));
|
||||||
});
|
});
|
||||||
|
|
||||||
action.Should().Throw<Exception>();
|
action.Should().Throw<Exception>();
|
||||||
@@ -88,7 +88,7 @@ public class LoggerResolverTests
|
|||||||
|
|
||||||
Action action = new(() =>
|
Action action = new(() =>
|
||||||
{
|
{
|
||||||
this.loggerResolver.Resolve(this.serviceProviderMock.Object, typeof(ILogger<>));
|
this.loggerResolver.Resolve(this.serviceProviderMock, typeof(ILogger<>));
|
||||||
});
|
});
|
||||||
|
|
||||||
action.Should().Throw<Exception>();
|
action.Should().Throw<Exception>();
|
||||||
@@ -96,12 +96,8 @@ public class LoggerResolverTests
|
|||||||
|
|
||||||
private void SetupIServiceProvider()
|
private void SetupIServiceProvider()
|
||||||
{
|
{
|
||||||
this.serviceProviderMock
|
this.serviceProviderMock.GetService<ILoggerFactory>().Returns(this.loggerFactoryMock);
|
||||||
.Setup(u => u.GetService<ILoggerFactory>())
|
|
||||||
.Returns(this.loggerFactoryMock.Object);
|
|
||||||
|
|
||||||
this.loggerFactoryMock
|
this.loggerFactoryMock.CreateLogger(Arg.Any<string>()).Returns(this.loggerMock);
|
||||||
.Setup(u => u.CreateLogger(It.IsAny<string>()))
|
|
||||||
.Returns(this.loggerMock.Object);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -9,13 +9,17 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="FluentAssertions" Version="6.11.0" />
|
<PackageReference Include="FluentAssertions" Version="6.11.0" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
|
||||||
<PackageReference Include="Moq" Version="4.18.4" />
|
|
||||||
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
|
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
|
||||||
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
|
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
|
||||||
<PackageReference Include="coverlet.collector" Version="3.2.0">
|
<PackageReference Include="coverlet.collector" Version="3.2.0">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="NSubstitute" Version="5.0.0" />
|
||||||
|
<PackageReference Include="NSubstitute.Analyzers.CSharp" Version="1.0.16">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
+7
-8
@@ -1,9 +1,9 @@
|
|||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Moq;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Net.WebSockets;
|
using System.Net.WebSockets;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using NSubstitute;
|
||||||
|
|
||||||
namespace SystemExtensions.NetStandard.DependencyInjection.Tests.WebSockets;
|
namespace SystemExtensions.NetStandard.DependencyInjection.Tests.WebSockets;
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ namespace SystemExtensions.NetStandard.DependencyInjection.Tests.WebSockets;
|
|||||||
public sealed class ClientWebSocketResolverTests
|
public sealed class ClientWebSocketResolverTests
|
||||||
{
|
{
|
||||||
private readonly ClientWebSocketResolver webSocketResolver = new();
|
private readonly ClientWebSocketResolver webSocketResolver = new();
|
||||||
private readonly Mock<Slim.IServiceProvider> serviceProviderMock = new();
|
private readonly Slim.IServiceProvider serviceProviderMock = Substitute.For<Slim.IServiceProvider>();
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CanResolve_IHttpClient_ReturnsTrue()
|
public void CanResolve_IHttpClient_ReturnsTrue()
|
||||||
@@ -39,11 +39,10 @@ public sealed class ClientWebSocketResolverTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Resolve_TypedClient_ReturnsIClientWebSocketResolver()
|
public void Resolve_TypedClient_ReturnsIClientWebSocketResolver()
|
||||||
{
|
{
|
||||||
var loggerMock = new Mock<ILogger<string>>();
|
var loggerMock = Substitute.For<ILogger<string>>();
|
||||||
this.serviceProviderMock.Setup(u => u.GetService(typeof(ILogger<string>)))
|
this.serviceProviderMock.GetService(typeof(ILogger<string>)).Returns(loggerMock);
|
||||||
.Returns(loggerMock.Object);
|
|
||||||
|
|
||||||
var client = this.webSocketResolver.Resolve(this.serviceProviderMock.Object, typeof(IClientWebSocket<string>));
|
var client = this.webSocketResolver.Resolve(this.serviceProviderMock, typeof(IClientWebSocket<string>));
|
||||||
|
|
||||||
client.Should().BeAssignableTo<IClientWebSocket<string>>();
|
client.Should().BeAssignableTo<IClientWebSocket<string>>();
|
||||||
}
|
}
|
||||||
@@ -53,7 +52,7 @@ public sealed class ClientWebSocketResolverTests
|
|||||||
{
|
{
|
||||||
Action action = new(() =>
|
Action action = new(() =>
|
||||||
{
|
{
|
||||||
this.webSocketResolver.Resolve(this.serviceProviderMock.Object, typeof(IClientWebSocket<>));
|
this.webSocketResolver.Resolve(this.serviceProviderMock, typeof(IClientWebSocket<>));
|
||||||
});
|
});
|
||||||
|
|
||||||
action.Should().Throw<Exception>();
|
action.Should().Throw<Exception>();
|
||||||
@@ -64,7 +63,7 @@ public sealed class ClientWebSocketResolverTests
|
|||||||
{
|
{
|
||||||
Action action = new(() =>
|
Action action = new(() =>
|
||||||
{
|
{
|
||||||
this.webSocketResolver.Resolve(this.serviceProviderMock.Object, typeof(string));
|
this.webSocketResolver.Resolve(this.serviceProviderMock, typeof(string));
|
||||||
});
|
});
|
||||||
|
|
||||||
action.Should().Throw<Exception>();
|
action.Should().Throw<Exception>();
|
||||||
|
|||||||
Reference in New Issue
Block a user