Skip to content

Commit 9e7498b

Browse files
authored
Remove obsolete methods (#64)
1 parent f1b76bb commit 9e7498b

File tree

9 files changed

+12
-131
lines changed

9 files changed

+12
-131
lines changed

AutofacContrib.NSubstitute.Tests/ExampleFixture.cs

-20
Original file line numberDiff line numberDiff line change
@@ -166,26 +166,6 @@ public void Example_test_with_concrete_object_provided()
166166
Assert.That(result, Is.EqualTo(val1 + val2));
167167
}
168168

169-
[Test]
170-
[Obsolete]
171-
public void Example_test_with_substitute_for_concrete_resolved_from_autofac()
172-
{
173-
const int val1 = 2;
174-
const int val2 = 3;
175-
const int val3 = 4;
176-
177-
using var mock = AutoSubstitute.Configure()
178-
.ResolveAndSubstituteFor<ConcreteClassWithDependency>(new TypedParameter(typeof(int), val1))
179-
.Build();
180-
181-
mock.Resolve<IDependency2>().SomeOtherMethod().Returns(val2);
182-
mock.Resolve<IDependency1>().SomeMethod(val1).Returns(val3);
183-
184-
var result = mock.Resolve<MyClassWithConcreteDependencyThatHasDependencies>().AMethod();
185-
186-
Assert.That(result, Is.EqualTo(val2 * val3 * 2));
187-
}
188-
189169
[Test]
190170
public void Example_provide_service()
191171
{

AutofacContrib.NSubstitute.Tests/SubstituteForFixture.cs

-19
Original file line numberDiff line numberDiff line change
@@ -60,25 +60,6 @@ public ConcreteTest(Concrete1 c1)
6060
public Concrete3 Get() => _c2.Get();
6161
}
6262

63-
[Test]
64-
[Obsolete]
65-
public void Example_test_with_substitute_for_concrete_obsolete()
66-
{
67-
const int val1 = 3;
68-
const int val2 = 2;
69-
const int val3 = 10;
70-
71-
using var utoSubstitute = AutoSubstitute.Configure()
72-
.SubstituteFor<ConcreteClass>(val2).Configure(c => c.Add(Arg.Any<int>()).Returns(val3))
73-
.Build();
74-
75-
utoSubstitute.Resolve<IDependency2>().SomeOtherMethod().Returns(val1);
76-
77-
var result = utoSubstitute.Resolve<MyClassWithConcreteDependency>().AMethod();
78-
79-
Assert.That(result, Is.EqualTo(val3));
80-
}
81-
8263
[Test]
8364
public void Example_test_with_substitute_for_concrete()
8465
{

AutofacContrib.NSubstitute.Tests/TypesToSkipForMockingFixture.cs

-14
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,6 @@ public void WithoutOption()
2424
Assert.AreEqual(impl2.Value, items[1]);
2525
}
2626

