// 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; using System.Linq; namespace Microsoft.CodeAnalysis.Host { public class TestServices : HostServices { private readonly IEnumerable _workspaceServices; private readonly IEnumerable _razorLanguageServices; private TestServices(IEnumerable workspaceServices, IEnumerable razorLanguageServices) { if (workspaceServices == null) { throw new ArgumentNullException(nameof(workspaceServices)); } if (razorLanguageServices == null) { throw new ArgumentNullException(nameof(razorLanguageServices)); } _workspaceServices = workspaceServices; _razorLanguageServices = razorLanguageServices; } protected override HostWorkspaceServices CreateWorkspaceServices(Workspace workspace) { if (workspace == null) { throw new ArgumentNullException(nameof(workspace)); } return new TestWorkspaceServices(this, _workspaceServices, _razorLanguageServices, workspace); } public static HostServices Create(IEnumerable razorLanguageServices) => Create(Enumerable.Empty(), razorLanguageServices); public static HostServices Create(IEnumerable workspaceServices, IEnumerable razorLanguageServices) => new TestServices(workspaceServices, razorLanguageServices); } }