From 937abb1c3910053f10e0460f567e1d4d353588ae Mon Sep 17 00:00:00 2001 From: Tomasz Cielecki Date: Sun, 4 Feb 2018 12:20:19 +0100 Subject: [PATCH] Fix a whole bunch of tests --- .../MvvmCross.Test/MvxIoCSupportingTest.cs | 25 ++- .../MvvmCross.UnitTest/Base/MvxIoCTest.cs | 38 ++-- .../Base/ReflectionExtensionsTests.cs | 175 ------------------ .../Binding/Binders/MvxSourceStepTests.cs | 2 +- .../MvxFullBindingConstructionTest.cs | 2 +- .../Binding/Bindings/MvxFullBindingTest.cs | 2 +- .../MvxFullBindingValueConversionTest.cs | 2 +- .../MvxExpressionBindingTest.cs | 2 +- .../ExtensionMethods/MakeSafeValueTest.cs | 32 ++-- .../Binding/Swiss/MvxSwissBindingTest.cs | 2 +- .../Binding/Swiss/MvxTibetBindingTest.cs | 10 +- .../MvxSourcePropertyPathParserTest.cs | 6 +- .../Dispatchers/NavigationMockDispatcher.cs | 5 +- .../Navigation/NavigationServiceTests.cs | 4 +- .../Navigation/RoutingServiceTests.cs | 2 +- .../MvxStringDictionaryTextSerializerTest.cs | 1 - ...PropertyDictionaryExtensionMethodsTests.cs | 4 +- .../Platform/MvxStringToTypeParserTest.cs | 3 +- .../Platform/MvxViewModelByNameLookupTest.cs | 2 +- .../MvxViewModelViewLookupBuilderTest.cs | 4 +- .../MvxViewModelViewTypeFinderTest.cs | 2 +- .../ViewModels/MvxBundleTest.cs | 2 +- .../ViewModels/MvxCommandCollectionTest.cs | 2 +- .../MvxDefaultViewModelLocatorTest.cs | 2 +- .../MvxNotifyPropertyChangedTest.cs | 4 +- .../ViewModels/MvxSaveStateTest.cs | 2 +- .../ViewModels/MvxViewModelLoaderTest.cs | 4 +- .../MvxDictionaryTextProviderTest.cs | 11 +- .../MessengerHubTest.cs | 15 +- 29 files changed, 112 insertions(+), 255 deletions(-) delete mode 100644 MvvmCross.Tests/MvvmCross.UnitTest/Base/ReflectionExtensionsTests.cs diff --git a/MvvmCross.Tests/MvvmCross.Test/MvxIoCSupportingTest.cs b/MvvmCross.Tests/MvvmCross.Test/MvxIoCSupportingTest.cs index 9047ae5d8..ab2520cda 100644 --- a/MvvmCross.Tests/MvvmCross.Test/MvxIoCSupportingTest.cs +++ b/MvvmCross.Tests/MvvmCross.Test/MvxIoCSupportingTest.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Globalization; +using MvvmCross.Binding; using MvvmCross.Core; using MvvmCross.Core.Platform; using MvvmCross.Platform.Core; @@ -30,12 +31,13 @@ namespace MvvmCross.Test return null; } - public virtual void ClearAll() + public virtual void ClearAll(IMvxIocOptions options = null) { // fake set up of the IoC Reset(); - Ioc = MvxIoCProvider.Initialize(CreateIocOptions()); + Ioc = MvxIoCProvider.Initialize(options ?? CreateIocOptions()); Ioc.RegisterSingleton(Ioc); + CreateLog(); InitializeSingletonCache(); InitializeMvxSettings(); AdditionalSetup(); @@ -43,7 +45,11 @@ namespace MvvmCross.Test public void InitializeSingletonCache() { - MvxSingletonCache.Initialize(); + if (MvxSingletonCache.Instance == null) + MvxSingletonCache.Initialize(); + + if (MvxBindingSingletonCache.Instance == null) + MvxBindingSingletonCache.Initialize(); } protected virtual void InitializeMvxSettings() @@ -53,7 +59,18 @@ namespace MvvmCross.Test protected virtual void AdditionalSetup() { - Ioc.RegisterSingleton(new TestLogProvider()); + } + + protected virtual void CreateLog() + { + var logProvider = new TestLogProvider(); + Ioc.RegisterSingleton(logProvider); + + var globalLog = logProvider.GetLogFor(); + MvxLog.Instance = globalLog; + Ioc.RegisterSingleton(globalLog); + + var pluginLog = logProvider.GetLogFor("MvxPlugin"); } public void SetInvariantCulture() diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Base/MvxIoCTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Base/MvxIoCTest.cs index 9a75e2d51..b35a1e48d 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Base/MvxIoCTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Base/MvxIoCTest.cs @@ -9,12 +9,21 @@ using MvvmCross.Platform.IoC; using Xunit; using System.Reflection; using System.Linq; +using MvvmCross.Test; namespace MvvmCross.Platform.Test { - + [Collection("MvxTest")] public class MvxIocTest { + private readonly MvxTestFixture _fixture; + + public MvxIocTest(MvxTestFixture fixture) + { + _fixture = fixture; + _fixture.ClearAll(); + } + public interface IA { IB B { get; } @@ -112,19 +121,16 @@ namespace MvvmCross.Platform.Test public void TryResolve_CircularButSafeDynamicWithOptionOff_ReturnsTrue() { COdd.FirstTime = true; - MvxSingleton.ClearAllSingletons(); - var options = new MvxIocOptions() + _fixture.ClearAll(new MvxIocOptions() { TryToDetectDynamicCircularReferences = false - }; - var instance = MvxIoCProvider.Initialize(options); + }); - Mvx.RegisterType(); - Mvx.RegisterType(); - Mvx.RegisterType(); + _fixture.Ioc.RegisterType(); + _fixture.Ioc.RegisterType(); + _fixture.Ioc.RegisterType(); - IA a; - var result = Mvx.TryResolve(out a); + var result = _fixture.Ioc.TryResolve(out IA a); Assert.True(result); Assert.NotNull(a); } @@ -133,15 +139,13 @@ namespace MvvmCross.Platform.Test public void TryResolve_CircularButSafeDynamicWithOptionOn_ReturnsFalse() { COdd.FirstTime = true; - MvxSingleton.ClearAllSingletons(); - var instance = MvxIoCProvider.Initialize(); + _fixture.ClearAll(); - Mvx.RegisterType(); - Mvx.RegisterType(); - Mvx.RegisterType(); + _fixture.Ioc.RegisterType(); + _fixture.Ioc.RegisterType(); + _fixture.Ioc.RegisterType(); - IA a; - var result = Mvx.TryResolve(out a); + var result = _fixture.Ioc.TryResolve(out IA a); Assert.False(result); Assert.Null(a); } diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Base/ReflectionExtensionsTests.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Base/ReflectionExtensionsTests.cs deleted file mode 100644 index c24c6224a..000000000 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Base/ReflectionExtensionsTests.cs +++ /dev/null @@ -1,175 +0,0 @@ -// 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. - -using System.Linq; -using System.Reflection; -using Xunit; - -namespace MvvmCross.Platform.Test -{ - - public class ReflectionExtensionsTests - { - private class TestClass - { - public static readonly object PublicStaticField = new object(); - - public object PublicInstanceField1 = new object(); - public object PublicInstanceField2 = new object(); - - private object _privateInstanceField1 = new object(); - - public TestClass() - { - } - - public TestClass(object param1) - { - } - } - - private class TestSubClass : TestBaseClass - { - public object PublicSubInstanceField1 = new object(); - - private object _privateInstanceField1 = new object(); - } - - private class TestBaseClass - { - public object PublicBaseInstanceField1 = new object(); - public object PublicBaseInstanceField2 = new object(); - - private object _privateBaseInstanceField1 = new object(); - - public TestBaseClass() - { - } - } - - #region Fields - - [Fact] - public void TestGetStaticFields() - { - // Act - var fields = typeof(TestClass).GetFields(BindingFlags.Static); - - // Assert - Assert.Equal(1, fields.Count()); - } - - [Fact] - public void TestGetPublicInstanceFields() - { - // Act - var fields = typeof(TestClass).GetFields(BindingFlags.Public | BindingFlags.Instance); - - // Assert - Assert.Equal(2, fields.Count()); - } - - [Fact] - public void TestGetAllInstanceFields() - { - // Act - var fields = typeof(TestClass).GetFields(BindingFlags.Instance); - - // Assert - Assert.Equal(3, fields.Count()); - } - - [Fact] - public void TestGetAllFields() - { - // Act - var fields = typeof(TestClass).GetFields(); - - // Assert - Assert.Equal(3, fields.Count()); - } - - [Fact] - public void TestGetInstanceFieldByNameStaticFieldSpecified() - { - // Act - var field = typeof(TestClass).GetField("PublicStaticField", BindingFlags.Public | BindingFlags.Static); - - // Assert - Assert.NotNull(field); - } - - [Fact] - public void TestGetInstanceFieldByNameReturnsNullIfStaticFieldSpecified() - { - // Act - var field = typeof(TestClass).GetField("PublicStaticField", BindingFlags.Public | BindingFlags.Instance); - - // Assert - Assert.Null(field); - } - - [Fact] - public void TestGetInstanceFieldByNameInstanceFieldSpecified() - { - // Act - var field = typeof(TestClass).GetField("PublicInstanceField1", BindingFlags.Public | BindingFlags.Instance); - - // Assert - Assert.NotNull(field); - } - - [Fact] - public void TestGetStaticFieldByNameReturnsNullIfInstanceFieldSpecified() - { - // Act - var field = typeof(TestClass).GetField("PublicInstanceField1", BindingFlags.Public | BindingFlags.Static); - - // Assert - Assert.Null(field); - } - - [Fact] - public void TestFlattenHierarchyGetsAllFields() - { - // Act - var fields = typeof(TestSubClass).GetFields(BindingFlags.Public | BindingFlags.FlattenHierarchy); - - // Assert - Assert.Equal(3, fields.Count()); - } - - [Fact] - public void TestFlattenHierarchyGetsOnlyDeclaredFields() - { - // Act - var fields = typeof(TestSubClass).GetFields(BindingFlags.Public); - - // Assert - Assert.Equal(1, fields.Count()); - } - - #endregion Fields - - [Fact] - public void TestGetConstructors() - { - // Act - var ctors = typeof(TestClass).GetConstructors(); - - // Assert - Assert.Equal(2, ctors.Count()); - } - - [Fact] - public void TestGetBaseConstructor() - { - // Act - var ctors = typeof(TestSubClass).GetConstructors(); - - // Assert - Assert.Equal(1, ctors.Count()); - } - } -} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Binders/MvxSourceStepTests.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Binders/MvxSourceStepTests.cs index 894cf62e9..9fc5cde19 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Binders/MvxSourceStepTests.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Binders/MvxSourceStepTests.cs @@ -20,7 +20,7 @@ using Xunit; namespace MvvmCross.Binding.Test.Binders { [Collection("MvxTest")] - public class MvxSourceStepTests : IClassFixture + public class MvxSourceStepTests { private readonly MvxTestFixture _fixture; diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingConstructionTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingConstructionTest.cs index 593aadac3..8dc7291dc 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingConstructionTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingConstructionTest.cs @@ -19,7 +19,7 @@ using Xunit; namespace MvvmCross.Binding.Test.Bindings { [Collection("MvxTest")] - public class MvxFullBindingConstructionTest : IClassFixture + public class MvxFullBindingConstructionTest { private readonly MvxTestFixture _fixture; diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingTest.cs index a12f195c0..542b340ca 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingTest.cs @@ -17,7 +17,7 @@ using Xunit; namespace MvvmCross.Binding.Test.Bindings { [Collection("MvxTest")] - public class MvxFullBindingTest : IClassFixture + public class MvxFullBindingTest { private readonly MvxTestFixture _fixture; diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingValueConversionTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingValueConversionTest.cs index 97f7835aa..2455d88c0 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingValueConversionTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingValueConversionTest.cs @@ -21,7 +21,7 @@ using Xunit; namespace MvvmCross.Binding.Test.Bindings { [Collection("MvxTest")] - public class MvxFullBindingValueConversionTest : IClassFixture + public class MvxFullBindingValueConversionTest { private readonly MvxTestFixture _fixture; diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/ExpressionParse/MvxExpressionBindingTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/ExpressionParse/MvxExpressionBindingTest.cs index a90ea95be..4fa360f7f 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/ExpressionParse/MvxExpressionBindingTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/ExpressionParse/MvxExpressionBindingTest.cs @@ -19,7 +19,7 @@ using Xunit; namespace MvvmCross.Binding.Test.ExpressionParse { [Collection("MvxTest")] - public class MvxExpressionBindingTest : IClassFixture + public class MvxExpressionBindingTest { private readonly MvxTestFixture _fixture; diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/ExtensionMethods/MakeSafeValueTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/ExtensionMethods/MakeSafeValueTest.cs index a455c1f85..2a6d9368c 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/ExtensionMethods/MakeSafeValueTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/ExtensionMethods/MakeSafeValueTest.cs @@ -12,8 +12,8 @@ using Xunit; namespace MvvmCross.Binding.Test.ExtensionMethods { - - public class MakeSafeValueTest : IClassFixture + [Collection("MvxTest")] + public class MakeSafeValueTest { private readonly MvxTestFixture _fixture; @@ -39,7 +39,7 @@ namespace MvvmCross.Binding.Test.ExtensionMethods public void TestIntValues() { _fixture.ClearAll(); - Mvx.RegisterSingleton(new MockAutoValueConverters()); + _fixture.Ioc.RegisterSingleton(new MockAutoValueConverters()); Assert.Equal(0, typeof(int).MakeSafeValue(0)); Assert.Equal(0, typeof(int).MakeSafeValue(null)); @@ -55,7 +55,7 @@ namespace MvvmCross.Binding.Test.ExtensionMethods public void TestDoubleValues() { _fixture.ClearAll(); - Mvx.RegisterSingleton(new MockAutoValueConverters()); + _fixture.Ioc.RegisterSingleton(new MockAutoValueConverters()); Assert.Equal(0.0, typeof(double).MakeSafeValue(0.0)); Assert.Equal(0.0, typeof(double).MakeSafeValue(null)); @@ -71,16 +71,16 @@ namespace MvvmCross.Binding.Test.ExtensionMethods public void TestFloatValues() { _fixture.ClearAll(); - Mvx.RegisterSingleton(new MockAutoValueConverters()); + _fixture.Ioc.RegisterSingleton(new MockAutoValueConverters()); - Assert.Equal(0.0f, typeof(double).MakeSafeValue(0.0f)); - Assert.Equal(0.0f, typeof(double).MakeSafeValue(null)); - Assert.Equal(1.0f, typeof(double).MakeSafeValue(1.0f)); - Assert.Equal(0.0f, typeof(double?).MakeSafeValue(0.0f)); + Assert.Equal(0.0f, typeof(float).MakeSafeValue(0.0f)); + Assert.Equal(0.0f, typeof(float).MakeSafeValue(null)); + Assert.Equal(1.0f, typeof(float).MakeSafeValue(1.0f)); + Assert.Equal(0.0f, typeof(float?).MakeSafeValue(0.0f)); Assert.Null(typeof(double?).MakeSafeValue(null)); - Assert.Equal(1.0f, typeof(double?).MakeSafeValue(1.0f)); - Assert.Equal(1.0f, typeof(double).MakeSafeValue(1f)); - Assert.Equal(0.0f, typeof(double?).MakeSafeValue(0f)); + Assert.Equal(1.0f, typeof(float?).MakeSafeValue(1.0f)); + Assert.Equal(1.0f, typeof(float).MakeSafeValue(1f)); + Assert.Equal(0.0f, typeof(float?).MakeSafeValue(0f)); } public class MyTest @@ -95,7 +95,7 @@ namespace MvvmCross.Binding.Test.ExtensionMethods public void TestStringValues() { _fixture.ClearAll(); - Mvx.RegisterSingleton(new MockAutoValueConverters()); + _fixture.Ioc.RegisterSingleton(new MockAutoValueConverters()); Assert.Equal("0", typeof(string).MakeSafeValue(0.0)); Assert.Null(typeof(string).MakeSafeValue(null)); @@ -115,7 +115,7 @@ namespace MvvmCross.Binding.Test.ExtensionMethods public void TestEnumValues() { _fixture.ClearAll(); - Mvx.RegisterSingleton(new MockAutoValueConverters()); + _fixture.Ioc.RegisterSingleton(new MockAutoValueConverters()); Assert.Equal(SampleEnum.Defaulto, typeof(SampleEnum).MakeSafeValue(0)); Assert.Equal(SampleEnum.Defaulto, typeof(SampleEnum).MakeSafeValue(null)); @@ -128,7 +128,7 @@ namespace MvvmCross.Binding.Test.ExtensionMethods public void TestBoolValues() { _fixture.ClearAll(); - Mvx.RegisterSingleton(new MockAutoValueConverters()); + _fixture.Ioc.RegisterSingleton(new MockAutoValueConverters()); Assert.False((bool)typeof(bool).MakeSafeValue(0)); Assert.False((bool)typeof(bool).MakeSafeValue(null)); @@ -159,7 +159,7 @@ namespace MvvmCross.Binding.Test.ExtensionMethods public void TestObjectValues() { _fixture.ClearAll(); - Mvx.RegisterSingleton(new MockAutoValueConverters()); + _fixture.Ioc.RegisterSingleton(new MockAutoValueConverters()); var foo = new Foo(); Assert.Equal(foo, typeof(FooBase).MakeSafeValue(foo)); diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/Binding/Swiss/MvxSwissBindingTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/Binding/Swiss/MvxSwissBindingTest.cs index 34105eab7..6ade29bac 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/Binding/Swiss/MvxSwissBindingTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/Binding/Swiss/MvxSwissBindingTest.cs @@ -63,7 +63,7 @@ namespace MvvmCross.Binding.Test.Parse.Binding.Swiss Path = "Foo", }, }, - ConverterParameter = 12 + ConverterParameter = 12L } } }; diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/Binding/Swiss/MvxTibetBindingTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/Binding/Swiss/MvxTibetBindingTest.cs index f82e61ea4..3bd394c07 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/Binding/Swiss/MvxTibetBindingTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/Binding/Swiss/MvxTibetBindingTest.cs @@ -63,7 +63,7 @@ namespace MvvmCross.Binding.Test.Parse.Binding.Swiss }, new MvxSerializableBindingDescription() { - Literal = 12, + Literal = 12L, }, }, } @@ -226,7 +226,7 @@ namespace MvvmCross.Binding.Test.Parse.Binding.Swiss { Path = "Foo2", Converter = "Second", - FallbackValue = 23, + FallbackValue = 23L, } }, }, @@ -236,7 +236,7 @@ namespace MvvmCross.Binding.Test.Parse.Binding.Swiss }, new MvxSerializableBindingDescription() { - Literal = 23, + Literal = 23L, }, } } @@ -288,7 +288,7 @@ namespace MvvmCross.Binding.Test.Parse.Binding.Swiss { Path = "Foo2", Converter = "Second", - FallbackValue = 23, + FallbackValue = 23L, } } }, @@ -348,7 +348,7 @@ namespace MvvmCross.Binding.Test.Parse.Binding.Swiss { Path = "Foo2", Converter = "Second", - FallbackValue = 23, + FallbackValue = 23L, } } }, diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/PropertyPath/MvxSourcePropertyPathParserTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/PropertyPath/MvxSourcePropertyPathParserTest.cs index f082a1841..1b664473f 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/PropertyPath/MvxSourcePropertyPathParserTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/PropertyPath/MvxSourcePropertyPathParserTest.cs @@ -175,14 +175,14 @@ namespace MvvmCross.Binding.Test.Parse.PropertyPath private static void AssertIsSimplePropertyToken(MvxPropertyToken token, string text) { - Assert.IsType(token); + Assert.IsAssignableFrom(token); Assert.Equal(text, ((MvxPropertyNamePropertyToken)token).PropertyName); } private static void AssertIsIndexerPropertyToken(MvxPropertyToken token, T value) { - Assert.IsType>(token); - Assert.IsType(token); + Assert.IsAssignableFrom>(token); + Assert.IsAssignableFrom(token); Assert.Equal(value, ((MvxIndexerPropertyToken)token).Key); } diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Mocks/Dispatchers/NavigationMockDispatcher.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Mocks/Dispatchers/NavigationMockDispatcher.cs index 876416425..8a6770335 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Mocks/Dispatchers/NavigationMockDispatcher.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Mocks/Dispatchers/NavigationMockDispatcher.cs @@ -9,11 +9,12 @@ using System.Linq; using MvvmCross.Core.ViewModels; using MvvmCross.Core.Views; using MvvmCross.Platform.Core; +using MvvmCross.Platform.Logging; namespace MvvmCross.Test.Mocks.Dispatchers { public class NavigationMockDispatcher - : MvxMainThreadDispatcher, IMvxViewDispatcher + : IMvxMainThreadDispatcher, IMvxViewDispatcher { public readonly List Requests = new List(); public readonly List Hints = new List(); @@ -32,7 +33,7 @@ namespace MvvmCross.Test.Mocks.Dispatchers debugString += $"with parameters: {string.Join(",", request.ParameterValues.Select(pair => $"{{ {pair.Key}={pair.Value} }}"))}"; else debugString += "without parameters"; - Debug.WriteLine(debugString); + MvxTestLog.Instance.Log(MvxLogLevel.Debug, () => debugString); Requests.Add(request); return true; diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Navigation/NavigationServiceTests.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Navigation/NavigationServiceTests.cs index ae6fc0a08..3037a26b4 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Navigation/NavigationServiceTests.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Navigation/NavigationServiceTests.cs @@ -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. @@ -16,13 +16,13 @@ namespace MvvmCross.Test.Navigation { [Collection("MvxTest")] public class NavigationServiceTests - : IClassFixture { private readonly MvxTestFixture _fixture; public NavigationServiceTests(MvxTestFixture fixture) { _fixture = fixture; + _fixture.ClearAll(); AdditionalSetup(fixture); } diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Navigation/RoutingServiceTests.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Navigation/RoutingServiceTests.cs index 85a6934df..a204d715e 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Navigation/RoutingServiceTests.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Navigation/RoutingServiceTests.cs @@ -26,7 +26,6 @@ namespace MvvmCross.Test.Navigation { [Collection("MvxTest")] public class RoutingServiceTests - : IClassFixture { protected Mock MockDispatcher; protected IMvxNavigationService RoutingService; @@ -35,6 +34,7 @@ namespace MvvmCross.Test.Navigation public RoutingServiceTests(MvxTestFixture fixture) { _fixture = fixture; + _fixture.ClearAll(); MvxNavigationService.LoadRoutes(new[] { typeof(RoutingServiceTests).Assembly }); // ReSharper disable once AssignNullToNotNullAttribute diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Parse/MvxStringDictionaryTextSerializerTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Parse/MvxStringDictionaryTextSerializerTest.cs index ae632fec3..c79b97957 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Parse/MvxStringDictionaryTextSerializerTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Parse/MvxStringDictionaryTextSerializerTest.cs @@ -13,7 +13,6 @@ namespace MvvmCross.Test.Parse { [Collection("MvxTest")] public class MvxStringDictionaryTextSerializerTest - : IClassFixture { private readonly MvxTestFixture _fixture; diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxSimplePropertyDictionaryExtensionMethodsTests.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxSimplePropertyDictionaryExtensionMethodsTests.cs index e90ffb6a5..bd9b2b78a 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxSimplePropertyDictionaryExtensionMethodsTests.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxSimplePropertyDictionaryExtensionMethodsTests.cs @@ -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. @@ -9,7 +9,7 @@ using Xunit; namespace MvvmCross.Test.Platform { [Collection("MvxTest")] - public class MvxSimplePropertyDictionaryExtensionMethodsTests : IClassFixture + public class MvxSimplePropertyDictionaryExtensionMethodsTests { private readonly MvxTestFixture _fixture; diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxStringToTypeParserTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxStringToTypeParserTest.cs index 6a476edf5..12271a238 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxStringToTypeParserTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxStringToTypeParserTest.cs @@ -10,13 +10,14 @@ using Xunit; namespace MvvmCross.Test.Platform { [Collection("MvxTest")] - public class MvxStringToTypeParserTest : IClassFixture + public class MvxStringToTypeParserTest { private readonly MvxTestFixture _fixture; public MvxStringToTypeParserTest(MvxTestFixture fixture) { _fixture = fixture; + _fixture.ClearAll(); _fixture.SetInvariantCulture(); } diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelByNameLookupTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelByNameLookupTest.cs index cbdae1abc..ca0d72388 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelByNameLookupTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelByNameLookupTest.cs @@ -10,7 +10,7 @@ using Xunit; namespace MvvmCross.Test.Platform { [Collection("MvxTest")] - public class MvxViewModelByNameLookupTest : IClassFixture + public class MvxViewModelByNameLookupTest { private readonly MvxTestFixture _fixture; diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelViewLookupBuilderTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelViewLookupBuilderTest.cs index f101783d6..75cb2fc83 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelViewLookupBuilderTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelViewLookupBuilderTest.cs @@ -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. @@ -10,7 +10,7 @@ using Xunit; namespace MvvmCross.Test.Platform { [Collection("MvxTest")] - public class MvxViewModelViewLookupBuilderTest : IClassFixture + public class MvxViewModelViewLookupBuilderTest { private readonly MvxTestFixture _fixture; diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelViewTypeFinderTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelViewTypeFinderTest.cs index cec275b1a..c4729973f 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelViewTypeFinderTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelViewTypeFinderTest.cs @@ -10,7 +10,7 @@ using Xunit; namespace MvvmCross.Test.Platform { [Collection("MvxTest")] - public class MvxViewModelViewTypeFinderTest : IClassFixture + public class MvxViewModelViewTypeFinderTest { private readonly MvxTestFixture _fixture; diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxBundleTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxBundleTest.cs index 18acea97f..cdbb9289c 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxBundleTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxBundleTest.cs @@ -12,7 +12,7 @@ using Xunit; namespace MvvmCross.Test.ViewModels { [Collection("MvxTest")] - public class MvxBundleTest : IClassFixture + public class MvxBundleTest { private readonly MvxTestFixture _fixture; diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxCommandCollectionTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxCommandCollectionTest.cs index 6a91187a9..4bd2a770d 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxCommandCollectionTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxCommandCollectionTest.cs @@ -12,7 +12,7 @@ using Xunit; namespace MvvmCross.Test.ViewModels { [Collection("MvxTest")] - public class MvxCommandCollectionTest : IClassFixture + public class MvxCommandCollectionTest { private MvxTestFixture _fixture; diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxDefaultViewModelLocatorTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxDefaultViewModelLocatorTest.cs index d83b00cff..9d0b81981 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxDefaultViewModelLocatorTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxDefaultViewModelLocatorTest.cs @@ -12,7 +12,7 @@ using Xunit; namespace MvvmCross.Test.ViewModels { [Collection("MvxTest")] - public class MvxDefaultViewModelLocatorTest : IClassFixture + public class MvxDefaultViewModelLocatorTest { private readonly MvxTestFixture _fixture; diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxNotifyPropertyChangedTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxNotifyPropertyChangedTest.cs index a86001218..443d160fe 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxNotifyPropertyChangedTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxNotifyPropertyChangedTest.cs @@ -12,8 +12,8 @@ using Xunit; namespace MvvmCross.Test.ViewModels { - - public class MvxNotifyPropertyChangedTest : IClassFixture + [Collection("MvxTest")] + public class MvxNotifyPropertyChangedTest { private readonly MvxTestFixture _fixture; diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxSaveStateTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxSaveStateTest.cs index 7ea31ac45..63051dae1 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxSaveStateTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxSaveStateTest.cs @@ -12,7 +12,7 @@ using Xunit; namespace MvvmCross.Test.ViewModels { [Collection("MvxTest")] - public class MvxSaveStateTest : IClassFixture + public class MvxSaveStateTest { private readonly MvxTestFixture _fixture; diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxViewModelLoaderTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxViewModelLoaderTest.cs index c77bfbe6c..17be83a8d 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxViewModelLoaderTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxViewModelLoaderTest.cs @@ -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. @@ -13,7 +13,7 @@ using Xunit; namespace MvvmCross.Test.ViewModels { [Collection("MvxTest")] - public class MvxViewModelLoaderTest : IClassFixture + public class MvxViewModelLoaderTest { private readonly MvxTestFixture _fixture; diff --git a/MvvmCross.Tests/Plugins.JsonLocalization.UnitTest/MvxDictionaryTextProviderTest.cs b/MvvmCross.Tests/Plugins.JsonLocalization.UnitTest/MvxDictionaryTextProviderTest.cs index 870b27fe0..761e17bd0 100644 --- a/MvvmCross.Tests/Plugins.JsonLocalization.UnitTest/MvxDictionaryTextProviderTest.cs +++ b/MvvmCross.Tests/Plugins.JsonLocalization.UnitTest/MvxDictionaryTextProviderTest.cs @@ -4,13 +4,20 @@ using System.Collections.Generic; using MvvmCross.Plugins.JsonLocalization.Tests.Mocks; +using MvvmCross.Test; using Xunit; namespace MvvmCross.Plugins.JsonLocalization.Tests { - - public class MvxDictionaryTextProviderTest + public class MvxDictionaryTextProviderTest : IClassFixture { + private readonly MvxTestFixture _fixture; + + public MvxDictionaryTextProviderTest(MvxTestFixture fixture) + { + _fixture = fixture; + } + [Fact] public void GetTextWithExistingValueReturnsTheValueWhenMaskingErrors() { diff --git a/MvvmCross.Tests/Plugins.Messenger.UnitTest/MessengerHubTest.cs b/MvvmCross.Tests/Plugins.Messenger.UnitTest/MessengerHubTest.cs index 7a0f39979..7f51c9760 100644 --- a/MvvmCross.Tests/Plugins.Messenger.UnitTest/MessengerHubTest.cs +++ b/MvvmCross.Tests/Plugins.Messenger.UnitTest/MessengerHubTest.cs @@ -5,13 +5,20 @@ using System; using System.Linq; using System.Threading; +using MvvmCross.Test; using Xunit; namespace MvvmCross.Plugins.Messenger.Test { - - public class MessengerHubTest + public class MessengerHubTest : IClassFixture { + private readonly MvxTestFixture _fixture; + + public MessengerHubTest(MvxTestFixture fixture) + { + _fixture = fixture; + } + #region TestClasses private class TestMessage : MvxMessage @@ -32,10 +39,6 @@ namespace MvvmCross.Plugins.Messenger.Test #endregion TestClasses - - public void SetUp() - { - } [Fact] public void SubscribeAndPublishAllowsMessageToBeReceived()