Reputation: 1
System.InvalidOperationException
HResult=0x80131509
Message=Unable to resolve service for type 'Microsoft.AspNetCore.DataProtection.IDataProtectionProvider' while attempting to activate 'Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage.ProtectedSessionStorage'.
Source=Microsoft.Extensions.DependencyInjection
StackTrace:
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, Type serviceType, Type implementationType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain, Int32 slot)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(Type serviceType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(Type serviceType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType)
at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func
2 valueFactory)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Bunit.TestServiceProvider.GetServiceInternal(Type serviceType)
at Bunit.TestServiceProvider.GetService(Type serviceType)
at Microsoft.AspNetCore.Components.ComponentFactory.<>c__DisplayClass7_0.g__Initialize|1(IServiceProvider serviceProvider, IComponent component)
at Microsoft.AspNetCore.Components.ComponentFactory.PerformPropertyInjection(IServiceProvider serviceProvider, IComponent instance)
at Microsoft.AspNetCore.Components.ComponentFactory.InstantiateComponent(IServiceProvider serviceProvider, Type componentType)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.InstantiateChildComponentOnFrame(RenderTreeFrame& frame, Int32 parentComponentId)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewComponentFrame(DiffContext& diffContext, Int32 frameIndex)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewSubtree(DiffContext& diffContext, Int32 frameIndex)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& diffContext, Int32 newFrameIndex)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer renderer, RenderBatchBuilder batchBuilder, Int32 componentId, ArrayRange1 oldTree, ArrayRange
1 newTree)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()
--- End of stack trace from previous location ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Bunit.Rendering.TestRenderer.AssertNoUnhandledExceptions()
at Bunit.Rendering.TestRenderer.Render[TResult](RenderFragment renderFragment, Func`2 activator)
at Bunit.Rendering.TestRenderer.RenderFragment(RenderFragment renderFragment)
at Bunit.Extensions.TestContextBaseRenderExtensions.RenderInsideRenderTree(TestContextBase testContext, RenderFragment renderFragment)
at Bunit.Extensions.TestContextBaseRenderExtensions.RenderInsideRenderTree[TComponent](TestContextBase testContext, RenderFragment renderFragment)
at Bunit.TestContext.Render[TComponent](RenderFragment renderFragment)
at Bunit.TestContext.RenderComponent[TComponent](ComponentParameter[] parameters)
at ConfigWebappUnitTesting.AssetTableTest..ctor() in D:\Gleason Projects\ConfigurationWebAppBlazor\ConfigWebappUnitTesting\AssetTableTest.cs:line 19
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
This exception was originally thrown at this call stack: [External Code] ConfigWebappUnitTesting.AssetTableTest.AssetTableTest() in AssetTableTest.cs
AssetTable.cs with constructor
public AssetTableTest()
{
// Act
var session = Context.Services.GetService<FakeSignOutSessionStateManager>();
var page = Context.Services.GetService<FakeNavigationManager>();
page.NavigateTo(page.BaseUri.Remove(page.BaseUri.Length - 1, 1) + Configuration["Session"]);
cut = Context.RenderComponent<Assets>(); //**Got My error at this point**
//cut = Context.RenderComponent<Assets>(x =>
//x.Add(p => p.Session, Configuration["Session"])
//);
//WaitForAssertion
cut.WaitForAssertion(() => { }, TimeSpan.FromSeconds(5));
cut.WaitForState(() => (cut.Markup.Contains("tbody")), TimeSpan.FromSeconds(10));
cut.WaitForState(() => (!cut.Find("tbody").TextContent.Contains("Loading")), TimeSpan.FromSeconds(50));
tableBody = cut.Find("tbody");
}
Upvotes: 0
Views: 534
Reputation: 7236
That exception is saying that you are missing a valid implementation for the IDataProtectionProvider
service interface. In ASP.NET apps, this is typically done in Program.cs
or Startup.cs
(depending on the project and version of .NET). The Microsoft.AspNetCore.DataProtection
package provides an extension method for ServiceCollection
to accomplish this.
For you, it might look something like:
// Assuming Context.Services is a ServiceCollection:
Context.Services.AddDataProtection();
Upvotes: 0