Browse Source

Adapt threading tests to VerifyAccess on AvaloniaObject.ctor

pull/1105/head
Nikita Tsukanov 9 years ago
parent
commit
884423d879
  1. 52
      tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_Threading.cs

52
tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_Threading.cs

@ -14,13 +14,24 @@ namespace Avalonia.Base.UnitTests
{
public class AvaloniaObjectTests_Threading
{
private ThreadingInterface _threading = new ThreadingInterface(true);
[Fact]
public void StyledProperty_GetValue_Should_Throw()
public void AvaloniaObject_Constructor_Should_Throw()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: new ThreadingInterface())))
{
var target = new Class1();
Assert.Throws<InvalidOperationException>(() => new Class1());
}
}
[Fact]
public void StyledProperty_GetValue_Should_Throw()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: _threading)))
{
var target = new Class1();
_threading.CurrentThreadIsLoopThread = false;
Assert.Throws<InvalidOperationException>(() => target.GetValue(Class1.StyledProperty));
}
}
@ -28,10 +39,10 @@ namespace Avalonia.Base.UnitTests
[Fact]
public void StyledProperty_SetValue_Should_Throw()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: new ThreadingInterface())))
using (UnitTestApplication.Start(new TestServices(threadingInterface: _threading)))
{
var target = new Class1();
_threading.CurrentThreadIsLoopThread = false;
Assert.Throws<InvalidOperationException>(() => target.SetValue(Class1.StyledProperty, "foo"));
}
}
@ -39,10 +50,10 @@ namespace Avalonia.Base.UnitTests
[Fact]
public void Setting_StyledProperty_Binding_Should_Throw()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: new ThreadingInterface())))
using (UnitTestApplication.Start(new TestServices(threadingInterface: _threading)))
{
var target = new Class1();
_threading.CurrentThreadIsLoopThread = false;
Assert.Throws<InvalidOperationException>(() =>
target.Bind(
Class1.StyledProperty,
@ -53,10 +64,10 @@ namespace Avalonia.Base.UnitTests
[Fact]
public void StyledProperty_ClearValue_Should_Throw()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: new ThreadingInterface())))
using (UnitTestApplication.Start(new TestServices(threadingInterface: _threading)))
{
var target = new Class1();
_threading.CurrentThreadIsLoopThread = false;
Assert.Throws<InvalidOperationException>(() => target.ClearValue(Class1.StyledProperty));
}
}
@ -64,10 +75,10 @@ namespace Avalonia.Base.UnitTests
[Fact]
public void StyledProperty_IsSet_Should_Throw()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: new ThreadingInterface())))
using (UnitTestApplication.Start(new TestServices(threadingInterface: _threading)))
{
var target = new Class1();
_threading.CurrentThreadIsLoopThread = false;
Assert.Throws<InvalidOperationException>(() => target.IsSet(Class1.StyledProperty));
}
}
@ -75,10 +86,10 @@ namespace Avalonia.Base.UnitTests
[Fact]
public void DirectProperty_GetValue_Should_Throw()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: new ThreadingInterface())))
using (UnitTestApplication.Start(new TestServices(threadingInterface: _threading)))
{
var target = new Class1();
_threading.CurrentThreadIsLoopThread = false;
Assert.Throws<InvalidOperationException>(() => target.GetValue(Class1.DirectProperty));
}
}
@ -86,10 +97,10 @@ namespace Avalonia.Base.UnitTests
[Fact]
public void DirectProperty_SetValue_Should_Throw()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: new ThreadingInterface())))
using (UnitTestApplication.Start(new TestServices(threadingInterface: _threading)))
{
var target = new Class1();
_threading.CurrentThreadIsLoopThread = false;
Assert.Throws<InvalidOperationException>(() => target.SetValue(Class1.DirectProperty, "foo"));
}
}
@ -97,10 +108,10 @@ namespace Avalonia.Base.UnitTests
[Fact]
public void Setting_DirectProperty_Binding_Should_Throw()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: new ThreadingInterface())))
using (UnitTestApplication.Start(new TestServices(threadingInterface: _threading)))
{
var target = new Class1();
_threading.CurrentThreadIsLoopThread = false;
Assert.Throws<InvalidOperationException>(() =>
target.Bind(
Class1.DirectProperty,
@ -111,10 +122,10 @@ namespace Avalonia.Base.UnitTests
[Fact]
public void DirectProperty_ClearValue_Should_Throw()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: new ThreadingInterface())))
using (UnitTestApplication.Start(new TestServices(threadingInterface: _threading)))
{
var target = new Class1();
_threading.CurrentThreadIsLoopThread = false;
Assert.Throws<InvalidOperationException>(() => target.ClearValue(Class1.DirectProperty));
}
}
@ -122,10 +133,10 @@ namespace Avalonia.Base.UnitTests
[Fact]
public void DirectProperty_IsSet_Should_Throw()
{
using (UnitTestApplication.Start(new TestServices(threadingInterface: new ThreadingInterface())))
using (UnitTestApplication.Start(new TestServices(threadingInterface: _threading)))
{
var target = new Class1();
_threading.CurrentThreadIsLoopThread = false;
Assert.Throws<InvalidOperationException>(() => target.IsSet(Class1.DirectProperty));
}
}
@ -141,6 +152,7 @@ namespace Avalonia.Base.UnitTests
private class ThreadingInterface : IPlatformThreadingInterface
{
public ThreadingInterface(bool isLoopThread = false)
{
CurrentThreadIsLoopThread = isLoopThread;

Loading…
Cancel
Save