public async Task VerifyDesignTimeInputsProcessed(string projectState, string[] designTimeInputs, string[] sharedDesignTimeInputs) { using DesignTimeInputsDataSource dataSource = CreateDesignTimeInputsDataSource(out ProjectValueDataSource <IProjectSubscriptionUpdate> sourceItemsRuleSource); const string defaultProjectConfig = @"""ProjectConfiguration"": { ""Name"": ""Debug|AnyCPU"", ""Dimensions"": { ""Configuration"": ""Debug"", ""Platform"": ""AnyCPU"" } }"; // Create a block to receive the results of the block under test DesignTimeInputs inputs = null; var receiver = DataflowBlockSlim.CreateActionBlock <IProjectVersionedValue <DesignTimeInputs> >(val => { inputs = val.Value; }); dataSource.SourceBlock.LinkTo(receiver, DataflowOption.PropagateCompletion); // Construct our input value, including a default project config var configUpdate = IProjectSubscriptionUpdateFactory.FromJson("{ " + projectState + "," + defaultProjectConfig + " }"); // Send our input, and wait for our receiver to complete await sourceItemsRuleSource.SendAndCompleteAsync(configUpdate, receiver); // Assert Assert.NotNull(inputs); Assert.Equal(designTimeInputs, inputs.Inputs); Assert.Equal(sharedDesignTimeInputs, inputs.SharedInputs); }
private static DesignTimeInputsDataSource CreateDesignTimeInputsDataSource(out ProjectValueDataSource <IProjectSubscriptionUpdate> sourceItemsRuleSource) { var unconfiguredProjectServices = UnconfiguredProjectServicesFactory.Create( projectService: IProjectServiceFactory.Create( services: ProjectServicesFactory.Create( threadingService: IProjectThreadingServiceFactory.Create(), projectLockService: IProjectLockServiceFactory.Create()))); var unconfiguredProject = UnconfiguredProjectFactory.Create(unconfiguredProjectServices: unconfiguredProjectServices); sourceItemsRuleSource = new ProjectValueDataSource <IProjectSubscriptionUpdate>(unconfiguredProjectServices); var projectSubscriptionService = IActiveConfiguredProjectSubscriptionServiceFactory.Create(sourceItemsRuleSource: sourceItemsRuleSource); var dataSource = new DesignTimeInputsDataSource(unconfiguredProject, unconfiguredProjectServices, projectSubscriptionService); return(dataSource); }