Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/ReactiveUI.Tests/ActivationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.Linq;
using System.Reactive;
using System.Reactive.Concurrency;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Reactive.Subjects;
Expand Down Expand Up @@ -280,7 +281,7 @@ public class ViewModelActivatorTests
public void ActivatingTicksActivatedObservable()
{
var viewModelActivator = new ViewModelActivator();
var activated = viewModelActivator.Activated.CreateCollection();
var activated = viewModelActivator.Activated.CreateCollection(scheduler: ImmediateScheduler.Instance);

viewModelActivator.Activate();

Expand All @@ -291,7 +292,7 @@ public void ActivatingTicksActivatedObservable()
public void DeactivatingIgnoringRefCountTicksDeactivatedObservable()
{
var viewModelActivator = new ViewModelActivator();
var deactivated = viewModelActivator.Deactivated.CreateCollection();
var deactivated = viewModelActivator.Deactivated.CreateCollection(scheduler: ImmediateScheduler.Instance);

viewModelActivator.Deactivate(true);

Expand All @@ -302,7 +303,7 @@ public void DeactivatingIgnoringRefCountTicksDeactivatedObservable()
public void DeactivatingCountDoesntTickDeactivatedObservable()
{
var viewModelActivator = new ViewModelActivator();
var deactivated = viewModelActivator.Deactivated.CreateCollection();
var deactivated = viewModelActivator.Deactivated.CreateCollection(scheduler: ImmediateScheduler.Instance);

viewModelActivator.Deactivate(false);

Expand All @@ -313,7 +314,7 @@ public void DeactivatingCountDoesntTickDeactivatedObservable()
public void DeactivatingFollowingActivatingTicksDeactivatedObservable()
{
var viewModelActivator = new ViewModelActivator();
var deactivated = viewModelActivator.Deactivated.CreateCollection();
var deactivated = viewModelActivator.Deactivated.CreateCollection(scheduler: ImmediateScheduler.Instance);

viewModelActivator.Activate();
viewModelActivator.Deactivate(false);
Expand Down
6 changes: 1 addition & 5 deletions src/ReactiveUI.Tests/AutoPersistHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive;
using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reactive.Subjects;
using Microsoft.Reactive.Testing;
using ReactiveUI.Testing;
using Xunit;
using System.Reactive.Subjects;

namespace ReactiveUI.Tests
{
Expand Down
25 changes: 12 additions & 13 deletions src/ReactiveUI.Tests/CommandBindingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object IViewFor.ViewModel {

public class CreatesCommandBindingTests
{
[Fact]
[WpfFact]
public void CommandBinderBindsToButton()
{
var fixture = new CreatesCommandBindingViaCommandParameter();
Expand Down Expand Up @@ -87,15 +87,15 @@ public void EventBinderBindsToExplicitEvent()
Assert.False(wasCalled);
}

[Fact]
[WpfFact]
public void EventBinderBindsToExplicitInheritedEvent()
{
var fixture = new FakeView();
fixture.BindCommand(fixture.ViewModel, x => x.Cmd, x => x.TheTextBox, "MouseDown");
}

#if !SILVERLIGHT
[Fact]
[WpfFact]
public void EventBinderBindsToImplicitEvent()
{
var input = new Button();
Expand Down Expand Up @@ -191,7 +191,7 @@ public CommandBindView()

public class CommandBindingImplementationTests
{
[Fact]
[WpfFact]
public void CommandBindByNameWireup()
{
var vm = new CommandBindViewModel();
Expand All @@ -210,7 +210,7 @@ public void CommandBindByNameWireup()
Assert.Null(view.Command1.Command);
}

[Fact]
[WpfFact]
public void CommandBindNestedCommandWireup()
{
var vm = new CommandBindViewModel()
Expand All @@ -225,7 +225,7 @@ public void CommandBindNestedCommandWireup()
Assert.Equal(vm.NestedViewModel.NestedCommand, view.Command1.Command);
}

[Fact]
[WpfFact]
public void CommandBindSetsInitialEnabledState_True()
{
var vm = new CommandBindViewModel();
Expand All @@ -240,7 +240,7 @@ public void CommandBindSetsInitialEnabledState_True()
Assert.True(view.Command1.IsEnabled);
}

[Fact]
[WpfFact]
public void CommandBindSetsDisablesCommandWhenCanExecuteChanged()
{
var vm = new CommandBindViewModel();
Expand All @@ -259,7 +259,7 @@ public void CommandBindSetsDisablesCommandWhenCanExecuteChanged()
Assert.False(view.Command1.IsEnabled);
}

[Fact]
[WpfFact]
public void CommandBindSetsInitialEnabledState_False()
{
var vm = new CommandBindViewModel();
Expand All @@ -274,8 +274,7 @@ public void CommandBindSetsInitialEnabledState_False()
Assert.False(view.Command1.IsEnabled);
}


[Fact]
[WpfFact]
public void CommandBindRaisesCanExecuteChangedOnBind()
{
var vm = new CommandBindViewModel();
Expand All @@ -299,7 +298,7 @@ public void CommandBindRaisesCanExecuteChangedOnBind()
}

#if !SILVERLIGHT
[Fact]
[WpfFact]
public void CommandBindToExplicitEventWireup()
{
var vm = new CommandBindViewModel();
Expand All @@ -319,7 +318,7 @@ public void CommandBindToExplicitEventWireup()
}
#endif

[Fact]
[WpfFact]
public void CommandBindWithParameterExpression()
{
var vm = new CommandBindViewModel();
Expand All @@ -340,7 +339,7 @@ public void CommandBindWithParameterExpression()
Assert.Equal(13, received);
}

[Fact]
[WpfFact]
public void CommandBindWithParameterObservable()
{
var vm = new CommandBindViewModel();
Expand Down
12 changes: 6 additions & 6 deletions src/ReactiveUI.Tests/DependencyResolverTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public DependencyResolverTests()
resolver.RegisterViewsForViewModels(GetType().Assembly);
}

[Fact]
[WpfFact]
public void RegisterViewsForViewModelShouldRegisterAllViews()
{
using (resolver.WithResolver()) {
Expand All @@ -90,23 +90,23 @@ public void RegisterViewsForViewModelShouldRegisterAllViews()
}
}

[Fact]
[WpfFact]
public void RegisterViewsForViewModelShouldIncludeContracts()
{
using (resolver.WithResolver()) {
Assert.Single(resolver.GetServices(typeof(IViewFor<ExampleViewModel>), "contract"));
}
}

[Fact]
[WpfFact]
public void NonContractRegistrationsShouldResolveCorrectly()
{
using (resolver.WithResolver()) {
Assert.IsType<AnotherView>(resolver.GetService<IViewFor<AnotherViewModel>>());
}
}

[Fact]
[WpfFact]
public void ContractRegistrationsShouldResolveCorrectly()
{
using (resolver.WithResolver()) {
Expand All @@ -122,7 +122,7 @@ public void SingleInstanceViewsShouldOnlyBeInstantiatedWhenRequested()
}
}

[Fact]
[WpfFact]
public void SingleInstanceViewsShouldOnlyBeInstantiatedOnce()
{
using (resolver.WithResolver()) {
Expand All @@ -138,7 +138,7 @@ public void SingleInstanceViewsShouldOnlyBeInstantiatedOnce()
}
}

[Fact]
[WpfFact]
public void SingleInstanceViewsWithContractShouldResolveCorrectly()
{
using (resolver.WithResolver()) {
Expand Down
41 changes: 18 additions & 23 deletions src/ReactiveUI.Tests/MessageBusTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@
// The .NET Foundation licenses this file to you under the MS-PL license.
// See the LICENSE file in the project root for more information.

using Microsoft.Reactive.Testing;
using ReactiveUI.Testing;
using System;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using Xunit;
using System;
using System.Linq;
using System.Collections.Generic;
using ReactiveUI;
using System.IO;
using System.Text;
using ReactiveUI.Testing;
using ReactiveUI.Tests;
using System.Threading;

using Microsoft.Reactive.Testing;
using System.Threading.Tasks;
using Microsoft.Reactive.Testing;
using ReactiveUI.Testing;
using Xunit;

namespace ReactiveUI.Tests
{
Expand All @@ -25,17 +21,17 @@ public class MessageBusTest
[Fact]
public void MessageBusSmokeTest()
{
var input = new[] {1, 2, 3, 4};
var input = new[] { 1, 2, 3, 4 };

var result = (new TestScheduler()).With(sched => {
var source = new Subject<int>();
var fixture = new MessageBus();

fixture.RegisterMessageSource(source, "Test");
Assert.False(fixture.IsRegistered(typeof (int)));
Assert.False(fixture.IsRegistered(typeof (int), "Foo"));
Assert.False(fixture.IsRegistered(typeof(int)));
Assert.False(fixture.IsRegistered(typeof(int), "Foo"));

var output = fixture.Listen<int>("Test").CreateCollection();
var output = fixture.Listen<int>("Test").CreateCollection(scheduler: ImmediateScheduler.Instance);

input.Run(source.OnNext);

Expand All @@ -46,20 +42,19 @@ public void MessageBusSmokeTest()
input.AssertAreEqual(result);
}


[Fact]
public void ExplicitSendMessageShouldWorkEvenAfterRegisteringSource()
public void ExplicitSendMessageShouldWorkEvenAfterRegisteringSource()
{
var fixture = new MessageBus();
fixture.RegisterMessageSource(Observable<int>.Never);

bool messageReceived = false;
fixture.Listen<int>().Subscribe(_ => messageReceived = true);

fixture.SendMessage(42);
Assert.True(messageReceived);
}

[Fact]
public void ListeningBeforeRegisteringASourceShouldWork()
{
Expand Down Expand Up @@ -121,18 +116,18 @@ public void RegisteringSecondMessageSourceShouldMergeBothSources()
}

[Fact]
public void MessageBusThreadingTest()
public async Task MessageBusThreadingTest()
{
var mb = new MessageBus();
int? listenedThread = null;
int? otherThread = null;
int thisThread = Thread.CurrentThread.ManagedThreadId;

Task.Run(() => {
await Task.Run(() => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't that stable locally, but doing async/await rather than Wait() seemed to make it happier

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, calling Wait is a big no-no. See here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, hadn't seen that, but does explain things! I think this was the only consistent deadlock, so hopefully we're not doing it elsewhere!

otherThread = Thread.CurrentThread.ManagedThreadId;
mb.Listen<int>().Subscribe(_ => listenedThread = Thread.CurrentThread.ManagedThreadId);
mb.SendMessage<int>(42);
}).Wait();
});

Assert.NotEqual(listenedThread.Value, thisThread);
Assert.Equal(listenedThread.Value, otherThread.Value);
Expand Down
5 changes: 3 additions & 2 deletions src/ReactiveUI.Tests/ObservableAsPropertyHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reactive.Concurrency;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Reactive.Subjects;
Expand Down Expand Up @@ -209,9 +210,9 @@ public void ToPropertyShouldFireBothChangingAndChanged()
var dontcare = (fixture.FirstThreeLettersOfOneWord ?? "").Substring(0, 0);

var resultChanging = fixture.ObservableForProperty(x => x.FirstThreeLettersOfOneWord, beforeChange: true)
.CreateCollection();
.CreateCollection(scheduler: ImmediateScheduler.Instance);
var resultChanged = fixture.ObservableForProperty(x => x.FirstThreeLettersOfOneWord, beforeChange: false)
.CreateCollection();
.CreateCollection(scheduler: ImmediateScheduler.Instance);

Assert.Empty(resultChanging);
Assert.Empty(resultChanged);
Expand Down
6 changes: 3 additions & 3 deletions src/ReactiveUI.Tests/Platforms/winforms/ActivationTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MS-PL license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -31,7 +31,7 @@ public void CanFetchActivatorForForm()

Assert.NotNull(formActivator);
}


[Fact]
public void CanFetchActivatorForControl()
Expand Down Expand Up @@ -81,7 +81,7 @@ public void SmokeTestWindowsForm()
public void SmokeTestUserControl()
{
var target = new ReactiveUI.Winforms.ActivationForViewFetcher();
using(var userControl = new TestControl())
using (var userControl = new TestControl())
using (var parent = new TestForm()) {
var userControlActivator = target.GetActivationForView(userControl);

Expand Down
Loading