public async Task TestCacheWithOption() { var code = @"class Test { void Method() { } }"; using (var workspace = await TestWorkspace.CreateCSharpAsync(code)) { var options = new TestOptionSet().WithChangedOption(RemoteHostOptions.RemoteHostTest, true); var solution = workspace.CurrentSolution; var service = await GetSolutionServiceAsync(solution); var solutionChecksum = await solution.State.GetChecksumAsync(CancellationToken.None); var first = await service.GetSolutionAsync(solutionChecksum, options, CancellationToken.None); var second = await service.GetSolutionAsync(solutionChecksum, options, CancellationToken.None); // new solutions if option is involved for isolation Assert.False(object.ReferenceEquals(first, second)); // but semantic of both solution should be same Assert.Equal(await first.State.GetChecksumAsync(CancellationToken.None), await second.State.GetChecksumAsync(CancellationToken.None)); // also any sub nodes such as projects should be same Assert.True(object.ReferenceEquals(first.Projects.First().State, second.Projects.First().State)); Assert.True(first.Workspace is TemporaryWorkspace); } }
public async Task TestCreationWithOption() { var code = @"class Test { void Method() { } }"; using (var workspace = await TestWorkspace.CreateCSharpAsync(code)) { var options = new TestOptionSet().WithChangedOption(RemoteHostOptions.RemoteHostTest, true); var solution = workspace.CurrentSolution; var service = await GetSolutionServiceAsync(solution); var solutionChecksum = await solution.State.GetChecksumAsync(CancellationToken.None); var synched = await service.GetSolutionAsync(solutionChecksum, options, CancellationToken.None); Assert.Equal(solutionChecksum, await synched.State.GetChecksumAsync(CancellationToken.None)); Assert.Empty(options.GetChangedOptions(synched.Workspace.Options)); Assert.True(options.GetOption(RemoteHostOptions.RemoteHostTest)); Assert.True(synched.Workspace.Options.GetOption(RemoteHostOptions.RemoteHostTest)); } }
public async Task TestOptionIsolation() { var code = @"class Test { void Method() { } }"; using (var workspace = await TestWorkspace.CreateCSharpAsync(code)) { var solution = workspace.CurrentSolution; var service = await GetSolutionServiceAsync(solution); var solutionChecksum = await solution.State.GetChecksumAsync(CancellationToken.None); var options = new TestOptionSet().WithChangedOption(RemoteHostOptions.RemoteHostTest, true); var first = await service.GetSolutionAsync(solutionChecksum, options, CancellationToken.None); var second = await service.GetSolutionAsync(solutionChecksum, options.WithChangedOption(RemoteHostOptions.RemoteHostTest, false), CancellationToken.None); Assert.Equal(await first.State.GetChecksumAsync(CancellationToken.None), await second.State.GetChecksumAsync(CancellationToken.None)); // option change shouldn't affect other workspace Assert.True(first.Workspace.Options.GetOption(RemoteHostOptions.RemoteHostTest)); Assert.False(second.Workspace.Options.GetOption(RemoteHostOptions.RemoteHostTest)); } }