-
Notifications
You must be signed in to change notification settings - Fork 426
Expand file tree
/
Copy pathProjectLoadTestEventEmitter.cs
More file actions
47 lines (42 loc) · 1.54 KB
/
ProjectLoadTestEventEmitter.cs
File metadata and controls
47 lines (42 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using Microsoft.Extensions.Logging;
using OmniSharp.Eventing;
using OmniSharp.Mef;
using OmniSharp.Models.Events;
using OmniSharp.MSBuild.Notification;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Composition.Hosting.Core;
using System.Threading;
namespace OmniSharp.MSBuild.Tests
{
public partial class ProjectLoadListenerTests
{
public class ProjectLoadTestEventEmitter : IEventEmitter
{
public ImmutableArray<ProjectConfigurationMessage> ReceivedMessages { get; private set; } = ImmutableArray<ProjectConfigurationMessage>.Empty;
private readonly ManualResetEvent _messageEvent = new ManualResetEvent(false);
public void WaitForProjectUpdate()
{
_messageEvent.Reset();
_messageEvent.WaitOne(TimeSpan.FromSeconds(5));
}
public ExportDescriptorProvider[] AsExportDescriptionProvider(ILoggerFactory loggerFactory)
{
var listener = new ProjectLoadListener(loggerFactory, this);
return new ExportDescriptorProvider[]
{
MefValueProvider.From<IMSBuildEventSink>(listener)
};
}
public void Emit(string kind, object args)
{
if(args is ProjectConfigurationMessage message)
{
ReceivedMessages = ReceivedMessages.Add(message);
_messageEvent.Set();
}
}
}
}
}