From 6686ad4b8d8d62aca96eb9e220ee2db0242daa96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Sun, 21 Feb 2016 14:38:07 +0100 Subject: [PATCH] Migrated to XUnit and fixed tests Remove app.config Fixed OmniXaml.Tests tests Skip test for now --- .../Glass.Tests/AutoKeyDictionaryTests.cs | 16 +- .../ObservablePropertyChainTests.cs | 35 ++-- .../Glass.Tests/DependencyResolverTest.cs | 24 +-- Source/Tests/Glass.Tests/Glass.Tests.csproj | 32 ++- Source/Tests/Glass.Tests/app.config | 16 +- Source/Tests/Glass.Tests/packages.config | 7 + .../InflatableFactoryTest.cs | 33 ++- .../OmniXaml.Services.DotNetFx.Tests.csproj | 31 ++- .../app.config | 11 - .../packages.config | 10 + .../InflatableTests.cs | 7 +- .../OmniXaml.Services.Tests.csproj | 24 +-- .../OmniXaml.Services.Tests/packages.config | 12 +- .../ConfiguredAssemblyWithNamespacesTests.cs | 7 +- .../InstructionTreeBuilderTests.cs | 27 ++- .../OmniXaml.Tests/LookaheadBufferTests.cs | 23 +- .../MemberDependencyNodeSorterTests.cs | 23 +- .../OmniXaml.Tests/NamespaceRegistryTests.cs | 26 ++- .../OmniXaml.Tests/ObjectAssemblerTests.cs | 196 +++++++++--------- .../OmniXaml.Tests/OmniXaml.Tests.csproj | 24 +-- .../MarkupExtensionsParsingFromProtoToXaml.cs | 11 +- .../InstructionParserTests/ParsingTests.cs | 124 ++++++----- .../Integration/FromXamlToInstructions.cs | 72 ++++--- ...pExtensionNodeToXamlNodesConverterTests.cs | 23 +- .../ParsingTests.cs | 59 +++--- .../StackWithLinkedNodesTests.cs | 2 +- .../TemplateHostingObjectAssemblerTests.cs | 14 +- .../OmniXaml.Tests/TypeRepositoryTests.cs | 44 ++-- .../OmniXaml.Tests/VisualizationTests.cs | 7 +- .../MarkupExtensionsTests.cs | 45 ++-- .../XamlXmlLoaderTests/NameScopeTests.cs | 13 +- .../XamlXmlLoaderTests/ParsingTests.cs | 158 +++++++------- .../XamlXmlLoaderTests/SpecialTests.cs | 10 +- Source/Tests/OmniXaml.Tests/packages.config | 12 +- .../Tests/OmniXaml.Wpf.Tests/LoadingTests.cs | 47 ++--- .../OmniXaml.Wpf.Tests.csproj | 36 +++- .../Tests/OmniXaml.Wpf.Tests/packages.config | 11 + 37 files changed, 647 insertions(+), 625 deletions(-) delete mode 100644 Source/Tests/OmniXaml.Services.DotNetFx.Tests/app.config create mode 100644 Source/Tests/OmniXaml.Services.DotNetFx.Tests/packages.config create mode 100644 Source/Tests/OmniXaml.Wpf.Tests/packages.config diff --git a/Source/Tests/Glass.Tests/AutoKeyDictionaryTests.cs b/Source/Tests/Glass.Tests/AutoKeyDictionaryTests.cs index 1599106..4b8fa96 100644 --- a/Source/Tests/Glass.Tests/AutoKeyDictionaryTests.cs +++ b/Source/Tests/Glass.Tests/AutoKeyDictionaryTests.cs @@ -1,30 +1,28 @@ namespace Glass.Tests { using System.Collections.Generic; - using Microsoft.VisualStudio.TestTools.UnitTesting; + using Xunit; - [TestClass] public class AutoKeyDictionaryTests { - [TestMethod] + [Fact] public void IndexerTestKeyExist() { var sut = new AutoKeyDictionary(i => i + 1, i => i < 3); var value = "Pepito"; sut.Add(2, value); var result = sut[1]; - Assert.AreEqual(value, result); + Assert.Equal(value, result); } - [TestMethod] - [ExpectedException(typeof(KeyNotFoundException))] + [Fact] public void IndexerTestKeyDoesNotExist() { var sut = new AutoKeyDictionary(i => i + 1, i => i < 2); - var result = sut[1]; + Assert.Throws(() => sut[1]); } - [TestMethod] + [Fact] public void TryGetTestKeyExist() { var sut = new AutoKeyDictionary(i => i + 1, i => i < 3); @@ -32,7 +30,7 @@ sut.Add(2, expected); string actual; var result = sut.TryGetValue(1, out actual); - Assert.AreEqual(expected, actual); + Assert.Equal(expected, actual); } } } \ No newline at end of file diff --git a/Source/Tests/Glass.Tests/ChangeTracking/ObservablePropertyChainTests.cs b/Source/Tests/Glass.Tests/ChangeTracking/ObservablePropertyChainTests.cs index bf0807f..3f0a16b 100644 --- a/Source/Tests/Glass.Tests/ChangeTracking/ObservablePropertyChainTests.cs +++ b/Source/Tests/Glass.Tests/ChangeTracking/ObservablePropertyChainTests.cs @@ -2,12 +2,11 @@ { using System; using Glass.ChangeTracking; - using Microsoft.VisualStudio.TestTools.UnitTesting; + using Xunit; - [TestClass] public class ObservablePropertyChainTests { - [TestMethod] + [Fact] public void SubscriptionToOneLevelPath() { var changeSource = new DummyViewModel(); @@ -17,10 +16,10 @@ sut.Subscribe(o => actualText = o); changeSource.Text = "Hello world"; - Assert.AreEqual("Hello world", actualText); + Assert.Equal("Hello world", actualText); } - [TestMethod] + [Fact] public void SubscriptionToTwoLevelPath() { var changeSource = new DummyViewModel { Child = new DummyViewModel() }; @@ -30,10 +29,10 @@ sut.Subscribe(o => actualText = o); changeSource.Child.Text = "Hello world"; - Assert.AreEqual("Hello world", actualText); + Assert.Equal("Hello world", actualText); } - [TestMethod] + [Fact] public void GivenSubscriptionToTwoLevelPath_WhenRootChanges_NotificationsShouldArrive() { var changeSource = new DummyViewModel { Child = new DummyViewModel { Text = "Old text" } }; @@ -43,10 +42,10 @@ sut.Subscribe(o => actualText = o); changeSource.Child = new DummyViewModel { Text = "This is the real thing" }; - Assert.AreEqual("This is the real thing", actualText); + Assert.Equal("This is the real thing", actualText); } - [TestMethod] + [Fact] public void GivenSubscriptionToTwoLevelPath_WhenRootChangesButValuesAreSame_NoNotificationAreReceived() { var changeSource = new DummyViewModel { Child = new DummyViewModel { Text = "Same" } }; @@ -56,10 +55,10 @@ sut.Subscribe(o => hit = true); changeSource.Child = new DummyViewModel { Text = "Same" }; - Assert.IsFalse(hit); + Assert.False(hit); } - [TestMethod] + [Fact] public void GivenSubscriptionToTwoLevelPath_WhenRootChangesInDifferentSteps_NotificationsShouldArrive() { var changeSource = new DummyViewModel { Child = new DummyViewModel { Text = "Old text" } }; @@ -70,34 +69,34 @@ changeSource.Child = new DummyViewModel(); changeSource.Child.Text = "This is the real thing"; - Assert.AreEqual("This is the real thing", actualText); + Assert.Equal("This is the real thing", actualText); } - [TestMethod] + [Fact] public void GivenSubscriptionToTwoLevelPathToStruct_RetrievesTheCorrectValue() { var changeSource = new DummyViewModel { Child = new DummyViewModel { MyStruct = new MyStruct { Text = "My text" } } }; var sut = new ObservablePropertyChain(changeSource, "Child.MyStruct.Text"); - Assert.AreEqual("My text", sut.Value); + Assert.Equal("My text", sut.Value); } - [TestMethod] + [Fact] public void ValueTypeChain_WithOneLevel_ValueIsAccessed() { var root = new MyStruct { Text = "Hello" }; var sut = new ValueTypePropertyChain(root, "Text"); - Assert.AreEqual("Hello", sut.Value); + Assert.Equal("Hello", sut.Value); } - [TestMethod] + [Fact] public void ValueTypeChain_WithTwoLevels_ValueIsAccessed() { var root = new MyStruct { Child = new ChildStruct { Text = "Some text" } }; var sut = new ValueTypePropertyChain(root, "Child.Text"); - Assert.AreEqual("Some text", sut.Value); + Assert.Equal("Some text", sut.Value); } } } diff --git a/Source/Tests/Glass.Tests/DependencyResolverTest.cs b/Source/Tests/Glass.Tests/DependencyResolverTest.cs index 6ce087b..4576706 100644 --- a/Source/Tests/Glass.Tests/DependencyResolverTest.cs +++ b/Source/Tests/Glass.Tests/DependencyResolverTest.cs @@ -4,12 +4,11 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; - using Microsoft.VisualStudio.TestTools.UnitTesting; + using Xunit; - [TestClass] public class DependencyResolverTest { - [TestMethod] + [Fact] public void SortTest() { var a = new Node("A"); @@ -25,10 +24,10 @@ var expected = new List { d, e, c, b, a }; var actual = DependencySorter.SortDependencies(new Collection { a, b, c, d, e }).ToList(); - CollectionAssert.AreEqual(expected, actual); + Assert.Equal(expected, actual); } - [TestMethod] + [Fact] public void SimpleTest() { var prop = new Node("Property"); @@ -39,10 +38,10 @@ var expected = new List { prop, val }; var actual = DependencySorter.SortDependencies(new Collection { prop, val }).ToList(); - CollectionAssert.AreEqual(expected, actual); + Assert.Equal(expected, actual); } - [TestMethod] + [Fact] public void AlreadySorted() { var a = new Node("A"); @@ -60,10 +59,10 @@ var expected = new List { a, b, c, d, e }; var actual = DependencySorter.SortDependencies(new Collection { a, b, c, d, e }).ToList(); - CollectionAssert.AreEqual(expected, actual); + Assert.Equal(expected, actual); } - [TestMethod] + [Fact] public void PartiallySorted() { var a = new Node("A"); @@ -81,11 +80,10 @@ var expected = new List { a, b, c, e, d }; var actual = DependencySorter.SortDependencies(new Collection { a, b, c, d, e }).ToList(); - CollectionAssert.AreEqual(expected, actual); + Assert.Equal(expected, actual); } - [TestMethod] - [ExpectedException(typeof(InvalidOperationException))] + [Fact] public void CircularDependency() { var a = new Node("A"); @@ -99,7 +97,7 @@ c.Dependencies = new Collection { d, e }; e.Dependencies = new Collection { a }; - DependencySorter.SortDependencies(new Collection { a, b, c, d, e }); + Assert.Throws(() => DependencySorter.SortDependencies(new Collection { a, b, c, d, e })); } } } diff --git a/Source/Tests/Glass.Tests/Glass.Tests.csproj b/Source/Tests/Glass.Tests/Glass.Tests.csproj index 76c2738..4bba944 100644 --- a/Source/Tests/Glass.Tests/Glass.Tests.csproj +++ b/Source/Tests/Glass.Tests/Glass.Tests.csproj @@ -1,5 +1,6 @@  + Debug AnyCPU @@ -8,7 +9,7 @@ Properties Glass.Tests Glass.Tests - v4.5.2 + v4.5 512 {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 10.0 @@ -18,6 +19,7 @@ UnitTest + true @@ -50,6 +52,22 @@ ..\..\..\packages\Rx-Linq.2.3.0-beta2\lib\net45\System.Reactive.Linq.dll True + + ..\..\..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll + True + + + ..\..\..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll + True + + + ..\..\..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll + True + + + ..\..\..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll + True + @@ -57,11 +75,7 @@ - - - - - + @@ -104,6 +118,12 @@ + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + +