Skip to content

Commit 0fc1935

Browse files
committed
All unit tests are now passing after all packages have been moved (#125)
1 parent dcf0352 commit 0fc1935

File tree

12 files changed

+98
-82
lines changed

12 files changed

+98
-82
lines changed

src/MyTested.AspNetCore.Mvc.Abstractions/Internal/Application/TestApplication.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,11 @@ public static void TryInitialize()
173173
{
174174
if (!initialiazed && TestConfiguration.AutomaticStartup)
175175
{
176-
startupType = TryFindDefaultStartupType();
176+
var defaultStartupType = TryFindDefaultStartupType();
177177

178-
if (startupType != null)
178+
if (defaultStartupType != null)
179179
{
180+
startupType = defaultStartupType;
180181
Initialize();
181182
}
182183
}

src/MyTested.AspNetCore.Mvc.Controllers/Builders/Controllers/ControllerActionCallBuilder.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ private ActionTestContext<TActionResult> GetAndValidateActionResult<TActionResul
115115
private string GetAndValidateAction(LambdaExpression actionCall)
116116
{
117117
this.BuildControllerIfNotExists();
118+
119+
this.TestContext.MethodCall = actionCall;
118120
this.TestContext.PreMethodInvocationAction?.Invoke();
119121

120122
var methodInfo = ExpressionParser.GetMethodInfo(actionCall);

src/MyTested.AspNetCore.Mvc.ViewFeatures/Builders/ViewComponents/ViewComponentBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Base;
44
using Contracts.ViewComponents;
55
using Internal.TestContexts;
6+
using Microsoft.AspNetCore.Mvc;
67

78
public class ViewComponentBuilder<TViewComponent> : BaseTestBuilder, IAndViewComponentBuilder<TViewComponent>
89
where TViewComponent : class

test/MyTested.AspNetCore.Mvc.Abstractions.Test/ServicesTests.cs

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -334,72 +334,6 @@ public void WithCustomStartupAndAdditionalRoutesShouldWorkCorrectly()
334334
MyApplication.IsUsingDefaultConfiguration();
335335
}
336336

337-
[Fact]
338-
public void WithoutAdditionalServicesTheDefaultActionInvokersShouldBeSet()
339-
{
340-
MyApplication.IsUsingDefaultConfiguration();
341-
342-
var services = TestApplication.Services;
343-
var actionInvokerProviders = services.GetServices<IActionInvokerProvider>();
344-
var modelBindingActionInvokerFactory = services.GetService<IModelBindingActionInvokerFactory>();
345-
346-
Assert.Equal(1, actionInvokerProviders.Count());
347-
Assert.True(actionInvokerProviders.Any(a => a.GetType() == typeof(ControllerActionInvokerProvider)));
348-
Assert.Null(modelBindingActionInvokerFactory);
349-
350-
var routeServices = TestApplication.RoutingServices;
351-
var routeActionInvokerProviders = routeServices.GetServices<IActionInvokerProvider>();
352-
var routeModelBindingActionInvokerFactory = routeServices.GetService<IModelBindingActionInvokerFactory>();
353-
354-
Assert.Equal(2, routeActionInvokerProviders.Count());
355-
356-
var routeActionInvokerProvidersList = routeActionInvokerProviders.OrderByDescending(r => r.Order).ToList();
357-
358-
Assert.True(routeActionInvokerProvidersList[0].GetType() == typeof(ModelBindingActionInvokerProvider));
359-
Assert.True(routeActionInvokerProvidersList[1].GetType() == typeof(ControllerActionInvokerProvider));
360-
Assert.NotNull(routeModelBindingActionInvokerFactory);
361-
Assert.IsAssignableFrom<ModelBindingActionInvokerFactory>(routeModelBindingActionInvokerFactory);
362-
363-
MyApplication.IsUsingDefaultConfiguration();
364-
}
365-
366-
[Fact]
367-
public void WithCustomImplementationsForTheRouteTestingTheCorrectServicesShouldBeSet()
368-
{
369-
MyApplication
370-
.IsUsingDefaultConfiguration()
371-
.WithServices(customServices =>
372-
{
373-
customServices.TryAddEnumerable(
374-
ServiceDescriptor.Transient<IActionInvokerProvider, CustomActionInvokerProvider>());
375-
customServices.TryAddSingleton<IModelBindingActionInvokerFactory, CustomModelBindingActionInvokerFactory>();
376-
});
377-
378-
var services = TestApplication.Services;
379-
var actionInvokerProviders = services.GetServices<IActionInvokerProvider>();
380-
var modelBindingActionInvokerFactory = services.GetService<IModelBindingActionInvokerFactory>();
381-
382-
Assert.Equal(2, actionInvokerProviders.Count());
383-
Assert.True(actionInvokerProviders.Any(a => a.GetType() == typeof(ControllerActionInvokerProvider)));
384-
Assert.True(actionInvokerProviders.Any(a => a.GetType() == typeof(CustomActionInvokerProvider)));
385-
Assert.NotNull(modelBindingActionInvokerFactory);
386-
387-
var routeServices = TestApplication.RoutingServices;
388-
var routeActionInvokerProviders = routeServices.GetServices<IActionInvokerProvider>();
389-
var routeModelBindingActionInvokerFactory = routeServices.GetService<IModelBindingActionInvokerFactory>();
390-
391-
Assert.Equal(2, routeActionInvokerProviders.Count());
392-
393-
var routeActionInvokerProvidersList = routeActionInvokerProviders.OrderByDescending(r => r.Order).ToList();
394-
395-
Assert.True(routeActionInvokerProvidersList[0].GetType() == typeof(CustomActionInvokerProvider));
396-
Assert.True(routeActionInvokerProvidersList[1].GetType() == typeof(ControllerActionInvokerProvider));
397-
Assert.NotNull(routeModelBindingActionInvokerFactory);
398-
Assert.IsAssignableFrom<CustomModelBindingActionInvokerFactory>(routeModelBindingActionInvokerFactory);
399-
400-
MyApplication.IsUsingDefaultConfiguration();
401-
}
402-
403337
[Fact]
404338
public void WithoutHttpContextFactoryTheDefaultMockedHttpContextShouldBeProvided()
405339
{
File renamed without changes.

test/MyTested.AspNetCore.Mvc.Core.Test/project.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
{
22
"buildOptions": {
33
"warningsAsErrors": true,
4-
"keyFile": "../../tools/Key.snk",
5-
"copyToOutput": {
6-
"include": [
7-
"testconfig.json"
8-
]
9-
}
4+
"keyFile": "../../tools/Key.snk"
105
},
116

127
"testRunner": "xunit",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
using Setups.Routing;
1111
using Xunit;
1212

13-
public class InternalRouteResolverTests
13+
public class MvcRouteResolverTests
1414
{
1515
[Fact]
1616
public void ResolveShouldResolveCorrectlyWithPartialJsonContentBody()

test/MyTested.AspNetCore.Mvc.DependencyInjection.Test/BuildersTests/ControllersTests/ControllerBuilderTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public void WithResolvedDependencyForShouldThrowExceptionWhenSameDependenciesAre
301301
.With<IInjectedService>(new InjectedService())
302302
.With<IAnotherInjectedService>(new AnotherInjectedService()));
303303
},
304-
"Dependency AnotherInjectedService is already registered for FullPocoController controller.");
304+
"Dependency AnotherInjectedService is already registered.");
305305
}
306306

