reactiveui/ReactiveUI — pull request #172 by ArturPhilibin (2013-02-08 01:37:29+00:00)
Title: False positives in RealUnitTestDetector

Hi, I've run into an issue using ReactiveUI in a WPF project that is hosted within an Office application. Some methods, that update the UI were being called from background threads causing the usual InvalidOperationExceptions.

Example code (running in a background thread):
```C#
MessageBus.Listen()
.ObserveOn(RxApp.DeferredScheduler)
.Subscribe(UpdateCustomerList);
```
UpdateCustomerList would end up running on the same background thread that had created the subscription. Turned out ```RxApp.DeferredScheduler``` in the Office host was returning the Immediate scheduler as it thinks the Office host is a test runner / designer. The offending code is:
```csharp
var entry = Assembly.GetEntryAssembly();
var exeName = (entry != null ? entry.Location.ToUpperInvariant() : "");
if (designEnvironments.Any(x => x.Contains(exeName)))
{
return true;
}
```

```Assembly.GetEntryAssembly()``` returns null in the Office host, which causes ```designEnvironments.Any(x => x.Contains(exeName))``` to always match, returning true.

I tried fixing it by returning false if ```entry``` was null, but that caused many of ReactiveUI's unit tests to fail. Debugged a test and broke on the line ```Assembly.GetEntryAssembly()``` and realised, it returns null under XUnit also. So it looks like XUnit is detected because there's no EntryAssembly rather than a match against the string array containing the XUnit assembly name.

I'm going to try against another test runner or two to see if they have the same behaviour.
I'm not that familiar with how test runners execute tests, maybe in the absence of an EntryAssembly there might some clues in the AppDomain or ProcessName.