27-
[Test]
28-
[Obsolete]
29-
public void ManuallyAddTypeToSkip()
30-
{
31-
var mock = AutoSubstitute.Configure()
32-
.ConfigureOptions(options =>
33-
{
34-
options.TypesToSkipForMocking.Add(typeof(IDependency));
35-
})
36-
.Build();
37-
38-
Assert.Throws<ComponentNotRegisteredException>(() => mock.Resolve<IDependency>());
39-
}
40-
4127
[Test]
4228
public void ManuallyCheckTypeToSkip()
4329
{

AutofacContrib.NSubstitute/AutoMock.cs

-14
This file was deleted.

AutofacContrib.NSubstitute/AutoSubstituteBuilder.cs

-19
Original file line numberDiff line numberDiff line change
@@ -231,25 +231,6 @@ public SubstituteForBuilder<TService> SubstituteForPartsOf<TService>(params obje
231231
where TService : class
232232
=> CreateSubstituteForBuilder(() => Substitute.ForPartsOf<TService>(parameters), false);
233233

234-
/// <summary>
235-
/// Registers to the container and returns a substitute for a given concrete class using autofac to resolve the constructor parameters.
236-
/// This is used for concrete classes where NSubstitutes won't be created by default by the container when using Resolve.
237-
/// For advanced uses consider using directly <see cref="Substitute.For{TService}"/> and then calling <see cref="Provide{TService}(TService)"/> so that type is used on dependencies for other Resolved types.
238-
/// </summary>
239-
/// <typeparam name="TService">The type to register and return a substitute for</typeparam>
240-
/// <param name="parameters">Any constructor parameters that Autofac can't resolve automatically</param>
241-
/// <returns>The current <see cref="AutoSubstituteBuilder"/>.</returns>
242-
[Obsolete("Use a Provide method instead")]
243-
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
244-
public AutoSubstituteBuilder ResolveAndSubstituteFor<TService>(params Parameter[] parameters) where TService : class
245-
{
246-
_builder.RegisterType<TService>()
247-
.WithParameters(parameters)
248-
.InstancePerLifetimeScope();
249-
250-
return this;
251-
}
252-
253234
private SubstituteForBuilder<TService> CreateSubstituteForBuilder<TService>(Func<TService> factory, bool isSubstituteFor)
254235
where TService : class
255236
{

AutofacContrib.NSubstitute/AutoSubstituteOptions.cs

-14
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,6 @@ public AutoSubstituteOptions()
3434
/// </summary>
3535
public ICollection<Action<IRegistrationBuilder<object, ConcreteReflectionActivatorData, SingleRegistrationStyle>>> ConfigureAnyConcreteTypeRegistration { get; } = new List<Action<IRegistrationBuilder<object, ConcreteReflectionActivatorData, SingleRegistrationStyle>>>();
3636

37-
/// <summary>
38-
/// Gets a collection of types that will be skipped during generation of NSubstitute mocks.
39-
/// </summary>
40-
[Obsolete("Use a custom MockHandler instead")]
41-
[EditorBrowsable(EditorBrowsableState.Never)]
42-
public ICollection<Type> TypesToSkipForMocking => _typesToSkipForMocking;
43-
44-
/// <summary>
45-
/// Gets or sets a flag indicating whether mocks should be excluded for provided values. This will automatically add values given to Provide methods to <see cref="TypesToSkipForMocking"/>.
46-
/// </summary>
47-
[Obsolete]
48-
[EditorBrowsable(EditorBrowsableState.Never)]
49-
public bool AutomaticallySkipMocksForProvidedValues { get; set; }
50-
5137
/// <summary>
5238
/// Gets or sets a factory to create an <see cref="IContainer"/> given a <see cref="ContainerBuilder"/>. This defaults to simply calling <see cref="ContainerBuilder.Build()"/>.
5339
/// </summary>

AutofacContrib.NSubstitute/MockHandlers/MockHandler.cs

+1-21
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using Autofac;
2-
using AutofacContrib.NSubstitute.MockHandlers;
3-
using NSubstitute.Core;
4-
using System;
5-
using System.ComponentModel;
1+
using AutofacContrib.NSubstitute.MockHandlers;
62

73
namespace AutofacContrib.NSubstitute
84
{
@@ -15,28 +11,12 @@ protected MockHandler()
1511
{
1612
}
1713

18-
/// <summary>
19-
/// Provides a way to manage mocks after creation but before returned from the container registry.
20-
/// </summary>
21-
/// <param name="instance">The mock instance.</param>
22-
/// <param name="type">The type the mock was created for.</param>
23-
/// <param name="context">The current component context.</param>
24-
/// <param name="substitutionContext">The current substitution context.</param>
25-
[Obsolete]
26-
[EditorBrowsable(EditorBrowsableState.Never)]
27-
protected virtual void OnMockCreated(object instance, Type type, IComponentContext context, ISubstitutionContext substitutionContext)
28-
{
29-
}
30-
3114
/// <summary>
3215
/// Provides a way to manage mocks after creation but before returned from the container registry.
3316
/// </summary>
3417
/// <param name="context">Created context.</param>
3518
protected internal virtual void OnMockCreated(MockCreatedContext context)
3619
{
37-
#pragma warning disable CS0612 // Type or member is obsolete
38-
OnMockCreated(context.Instance, context.Type, context.Context, context.SubstitutionContext);
39-
#pragma warning restore CS0612 // Type or member is obsolete
4020
}
4121

4222
/// <summary>

AutofacContrib.NSubstitute/SubstituteForBuilder.cs

-10
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,6 @@ internal SubstituteForBuilder(
3232

3333
internal ISubstitutionContext Context => SubstitutionContext.Current;
3434

35-
/// <summary>
36-
/// Allows for configuration of the service.
37-
/// </summary>
38-
/// <param name="action">The delegate to configure the service.</param>
39-
/// <returns>The original <see cref="AutoSubstituteBuilder"/>.</returns>
40-
[Obsolete("Use ConfigureSubstitute instead")]
41-
[EditorBrowsable(EditorBrowsableState.Never)]
42-
public AutoSubstituteBuilder Configure(Action<TService> action)
43-
=> ConfigureSubstitute((s, _) => action(s));
44-
4535
/// <summary>
4636
/// Allows for configuration of the service.
4737
/// </summary>

BREAKING_CHANGES.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
AutofacContrib.NSubstitute (AutoSubstitute) Breaking Changes
22
============================================================
33

4+
Version 7.0.0
5+
-------------
6+
7+
Removed obsolete methods that were in the project.
8+
9+
### Reason
10+
They built up some unnecessary cruft and had easy replacements
11+
12+
### Workaround
13+
Update to the latest 6.x package and review obsolete messages.
14+
415
Version 6.0.0
516
-------------
617

0 commit comments

Comments
 (0)