// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; namespace Microsoft.AspNetCore.Blazor.Test.Helpers { public class TestServiceProvider : IServiceProvider { private readonly Dictionary> _factories = new Dictionary>(); public object GetService(Type serviceType) => _factories.TryGetValue(serviceType, out var factory) ? factory() : null; internal void AddService(T value) => _factories.Add(typeof(T), () => value); } }