307307
[Fact]
@@ -340,7 +340,7 @@ public void WithResolvedDependencyForShouldThrowExceptionWhenSameDependenciesAre
340340
.With<IInjectedService>(new InjectedService())
341341
.With<IAnotherInjectedService>(new AnotherInjectedService()));
342342
},
343-
"Dependency AnotherInjectedService is already registered for MvcController controller.");
343+
"Dependency AnotherInjectedService is already registered.");
344344
}
345345

346346
[Fact]
@@ -359,7 +359,7 @@ public void WithResolvedDependencyForShouldThrowExceptionWhenNoConstructorExists
359359
.ShouldReturn()
360360
.Ok();
361361
},
362-
"NoParameterlessConstructorController could not be instantiated because it contains no constructor taking RequestModel, AnotherInjectedService, ResponseModel as parameters.");
362+
"NoParameterlessConstructorController could not be instantiated because it contains no constructor taking RequestModel, ResponseModel, AnotherInjectedService as parameters.");
363363
}
364364

365365
[Fact]
@@ -378,7 +378,7 @@ public void WithResolvedDependencyForShouldThrowExceptionWhenNoConstructorExists
378378
.ShouldReturn()
379379
.Ok();
380380
},
381-
"NoParameterlessConstructorController could not be instantiated because it contains no constructor taking RequestModel, AnotherInjectedService, ResponseModel as parameters.");
381+
"NoParameterlessConstructorController could not be instantiated because it contains no constructor taking RequestModel, ResponseModel, AnotherInjectedService as parameters.");
382382
}
383383

384384
[Fact]
@@ -458,7 +458,7 @@ public void WithServiceSetupForShouldThrowExceptionWithNoScopedService()
458458
.Ok()
459459
.WithModel("TestValue");
460460
},
461-
"The 'WithServiceSetupFor' method can be used only for services with scoped lifetime.");
461+
"The 'WithSetupFor' method can be used only for services with scoped lifetime.");
462462

463463
MyApplication.IsUsingDefaultConfiguration();
464464
}

test/MyTested.AspNetCore.Mvc.Core.Test/TestStartup.cs renamed to test/MyTested.AspNetCore.Mvc.Http.Test/TestStartup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace MyTested.AspNetCore.Mvc.Test
1+
namespace MyTested.AspNetCore.Mvc.Http.Test
22
{
33
using Microsoft.AspNetCore.Builder;
44
using Microsoft.Extensions.DependencyInjection;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ public void ResolveShouldReturnProperErrorWhenTwoActionsAreMatched()
311311

312312
Assert.False(routeInfo.IsResolved);
313313
Assert.Equal(
314-
"exception was thrown when trying to select an action: 'Multiple actions matched. The following actions matched route data and had all constraints satisfied:\r\n\r\nMyTested.AspNetCore.Mvc.Test.Setups.Routing.NormalController.ActionWithOverloads (MyTested.AspNetCore.Mvc.Test)\r\nMyTested.AspNetCore.Mvc.Test.Setups.Routing.NormalController.ActionWithOverloads (MyTested.AspNetCore.Mvc.Test)'",
314+
"exception was thrown when trying to select an action: 'Multiple actions matched. The following actions matched route data and had all constraints satisfied:\r\n\r\nMyTested.AspNetCore.Mvc.Test.Setups.Routing.NormalController.ActionWithOverloads (MyTested.AspNetCore.Mvc.Test.Setups)\r\nMyTested.AspNetCore.Mvc.Test.Setups.Routing.NormalController.ActionWithOverloads (MyTested.AspNetCore.Mvc.Test.Setups)'",
315315
routeInfo.UnresolvedError);
316316
Assert.Null(routeInfo.ControllerType);
317317
Assert.Null(routeInfo.ControllerName);

0 commit comments

Comments
 (0)