diff --git a/MvvmCross.Tests/MvvmCross.Test/MvxIoCSupportingTest.cs b/MvvmCross.Tests/MvvmCross.Test/MvxIoCSupportingTest.cs index 74d66d996..c88fa7942 100644 --- a/MvvmCross.Tests/MvvmCross.Test/MvxIoCSupportingTest.cs +++ b/MvvmCross.Tests/MvvmCross.Test/MvxIoCSupportingTest.cs @@ -2,11 +2,14 @@ // 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; using System.Globalization; using MvvmCross.Core; using MvvmCross.Core.Platform; using MvvmCross.Platform.Core; using MvvmCross.Platform.IoC; +using MvvmCross.Platform.Logging; +using MvvmCross.Platform.Logging.LogProviders; namespace MvvmCross.Test { @@ -29,7 +32,7 @@ namespace MvvmCross.Test return null; } - protected virtual void ClearAll() + public virtual void ClearAll() { // fake set up of the IoC Reset(); @@ -38,9 +41,10 @@ namespace MvvmCross.Test InitializeSingletonCache(); InitializeMvxSettings(); AdditionalSetup(); + Ioc.RegisterSingleton(new ConsoleLogProvider()); } - private static void InitializeSingletonCache() + public void InitializeSingletonCache() { MvxSingletonCache.Initialize(); } @@ -55,7 +59,7 @@ namespace MvvmCross.Test // nothing here.. } - protected void SetInvariantCulture() + public void SetInvariantCulture() { var invariantCulture = CultureInfo.InvariantCulture; CultureInfo.DefaultThreadCurrentCulture = invariantCulture; diff --git a/MvvmCross.Tests/MvvmCross.Test/MvxTestLog.cs b/MvvmCross.Tests/MvvmCross.Test/MvxTestLog.cs index 39e9cca8f..a01a6498a 100644 --- a/MvvmCross.Tests/MvvmCross.Test/MvxTestLog.cs +++ b/MvvmCross.Tests/MvvmCross.Test/MvxTestLog.cs @@ -5,12 +5,15 @@ // // Project Lead - Stuart Lodge, @slodge, me@slodge.com +using System.Runtime.CompilerServices; using MvvmCross.Platform; using MvvmCross.Platform.Logging; +[assembly: InternalsVisibleTo("MvvmCross.UnitTest")] + namespace MvvmCross { - public static class MvxTestLog + internal static class MvxTestLog { internal static IMvxLog Instance { get; } = Mvx.Resolve().GetLogFor("MvxTest"); } diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Base/Converters/MvxDictionaryValueConverterTests.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Base/Converters/MvxDictionaryValueConverterTests.cs index 7ee43fa44..a236d59b2 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Base/Converters/MvxDictionaryValueConverterTests.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Base/Converters/MvxDictionaryValueConverterTests.cs @@ -10,7 +10,6 @@ using System.Globalization; namespace MvvmCross.Platform.Test.Converters { - public class MvxDictionaryValueConverterTests : MvxDictionaryValueConverter { private Dictionary _testStatedictionary; @@ -26,8 +25,7 @@ namespace MvvmCross.Platform.Test.Converters Failed } - - public void Init() + public MvxDictionaryValueConverterTests() { _testStatedictionary = new Dictionary { @@ -36,18 +34,22 @@ namespace MvvmCross.Platform.Test.Converters }; } + [Theory] [InlineData(TestStates.Running, StateRunning)] [InlineData(TestStates.Completed, StateCompleted)] - public string Convert_MatchingKeyIncludeFallback_ReturnsDictionaryValue(TestStates state) + public void Convert_MatchingKeyIncludeFallback_ReturnsDictionaryValue(TestStates state, string expected) { - return Convert(state, null, new Tuple, string, bool>(_testStatedictionary, Fallback, true), CultureInfo.CurrentUICulture); + var converted = Convert(state, null, new Tuple, string, bool>(_testStatedictionary, Fallback, true), CultureInfo.CurrentUICulture); + Assert.Equal(expected, converted); } + [Theory] [InlineData(TestStates.Running, StateRunning)] [InlineData(TestStates.Completed, StateCompleted)] - public string Convert_MatchingKeyExcludeFallback_ReturnsDictionaryValue(TestStates state) + public void Convert_MatchingKeyExcludeFallback_ReturnsDictionaryValue(TestStates state, string expected) { - return Convert(state, null, new Tuple, string, bool>(_testStatedictionary, default(string), false), CultureInfo.CurrentUICulture); + var converted = Convert(state, null, new Tuple, string, bool>(_testStatedictionary, default(string), false), CultureInfo.CurrentUICulture); + Assert.Equal(expected, converted); } [Fact] diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Base/MvxIoCPropertyInjectionTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Base/MvxIoCPropertyInjectionTest.cs index 3b901eb17..c844370ce 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Base/MvxIoCPropertyInjectionTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Base/MvxIoCPropertyInjectionTest.cs @@ -60,14 +60,14 @@ namespace MvvmCross.Platform.Test IA a; var result = Mvx.TryResolve(out a); - Assert.IsTrue(result); - Assert.IsNotNull(a); - Assert.IsInstanceOf(a); + Assert.True(result); + Assert.NotNull(a); + Assert.IsType(a); var castA = (A)a; - Assert.IsNull(castA.B); - Assert.IsNull(castA.C); - Assert.IsNull(castA.BNever); - Assert.IsNull(castA.CNever); + Assert.Null(castA.B); + Assert.Null(castA.C); + Assert.Null(castA.BNever); + Assert.Null(castA.CNever); } [Fact] @@ -89,15 +89,15 @@ namespace MvvmCross.Platform.Test IA a; var result = Mvx.TryResolve(out a); - Assert.IsTrue(result); - Assert.IsNotNull(a); - Assert.IsInstanceOf(a); + Assert.True(result); + Assert.NotNull(a); + Assert.IsType(a); var castA = (A)a; - Assert.IsNotNull(castA.B); - Assert.IsInstanceOf(castA.B); - Assert.IsNull(castA.C); - Assert.IsNull(castA.BNever); - Assert.IsNull(castA.CNever); + Assert.NotNull(castA.B); + Assert.IsType(castA.B); + Assert.Null(castA.C); + Assert.Null(castA.BNever); + Assert.Null(castA.CNever); } [Fact] @@ -119,16 +119,16 @@ namespace MvvmCross.Platform.Test IA a; var result = Mvx.TryResolve(out a); - Assert.IsTrue(result); - Assert.IsNotNull(a); - Assert.IsInstanceOf(a); + Assert.True(result); + Assert.NotNull(a); + Assert.IsType(a); var castA = (A)a; - Assert.IsNotNull(castA.B); - Assert.IsInstanceOf(castA.B); - Assert.IsNotNull(castA.C); - Assert.IsInstanceOf(castA.C); - Assert.IsNull(castA.BNever); - Assert.IsNull(castA.CNever); + Assert.NotNull(castA.B); + Assert.IsType(castA.B); + Assert.NotNull(castA.C); + Assert.IsType(castA.C); + Assert.Null(castA.BNever); + Assert.Null(castA.CNever); } } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Base/MvxIoCTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Base/MvxIoCTest.cs index b3f4731a6..9a75e2d51 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Base/MvxIoCTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Base/MvxIoCTest.cs @@ -125,8 +125,8 @@ namespace MvvmCross.Platform.Test IA a; var result = Mvx.TryResolve(out a); - Assert.IsTrue(result); - Assert.IsNotNull(a); + Assert.True(result); + Assert.NotNull(a); } [Fact] @@ -142,8 +142,8 @@ namespace MvvmCross.Platform.Test IA a; var result = Mvx.TryResolve(out a); - Assert.IsFalse(result); - Assert.IsNull(a); + Assert.False(result); + Assert.Null(a); } [Fact] @@ -158,8 +158,8 @@ namespace MvvmCross.Platform.Test IA a; var result = Mvx.TryResolve(out a); - Assert.IsFalse(result); - Assert.IsNull(a); + Assert.False(result); + Assert.Null(a); } [Fact] @@ -174,8 +174,8 @@ namespace MvvmCross.Platform.Test IA a; var result = Mvx.TryResolve(out a); - Assert.IsTrue(result); - Assert.IsNotNull(a); + Assert.True(result); + Assert.NotNull(a); } [Fact] @@ -190,15 +190,15 @@ namespace MvvmCross.Platform.Test IA a0; var result = Mvx.TryResolve(out a0); - Assert.IsTrue(result); - Assert.IsNotNull(a0); + Assert.True(result); + Assert.NotNull(a0); for (int i = 0; i < 100; i++) { IA a1; result = Mvx.TryResolve(out a1); - Assert.IsTrue(result); - Assert.AreSame(a0, a1); + Assert.True(result); + Assert.Equal(a0, a1); } } @@ -214,15 +214,15 @@ namespace MvvmCross.Platform.Test IA a0; var result = Mvx.TryResolve(out a0); - Assert.IsTrue(result); - Assert.IsNotNull(a0); + Assert.True(result); + Assert.NotNull(a0); for (int i = 0; i < 100; i++) { IA a1; result = Mvx.TryResolve(out a1); - Assert.IsTrue(result); - Assert.AreSame(a0, a1); + Assert.True(result); + Assert.Equal(a0, a1); } } @@ -242,8 +242,8 @@ namespace MvvmCross.Platform.Test { IA a1; var result = Mvx.TryResolve(out a1); - Assert.IsTrue(result); - Assert.IsFalse(previous.ContainsKey(a1)); + Assert.True(result); + Assert.False(previous.ContainsKey(a1)); Assert.Equal(i, previous.Count); previous.Add(a1, true); } @@ -261,10 +261,10 @@ namespace MvvmCross.Platform.Test IA a1; var result = Mvx.TryResolve(out a1); - Assert.IsTrue(result); - Assert.IsNotNull(a1); - Assert.IsNotNull(a1.B); - Assert.IsInstanceOf(a1.B); + Assert.True(result); + Assert.NotNull(a1); + Assert.NotNull(a1.B); + Assert.IsType(a1.B); } [Fact] @@ -278,10 +278,10 @@ namespace MvvmCross.Platform.Test var c1 = Mvx.Resolve(); var c2 = Mvx.Resolve(); - Assert.IsNotNull(c1); - Assert.IsNotNull(c2); + Assert.NotNull(c1); + Assert.NotNull(c2); - Assert.AreNotEqual(c1, c2); + Assert.NotEqual(c1, c2); } [Fact] @@ -295,10 +295,10 @@ namespace MvvmCross.Platform.Test var c1 = Mvx.Resolve(); var c2 = Mvx.Resolve(); - Assert.IsNotNull(c1); - Assert.IsNotNull(c2); + Assert.NotNull(c1); + Assert.NotNull(c2); - Assert.AreNotEqual(c1, c2); + Assert.NotEqual(c1, c2); } [Fact] @@ -340,9 +340,9 @@ namespace MvvmCross.Platform.Test IOG toResolve = null; Mvx.TryResolve>(out toResolve); - Assert.IsNotNull(toResolve); - Assert.IsTrue(toResolve.GetType().GetTypeInfo().ImplementedInterfaces.Any(i => i == typeof(IOG))); - Assert.IsTrue(toResolve.GetType() == typeof(OG)); + Assert.NotNull(toResolve); + Assert.True(toResolve.GetType().GetTypeInfo().ImplementedInterfaces.Any(i => i == typeof(IOG))); + Assert.True(toResolve.GetType() == typeof(OG)); } [Fact] @@ -356,9 +356,9 @@ namespace MvvmCross.Platform.Test IOG toResolve = null; Mvx.TryResolve>(out toResolve); - Assert.IsNotNull(toResolve); - Assert.IsTrue(toResolve.GetType().GetTypeInfo().ImplementedInterfaces.Any(i => i == typeof(IOG))); - Assert.IsTrue(toResolve.GetType() == typeof(OG)); + Assert.NotNull(toResolve); + Assert.True(toResolve.GetType().GetTypeInfo().ImplementedInterfaces.Any(i => i == typeof(IOG))); + Assert.True(toResolve.GetType() == typeof(OG)); } [Fact] @@ -372,9 +372,9 @@ namespace MvvmCross.Platform.Test IOG2 toResolve = null; Mvx.TryResolve>(out toResolve); - Assert.IsNotNull(toResolve); - Assert.IsTrue(toResolve.GetType().GetTypeInfo().ImplementedInterfaces.Any(i => i == typeof(IOG2))); - Assert.IsTrue(toResolve.GetType() == typeof(OG2)); + Assert.NotNull(toResolve); + Assert.True(toResolve.GetType().GetTypeInfo().ImplementedInterfaces.Any(i => i == typeof(IOG2))); + Assert.True(toResolve.GetType() == typeof(OG2)); } [Fact] @@ -388,9 +388,9 @@ namespace MvvmCross.Platform.Test IOG2 toResolve = null; Mvx.TryResolve>(out toResolve); - Assert.IsNotNull(toResolve); - Assert.IsTrue(toResolve.GetType().GetTypeInfo().ImplementedInterfaces.Any(i => i == typeof(IOG2))); - Assert.IsTrue(toResolve.GetType() == typeof(OG2)); + Assert.NotNull(toResolve); + Assert.True(toResolve.GetType().GetTypeInfo().ImplementedInterfaces.Any(i => i == typeof(IOG2))); + Assert.True(toResolve.GetType() == typeof(OG2)); } [Fact] @@ -403,8 +403,8 @@ namespace MvvmCross.Platform.Test var isResolved = Mvx.TryResolve>(out toResolve); - Assert.IsFalse(isResolved); - Assert.IsNull(toResolve); + Assert.False(isResolved); + Assert.Null(toResolve); } [Fact] @@ -419,11 +419,11 @@ namespace MvvmCross.Platform.Test IHasOGParameter toResolve = null; Mvx.TryResolve(out toResolve); - Assert.IsNotNull(toResolve); - Assert.IsTrue(toResolve.GetType().GetTypeInfo().ImplementedInterfaces.Any(i => i == typeof(IHasOGParameter))); - Assert.IsTrue(toResolve.GetType() == typeof(HasOGParameter)); - Assert.IsTrue(toResolve.OpenGeneric.GetType().GetTypeInfo().ImplementedInterfaces.Any(i => i == typeof(IOG))); - Assert.IsTrue(toResolve.OpenGeneric.GetType() == typeof(OG)); + Assert.NotNull(toResolve); + Assert.True(toResolve.GetType().GetTypeInfo().ImplementedInterfaces.Any(i => i == typeof(IHasOGParameter))); + Assert.True(toResolve.GetType() == typeof(HasOGParameter)); + Assert.True(toResolve.OpenGeneric.GetType().GetTypeInfo().ImplementedInterfaces.Any(i => i == typeof(IOG))); + Assert.True(toResolve.OpenGeneric.GetType() == typeof(OG)); } #endregion @@ -442,17 +442,17 @@ namespace MvvmCross.Platform.Test var b = childContainer.Create(); - Assert.IsTrue(container.CanResolve()); - Assert.IsFalse(container.CanResolve()); - Assert.IsTrue(childContainer.CanResolve()); - Assert.IsTrue(childContainer.CanResolve()); + Assert.True(container.CanResolve()); + Assert.False(container.CanResolve()); + Assert.True(childContainer.CanResolve()); + Assert.True(childContainer.CanResolve()); - Assert.IsNotNull(b); - Assert.IsNotNull(b.C); + Assert.NotNull(b); + Assert.NotNull(b.C); } #endregion // TODO - there are so many tests we could and should do here! } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Base/MvxParserTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Base/MvxParserTest.cs index cd33c4576..5d2b14863 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Base/MvxParserTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Base/MvxParserTest.cs @@ -106,7 +106,7 @@ namespace MvvmCross.Platform.Test public void Test_Reset_Clears_And_Sets_All_Properties() { var tokeniser = new Parser(); - Assert.IsNull(tokeniser.GetFullText()); + Assert.Null(tokeniser.GetFullText()); Assert.Equal(0, tokeniser.GetCurrentIndex()); var testString1 = @"1 test"; tokeniser.CallReset(testString1); @@ -141,7 +141,7 @@ namespace MvvmCross.Platform.Test tokeniser.CallReset(testString.Key); var result = tokeniser.CallReadQuotedString(); Assert.Equal(testString.Value, result); - Assert.IsTrue(tokeniser.GetIsComplete()); + Assert.True(tokeniser.GetIsComplete()); } } @@ -162,7 +162,7 @@ namespace MvvmCross.Platform.Test tokeniser.CallReset(testString.Key); var result = tokeniser.CallReadUnsignedInteger(); Assert.Equal(testString.Value, result); - Assert.IsTrue(tokeniser.GetIsComplete()); + Assert.True(tokeniser.GetIsComplete()); } } @@ -191,7 +191,7 @@ namespace MvvmCross.Platform.Test parser.CallReset(input); var output = parser.CallReadValue(); Assert.Equal(expectedOutput, output); - Assert.IsTrue(parser.GetIsComplete()); + Assert.True(parser.GetIsComplete()); } [Fact] @@ -254,7 +254,7 @@ namespace MvvmCross.Platform.Test parser.CallReset(input); var output = parser.CallReadEnumerationValue(enumerationType, true /* ignoreCase */); Assert.Equal(expectedOutput, output); - Assert.IsTrue(parser.GetIsComplete()); + Assert.True(parser.GetIsComplete()); } [Fact] @@ -291,13 +291,13 @@ namespace MvvmCross.Platform.Test parser.CallReset(name); var result = parser.CallReadValidCSharpName(); Assert.Equal(name, result); - Assert.IsTrue(parser.GetIsComplete()); + Assert.True(parser.GetIsComplete()); var parser2 = new Parser(); parser2.CallReset("\t " + name + " \r \t"); var result2 = parser2.CallReadValidCSharpName(); Assert.Equal(name, result2); - Assert.IsFalse(parser2.GetIsComplete()); + Assert.False(parser2.GetIsComplete()); } } @@ -325,7 +325,7 @@ namespace MvvmCross.Platform.Test { exceptionThrown = true; } - Assert.IsTrue(exceptionThrown); + Assert.True(exceptionThrown); } } } diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Base/ReflectionExtensionsTests.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Base/ReflectionExtensionsTests.cs index 3f8ef6a3f..c24c6224a 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Base/ReflectionExtensionsTests.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Base/ReflectionExtensionsTests.cs @@ -97,7 +97,7 @@ namespace MvvmCross.Platform.Test var field = typeof(TestClass).GetField("PublicStaticField", BindingFlags.Public | BindingFlags.Static); // Assert - Assert.IsNotNull(field); + Assert.NotNull(field); } [Fact] @@ -107,7 +107,7 @@ namespace MvvmCross.Platform.Test var field = typeof(TestClass).GetField("PublicStaticField", BindingFlags.Public | BindingFlags.Instance); // Assert - Assert.IsNull(field); + Assert.Null(field); } [Fact] @@ -117,7 +117,7 @@ namespace MvvmCross.Platform.Test var field = typeof(TestClass).GetField("PublicInstanceField1", BindingFlags.Public | BindingFlags.Instance); // Assert - Assert.IsNotNull(field); + Assert.NotNull(field); } [Fact] @@ -127,7 +127,7 @@ namespace MvvmCross.Platform.Test var field = typeof(TestClass).GetField("PublicInstanceField1", BindingFlags.Public | BindingFlags.Static); // Assert - Assert.IsNull(field); + Assert.Null(field); } [Fact] diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Base/UI/MvxColorTests.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Base/UI/MvxColorTests.cs index fa56ba6ec..3af79007d 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Base/UI/MvxColorTests.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Base/UI/MvxColorTests.cs @@ -27,10 +27,10 @@ namespace MvvmCross.Platform.Test.UI for (var i = 0; i < tests.GetUpperBound(0); i++) { var c = new MvxColor((int)tests[i, 0]); - Assert.Equal(tests[i, 1], c.A); - Assert.Equal(tests[i, 2], c.R); - Assert.Equal(tests[i, 3], c.G); - Assert.Equal(tests[i, 4], c.B); + Assert.Equal(tests[i, 1], (uint)c.A); + Assert.Equal(tests[i, 2], (uint)c.R); + Assert.Equal(tests[i, 3], (uint)c.G); + Assert.Equal(tests[i, 4], (uint)c.B); Assert.Equal(tests[i, 0], (uint)c.ARGB); } } @@ -54,10 +54,10 @@ namespace MvvmCross.Platform.Test.UI for (uint alpha = 0; alpha < 256; alpha++) { var c = new MvxColor((int)tests[i, 0], (int)alpha); - Assert.Equal(alpha, c.A); - Assert.Equal(tests[i, 1], c.R); - Assert.Equal(tests[i, 2], c.G); - Assert.Equal(tests[i, 3], c.B); + Assert.Equal(alpha, (uint)c.A); + Assert.Equal(tests[i, 1], (uint)c.R); + Assert.Equal(tests[i, 2], (uint)c.G); + Assert.Equal(tests[i, 3], (uint)c.B); var argb = (tests[i, 0] & 0x00FFFFFF) | ((alpha & 0xFF) << 24); Assert.Equal(argb, (uint)c.ARGB); } @@ -81,10 +81,10 @@ namespace MvvmCross.Platform.Test.UI for (var i = 0; i < tests.GetUpperBound(0); i++) { var c = new MvxColor((int)tests[i, 1], (int)tests[i, 2], (int)tests[i, 3], (int)tests[i, 0]); - Assert.Equal(tests[i, 0], c.A); - Assert.Equal(tests[i, 1], c.R); - Assert.Equal(tests[i, 2], c.G); - Assert.Equal(tests[i, 3], c.B); + Assert.Equal(tests[i, 0], (uint)c.A); + Assert.Equal(tests[i, 1], (uint)c.R); + Assert.Equal(tests[i, 2], (uint)c.G); + Assert.Equal(tests[i, 3], (uint)c.B); var argb = tests[i, 0] & 0xFF; argb <<= 8; argb |= tests[i, 1] & 0xFF; @@ -118,9 +118,9 @@ namespace MvvmCross.Platform.Test.UI c.A = j; Assert.Equal(j, c.A); - Assert.Equal(tests[i, 1], c.R); - Assert.Equal(tests[i, 2], c.G); - Assert.Equal(tests[i, 3], c.B); + Assert.Equal(tests[i, 1], (uint)c.R); + Assert.Equal(tests[i, 2], (uint)c.G); + Assert.Equal(tests[i, 3], (uint)c.B); var argb = (uint)j & 0xFF; argb <<= 8; argb |= tests[i, 1] & 0xFF; @@ -154,10 +154,10 @@ namespace MvvmCross.Platform.Test.UI { c.R = j; - Assert.Equal(tests[i, 0], c.A); + Assert.Equal(tests[i, 0], (uint)c.A); Assert.Equal(j, c.R); - Assert.Equal(tests[i, 2], c.G); - Assert.Equal(tests[i, 3], c.B); + Assert.Equal(tests[i, 2], (uint)c.G); + Assert.Equal(tests[i, 3], (uint)c.B); var argb = tests[i, 0] & 0xFF; argb <<= 8; argb |= (uint)j & 0xFF; @@ -191,10 +191,10 @@ namespace MvvmCross.Platform.Test.UI { c.G = j; - Assert.Equal(tests[i, 0], c.A); - Assert.Equal(tests[i, 1], c.R); + Assert.Equal(tests[i, 0], (uint)c.A); + Assert.Equal(tests[i, 1], (uint)c.R); Assert.Equal(j, c.G); - Assert.Equal(tests[i, 3], c.B); + Assert.Equal(tests[i, 3], (uint)c.B); var argb = tests[i, 0] & 0xFF; argb <<= 8; argb |= tests[i, 1] & 0xFF; @@ -228,9 +228,9 @@ namespace MvvmCross.Platform.Test.UI { c.B = j; - Assert.Equal(tests[i, 0], c.A); - Assert.Equal(tests[i, 1], c.R); - Assert.Equal(tests[i, 2], c.G); + Assert.Equal(tests[i, 0], (uint)c.A); + Assert.Equal(tests[i, 1], (uint)c.R); + Assert.Equal(tests[i, 2], (uint)c.G); Assert.Equal(j, c.B); var argb = tests[i, 0] & 0xFF; argb <<= 8; @@ -244,4 +244,4 @@ namespace MvvmCross.Platform.Test.UI } } } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Binders/MvxSourceStepTests.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Binders/MvxSourceStepTests.cs index 05fbfb604..44862fa40 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Binders/MvxSourceStepTests.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Binders/MvxSourceStepTests.cs @@ -14,14 +14,21 @@ using MvvmCross.Binding.Bindings.SourceSteps; using MvvmCross.Binding.Combiners; using MvvmCross.Binding.Parse.PropertyPath; using MvvmCross.Platform.Converters; -using MvvmCross.Test.Core; +using MvvmCross.Test; using Xunit; namespace MvvmCross.Binding.Test.Binders { - - public class MvxSourceStepTests : MvxIoCSupportingTest + [Collection("MvxTest")] + public class MvxSourceStepTests : IClassFixture { + private readonly MvxTestFixture _fixture; + + public MvxSourceStepTests(MvxTestFixture fixture) + { + _fixture = fixture; + } + public class BaseSource : INotifyPropertyChanged { public int SubscriptionCount { get; private set; } @@ -186,12 +193,6 @@ namespace MvvmCross.Binding.Test.Binders } } - [OneTimeSetUp] - public void FixtureSetUp() - { - SetInvariantCulture(); - } - private IMvxSourceStep SetupSimpleBindingTest(BaseSource source, string sourceProperty) { var realSourceStepFactory = SetupSourceStepFactory(); @@ -208,17 +209,17 @@ namespace MvvmCross.Binding.Test.Binders private MvxSourceStepFactory SetupSourceStepFactory() { - ClearAll(); - MvxBindingSingletonCache.Initialize(); + _fixture.Reset(); + _fixture.InitializeSingletonCache(); var autoValueConverters = new MvxAutoValueConverters(); - Ioc.RegisterSingleton(autoValueConverters); + _fixture.Ioc.RegisterSingleton(autoValueConverters); var sourcePropertyParser = new MvxSourcePropertyPathParser(); - Ioc.RegisterSingleton(sourcePropertyParser); + _fixture.Ioc.RegisterSingleton(sourcePropertyParser); var realSourceBindingFactory = new MvxSourceBindingFactory(); - Ioc.RegisterSingleton(realSourceBindingFactory); + _fixture.Ioc.RegisterSingleton(realSourceBindingFactory); var sourceStepFactory = new MvxSourceStepFactory(); sourceStepFactory.AddOrOverwrite(typeof(MvxPathSourceStepDescription), new MvxPathSourceStepFactory()); @@ -226,7 +227,7 @@ namespace MvvmCross.Binding.Test.Binders new MvxLiteralSourceStepFactory()); sourceStepFactory.AddOrOverwrite(typeof(MvxCombinerSourceStepDescription), new MvxCombinerSourceStepFactory()); - Ioc.RegisterSingleton(sourceStepFactory); + _fixture.Ioc.RegisterSingleton(sourceStepFactory); var propertySource = new MvxPropertySourceBindingFactoryExtension(); realSourceBindingFactory.Extensions.Add(propertySource); @@ -559,7 +560,7 @@ namespace MvvmCross.Binding.Test.Binders sourceStep.DataContext = new MySource(); value = sourceStep.GetValue(); - Assert.Equal(null, value); + Assert.Null(value); source.Property1 = "Changed again 19"; @@ -815,4 +816,4 @@ namespace MvvmCross.Binding.Test.Binders Assert.Equal(MvxBindingConstant.UnsetValue, value); } } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingConstructionTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingConstructionTest.cs index c489e8452..f7f65f644 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingConstructionTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingConstructionTest.cs @@ -12,15 +12,22 @@ using MvvmCross.Binding.Bindings.Target; using MvvmCross.Binding.Bindings.Target.Construction; using MvvmCross.Platform.Converters; using MvvmCross.Platform.Core; -using MvvmCross.Test.Core; +using MvvmCross.Test; using MvvmCross.Test.Mocks.Dispatchers; using Xunit; namespace MvvmCross.Binding.Test.Bindings { - - public class MvxFullBindingConstructionTest : MvxIoCSupportingTest + [Collection("MvxTest")] + public class MvxFullBindingConstructionTest : IClassFixture { + private readonly MvxTestFixture _fixture; + + public MvxFullBindingConstructionTest(MvxTestFixture fixture) + { + _fixture = fixture; + } + public class MyBinding : MvxFullBinding { public MyBinding(MvxBindingRequest bindingRequest) @@ -73,19 +80,19 @@ namespace MvvmCross.Binding.Test.Bindings private void TestCommon(MvxBindingMode bindingMode, bool expectSourceBinding, bool expectTargetBinding) { - ClearAll(); - MvxBindingSingletonCache.Initialize(); - Ioc.RegisterSingleton(new InlineMockMainThreadDispatcher()); + _fixture.InitializeSingletonCache(); + _fixture.Reset(); + _fixture.Ioc.RegisterSingleton(new InlineMockMainThreadDispatcher()); var mockSourceBindingFactory = new Mock(); - Ioc.RegisterSingleton(mockSourceBindingFactory.Object); + _fixture.Ioc.RegisterSingleton(mockSourceBindingFactory.Object); var mockTargetBindingFactory = new Mock(); - Ioc.RegisterSingleton(mockTargetBindingFactory.Object); + _fixture.Ioc.RegisterSingleton(mockTargetBindingFactory.Object); var realSourceStepFactory = new MvxSourceStepFactory(); realSourceStepFactory.AddOrOverwrite(typeof(MvxPathSourceStepDescription), new MvxPathSourceStepFactory()); - Ioc.RegisterSingleton(realSourceStepFactory); + _fixture.Ioc.RegisterSingleton(realSourceStepFactory); var sourceText = "sourceText"; var targetName = "targetName"; @@ -134,4 +141,4 @@ namespace MvvmCross.Binding.Test.Bindings Times.Once()); } } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingTest.cs index b983dcb61..a12f195c0 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingTest.cs @@ -10,15 +10,22 @@ using MvvmCross.Binding.Bindings.Target; using MvvmCross.Binding.Bindings.Target.Construction; using MvvmCross.Binding.Test.Mocks; using MvvmCross.Platform.Core; -using MvvmCross.Test.Core; +using MvvmCross.Test; using MvvmCross.Test.Mocks.Dispatchers; using Xunit; namespace MvvmCross.Binding.Test.Bindings { - - public class MvxFullBindingTest : MvxIoCSupportingTest + [Collection("MvxTest")] + public class MvxFullBindingTest : IClassFixture { + private readonly MvxTestFixture _fixture; + + public MvxFullBindingTest(MvxTestFixture fixture) + { + _fixture = fixture; + } + [Fact] public void TestTwoWayEventSubscription() { @@ -320,19 +327,18 @@ namespace MvvmCross.Binding.Test.Bindings private MvxFullBinding TestSetupCommon(MvxBindingMode mvxBindingMode, MvxBindingMode defaultMode, out MockSourceBinding mockSource, out MockTargetBinding mockTarget) { - ClearAll(); - MvxBindingSingletonCache.Initialize(); - Ioc.RegisterSingleton(new InlineMockMainThreadDispatcher()); + _fixture.ClearAll(); + _fixture.Ioc.RegisterSingleton(new InlineMockMainThreadDispatcher()); var mockSourceBindingFactory = new Mock(); - Ioc.RegisterSingleton(mockSourceBindingFactory.Object); + _fixture.Ioc.RegisterSingleton(mockSourceBindingFactory.Object); var mockTargetBindingFactory = new Mock(); - Ioc.RegisterSingleton(mockTargetBindingFactory.Object); + _fixture.Ioc.RegisterSingleton(mockTargetBindingFactory.Object); var realSourceStepFactory = new MvxSourceStepFactory(); realSourceStepFactory.AddOrOverwrite(typeof(MvxPathSourceStepDescription), new MvxPathSourceStepFactory()); - Ioc.RegisterSingleton(realSourceStepFactory); + _fixture.Ioc.RegisterSingleton(realSourceStepFactory); var sourceText = "sourceText"; var targetName = "targetName"; @@ -373,4 +379,4 @@ namespace MvvmCross.Binding.Test.Bindings return toTest; } } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingValueConversionTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingValueConversionTest.cs index 2b860d287..97f7835aa 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingValueConversionTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Bindings/MvxFullBindingValueConversionTest.cs @@ -14,16 +14,23 @@ using MvvmCross.Binding.Bindings.Target.Construction; using MvvmCross.Binding.Test.Mocks; using MvvmCross.Platform.Converters; using MvvmCross.Platform.Core; -using MvvmCross.Test.Core; +using MvvmCross.Test; using MvvmCross.Test.Mocks.Dispatchers; using Xunit; namespace MvvmCross.Binding.Test.Bindings { - - public class MvxFullBindingValueConversionTest : MvxIoCSupportingTest + [Collection("MvxTest")] + public class MvxFullBindingValueConversionTest : IClassFixture { - [Fact] + private readonly MvxTestFixture _fixture; + + public MvxFullBindingValueConversionTest(MvxTestFixture fixture) + { + _fixture = fixture; + } + + [Fact] public void TestConverterIsUsedForConvert() { MockSourceBinding mockSource; @@ -206,7 +213,7 @@ namespace MvvmCross.Binding.Test.Bindings Assert.Equal(0, mockValueConverter.ConversionsBackRequested.Count); Assert.Equal(1, mockTarget.Values.Count); - Assert.Equal(null, mockTarget.Values[0]); + Assert.Null(mockTarget.Values[0]); mockSource.TryGetValueValue = "Fred"; mockSource.FireSourceChanged(); @@ -215,7 +222,7 @@ namespace MvvmCross.Binding.Test.Bindings Assert.Equal(0, mockValueConverter.ConversionsBackRequested.Count); Assert.Equal(2, mockTarget.Values.Count); - Assert.Equal(null, mockTarget.Values[1]); + Assert.Null(mockTarget.Values[1]); mockSource.TryGetValueValue = "Betty"; mockSource.FireSourceChanged(); @@ -224,7 +231,7 @@ namespace MvvmCross.Binding.Test.Bindings Assert.Equal(0, mockValueConverter.ConversionsBackRequested.Count); Assert.Equal(3, mockTarget.Values.Count); - Assert.Equal(null, mockTarget.Values[2]); + Assert.Null(mockTarget.Values[2]); } [Fact] @@ -282,7 +289,7 @@ namespace MvvmCross.Binding.Test.Bindings Assert.Equal(0, mockValueConverter.ConversionsBackRequested.Count); Assert.Equal(1, mockTarget.Values.Count); - Assert.Equal(null, mockTarget.Values[0]); + Assert.Null(mockTarget.Values[0]); mockSource.TryGetValueValue = "Fred"; mockSource.FireSourceChanged(); @@ -291,7 +298,7 @@ namespace MvvmCross.Binding.Test.Bindings Assert.Equal(0, mockValueConverter.ConversionsBackRequested.Count); Assert.Equal(2, mockTarget.Values.Count); - Assert.Equal(null, mockTarget.Values[1]); + Assert.Null(mockTarget.Values[1]); mockSource.TryGetValueValue = "Betty"; mockSource.FireSourceChanged(); @@ -300,7 +307,7 @@ namespace MvvmCross.Binding.Test.Bindings Assert.Equal(0, mockValueConverter.ConversionsBackRequested.Count); Assert.Equal(3, mockTarget.Values.Count); - Assert.Equal(null, mockTarget.Values[2]); + Assert.Null(mockTarget.Values[2]); } [Fact] @@ -329,7 +336,7 @@ namespace MvvmCross.Binding.Test.Bindings Assert.Equal(0, mockValueConverter.ConversionsBackRequested.Count); Assert.Equal(2, mockTarget.Values.Count); - Assert.Equal(null, mockTarget.Values[1]); + Assert.Null(mockTarget.Values[1]); mockSource.TryGetValueResult = false; mockSource.FireSourceChanged(); @@ -338,7 +345,7 @@ namespace MvvmCross.Binding.Test.Bindings Assert.Equal(0, mockValueConverter.ConversionsBackRequested.Count); Assert.Equal(3, mockTarget.Values.Count); - Assert.Equal(null, mockTarget.Values[2]); + Assert.Null(mockTarget.Values[2]); mockSource.TryGetValueValue = "Fred"; mockSource.TryGetValueResult = true; @@ -424,7 +431,7 @@ namespace MvvmCross.Binding.Test.Bindings Assert.Equal(0, mockValueConverter.ConversionsBackRequested.Count); Assert.Equal(2, mockTarget.Values.Count); - Assert.Equal(null, mockTarget.Values[1]); + Assert.Null(mockTarget.Values[1]); mockSource.TryGetValueResult = false; mockSource.FireSourceChanged(); @@ -433,7 +440,7 @@ namespace MvvmCross.Binding.Test.Bindings Assert.Equal(0, mockValueConverter.ConversionsBackRequested.Count); Assert.Equal(3, mockTarget.Values.Count); - Assert.Equal(null, mockTarget.Values[2]); + Assert.Null(mockTarget.Values[2]); mockSource.TryGetValueResult = false; mockSource.FireSourceChanged(); @@ -442,7 +449,7 @@ namespace MvvmCross.Binding.Test.Bindings Assert.Equal(0, mockValueConverter.ConversionsBackRequested.Count); Assert.Equal(4, mockTarget.Values.Count); - Assert.Equal(null, mockTarget.Values[3]); + Assert.Null(mockTarget.Values[3]); } private MvxFullBinding TestSetupCommon(IMvxValueConverter valueConverter, object converterParameter, @@ -454,19 +461,18 @@ namespace MvvmCross.Binding.Test.Bindings private MvxFullBinding TestSetupCommon(IMvxValueConverter valueConverter, object converterParameter, object fallbackValue, Type targetType, out MockSourceBinding mockSource, out MockTargetBinding mockTarget) { - ClearAll(); - MvxBindingSingletonCache.Initialize(); - Ioc.RegisterSingleton(new InlineMockMainThreadDispatcher()); + _fixture.ClearAll(); + _fixture.Ioc.RegisterSingleton(new InlineMockMainThreadDispatcher()); var mockSourceBindingFactory = new Mock(); - Ioc.RegisterSingleton(mockSourceBindingFactory.Object); + _fixture.Ioc.RegisterSingleton(mockSourceBindingFactory.Object); var mockTargetBindingFactory = new Mock(); - Ioc.RegisterSingleton(mockTargetBindingFactory.Object); + _fixture.Ioc.RegisterSingleton(mockTargetBindingFactory.Object); var realSourceStepFactory = new MvxSourceStepFactory(); realSourceStepFactory.AddOrOverwrite(typeof(MvxPathSourceStepDescription), new MvxPathSourceStepFactory()); - Ioc.RegisterSingleton(realSourceStepFactory); + _fixture.Ioc.RegisterSingleton(realSourceStepFactory); var sourceText = "sourceText"; var targetName = "targetName"; @@ -506,4 +512,4 @@ namespace MvvmCross.Binding.Test.Bindings return toTest; } } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/ExpressionParse/MvxExpressionBindingTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/ExpressionParse/MvxExpressionBindingTest.cs index 2e1ea88ae..a90ea95be 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/ExpressionParse/MvxExpressionBindingTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/ExpressionParse/MvxExpressionBindingTest.cs @@ -13,14 +13,21 @@ using MvvmCross.Binding.Bindings; using MvvmCross.Binding.Bindings.SourceSteps; using MvvmCross.Binding.ExpressionParse; using MvvmCross.Platform.Converters; -using MvvmCross.Test.Core; +using MvvmCross.Test; using Xunit; namespace MvvmCross.Binding.Test.ExpressionParse { - - public class MvxExpressionBindingTest : MvxIoCSupportingTest + [Collection("MvxTest")] + public class MvxExpressionBindingTest : IClassFixture { + private readonly MvxTestFixture _fixture; + + public MvxExpressionBindingTest(MvxTestFixture fixture) + { + _fixture = fixture; + } + public class Child { public string Value { get; set; } @@ -407,8 +414,7 @@ namespace MvvmCross.Binding.Test.ExpressionParse Func findTargetObjectFunc, MvxBindingDescription expectedDescription) { - ClearAll(); - MvxBindingSingletonCache.Initialize(); + _fixture.ClearAll(); var dataContext = new TestDataContext(); @@ -433,13 +439,13 @@ namespace MvvmCross.Binding.Test.ExpressionParse BindingDescription = descriptions.First() }); }); - Ioc.RegisterSingleton(binder.Object); + _fixture.Ioc.RegisterSingleton(binder.Object); - Ioc.RegisterSingleton(new MvxPropertyExpressionParser()); + _fixture.Ioc.RegisterSingleton(new MvxPropertyExpressionParser()); var converterLookup = new MvxValueConverterRegistry(); converterLookup.AddOrOverwrite("SampleConv", new SampleValueConverter()); - Ioc.RegisterSingleton(converterLookup); + _fixture.Ioc.RegisterSingleton(converterLookup); var testTarget = new MockBindingContext { @@ -456,9 +462,9 @@ namespace MvvmCross.Binding.Test.ExpressionParse Assert.Equal(dataContext, callback.Source); var desc = callback.BindingDescription; - Assert.IsTrue(expectedDescription.Source is MvxPathSourceStepDescription); + Assert.True(expectedDescription.Source is MvxPathSourceStepDescription); var path = desc.Source as MvxPathSourceStepDescription; - Assert.IsTrue(desc.Source is MvxPathSourceStepDescription); + Assert.True(desc.Source is MvxPathSourceStepDescription); var expectedPath = expectedDescription.Source as MvxPathSourceStepDescription; Assert.Equal(expectedPath.ConverterParameter, path.ConverterParameter); Assert.Equal(expectedPath.FallbackValue, path.FallbackValue); @@ -466,9 +472,9 @@ namespace MvvmCross.Binding.Test.ExpressionParse Assert.Equal(expectedDescription.Mode, desc.Mode); Assert.Equal(expectedDescription.TargetName, desc.TargetName); if (expectedPath.Converter == null) - Assert.IsNull(path.Converter); + Assert.Null(path.Converter); else Assert.Equal(expectedPath.Converter.GetType(), path.Converter.GetType()); } } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/ExtensionMethods/MakeSafeValueTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/ExtensionMethods/MakeSafeValueTest.cs index e75352977..b505a4323 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/ExtensionMethods/MakeSafeValueTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/ExtensionMethods/MakeSafeValueTest.cs @@ -7,14 +7,21 @@ using MvvmCross.Binding.Binders; using MvvmCross.Binding.ExtensionMethods; using MvvmCross.Platform; using MvvmCross.Platform.Converters; -using MvvmCross.Test.Core; +using MvvmCross.Test; using Xunit; namespace MvvmCross.Binding.Test.ExtensionMethods { - public class MakeSafeValueTest : MvxIoCSupportingTest + public class MakeSafeValueTest : IClassFixture { + private readonly MvxTestFixture _fixture; + + public MakeSafeValueTest(MvxTestFixture fixture) + { + _fixture = fixture; + } + public class MockAutoValueConverters : IMvxAutoValueConverters { public IMvxValueConverter Find(Type viewModelType, Type viewType) @@ -31,15 +38,14 @@ namespace MvvmCross.Binding.Test.ExtensionMethods [Fact] public void TestIntValues() { - ClearAll(); - MvxBindingSingletonCache.Initialize(); + _fixture.ClearAll(); Mvx.RegisterSingleton(new MockAutoValueConverters()); Assert.Equal(0, typeof(int).MakeSafeValue(0)); Assert.Equal(0, typeof(int).MakeSafeValue(null)); Assert.Equal(1, typeof(int).MakeSafeValue(1)); Assert.Equal(0, typeof(int?).MakeSafeValue(0)); - Assert.Equal(null, typeof(int?).MakeSafeValue(null)); + Assert.Null(typeof(int?).MakeSafeValue(null)); Assert.Equal(1, typeof(int?).MakeSafeValue(1)); Assert.Equal(0, typeof(int?).MakeSafeValue(0.0)); Assert.Equal(1, typeof(int?).MakeSafeValue(1.0)); @@ -48,15 +54,14 @@ namespace MvvmCross.Binding.Test.ExtensionMethods [Fact] public void TestDoubleValues() { - ClearAll(); - MvxBindingSingletonCache.Initialize(); + _fixture.ClearAll(); Mvx.RegisterSingleton(new MockAutoValueConverters()); Assert.Equal(0.0, typeof(double).MakeSafeValue(0.0)); Assert.Equal(0.0, typeof(double).MakeSafeValue(null)); Assert.Equal(1.0, typeof(double).MakeSafeValue(1.0)); Assert.Equal(0.0, typeof(double?).MakeSafeValue(0.0)); - Assert.Equal(null, typeof(double?).MakeSafeValue(null)); + Assert.Null(typeof(double?).MakeSafeValue(null)); Assert.Equal(1.0, typeof(double?).MakeSafeValue(1.0)); Assert.Equal(1.0, typeof(double).MakeSafeValue(1)); Assert.Equal(0.0, typeof(double?).MakeSafeValue(0)); @@ -65,15 +70,14 @@ namespace MvvmCross.Binding.Test.ExtensionMethods [Fact] public void TestFloatValues() { - ClearAll(); - MvxBindingSingletonCache.Initialize(); + _fixture.ClearAll(); Mvx.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(null, typeof(double?).MakeSafeValue(null)); + 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)); @@ -90,12 +94,11 @@ namespace MvvmCross.Binding.Test.ExtensionMethods [Fact] public void TestStringValues() { - ClearAll(); - MvxBindingSingletonCache.Initialize(); + _fixture.ClearAll(); Mvx.RegisterSingleton(new MockAutoValueConverters()); Assert.Equal("0", typeof(string).MakeSafeValue(0.0)); - Assert.Equal(null, typeof(string).MakeSafeValue(null)); + Assert.Null(typeof(string).MakeSafeValue(null)); Assert.Equal("1", typeof(string).MakeSafeValue(1.0)); Assert.Equal("Hello", typeof(string).MakeSafeValue("Hello")); Assert.Equal("Hello", typeof(string).MakeSafeValue(new MyTest())); @@ -111,8 +114,7 @@ namespace MvvmCross.Binding.Test.ExtensionMethods [Fact] public void TestEnumValues() { - ClearAll(); - MvxBindingSingletonCache.Initialize(); + _fixture.ClearAll(); Mvx.RegisterSingleton(new MockAutoValueConverters()); Assert.Equal(SampleEnum.Defaulto, typeof(SampleEnum).MakeSafeValue(0)); @@ -125,25 +127,25 @@ namespace MvvmCross.Binding.Test.ExtensionMethods [Fact] public void TestBoolValues() { - ClearAll(); - MvxBindingSingletonCache.Initialize(); + _fixture.Reset(); + _fixture.InitializeSingletonCache(); Mvx.RegisterSingleton(new MockAutoValueConverters()); - Assert.Equal(false, typeof(bool).MakeSafeValue(0)); - Assert.Equal(false, typeof(bool).MakeSafeValue(null)); - Assert.Equal(true, typeof(bool).MakeSafeValue(1)); - Assert.Equal(true, typeof(bool).MakeSafeValue(-1.0)); - Assert.Equal(true, typeof(bool).MakeSafeValue(1.0)); - Assert.Equal(true, typeof(bool).MakeSafeValue("Dos")); - Assert.Equal(true, typeof(bool).MakeSafeValue("dOs")); + Assert.False((bool)typeof(bool).MakeSafeValue(0)); + Assert.False((bool)typeof(bool).MakeSafeValue(null)); + Assert.True((bool)typeof(bool).MakeSafeValue(1)); + Assert.True((bool)typeof(bool).MakeSafeValue(-1.0)); + Assert.True((bool)typeof(bool).MakeSafeValue(1.0)); + Assert.True((bool)typeof(bool).MakeSafeValue("Dos")); + Assert.True((bool)typeof(bool).MakeSafeValue("dOs")); - Assert.Equal(false, typeof(bool?).MakeSafeValue(0)); - Assert.Equal(null, typeof(bool?).MakeSafeValue(null)); - Assert.Equal(true, typeof(bool?).MakeSafeValue(1)); - Assert.Equal(true, typeof(bool?).MakeSafeValue(-1.0)); - Assert.Equal(true, typeof(bool?).MakeSafeValue(1.0)); - Assert.Equal(true, typeof(bool?).MakeSafeValue("Dos")); - Assert.Equal(true, typeof(bool?).MakeSafeValue("dOs")); + Assert.False((bool?)typeof(bool?).MakeSafeValue(0)); + Assert.Null((bool?)typeof(bool?).MakeSafeValue(null)); + Assert.True((bool?)typeof(bool?).MakeSafeValue(1)); + Assert.True((bool?)typeof(bool?).MakeSafeValue(-1.0)); + Assert.True((bool?)typeof(bool?).MakeSafeValue(1.0)); + Assert.True((bool?)typeof(bool?).MakeSafeValue("Dos")); + Assert.True((bool?)typeof(bool?).MakeSafeValue("dOs")); } public class FooBase @@ -157,16 +159,15 @@ namespace MvvmCross.Binding.Test.ExtensionMethods [Fact] public void TestObjectValues() { - ClearAll(); - MvxBindingSingletonCache.Initialize(); + _fixture.ClearAll(); Mvx.RegisterSingleton(new MockAutoValueConverters()); var foo = new Foo(); - Assert.AreSame(foo, typeof(FooBase).MakeSafeValue(foo)); + Assert.Equal(foo, typeof(FooBase).MakeSafeValue(foo)); var fooBase = new FooBase(); - Assert.AreSame(fooBase, typeof(FooBase).MakeSafeValue(fooBase)); + Assert.Equal(fooBase, typeof(FooBase).MakeSafeValue(fooBase)); fooBase = null; - Assert.IsNull(typeof(FooBase).MakeSafeValue(null)); + Assert.Null(typeof(FooBase).MakeSafeValue(null)); } } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/Binding/Lang/MvxLangBindingTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/Binding/Lang/MvxLangBindingTest.cs index cc1602684..6d900514e 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/Binding/Lang/MvxLangBindingTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/Binding/Lang/MvxLangBindingTest.cs @@ -28,7 +28,7 @@ namespace MvvmCross.Binding.Test.Parse.Binding.Lang var language = new MvxLanguageBindingParser(); MvxSerializableBindingSpecification result; var parsed = language.TryParseBindingSpecification(testPair.Key, out result); - Assert.IsTrue(parsed, "Failed to parse " + testPair.Key); + Assert.True(parsed, "Failed to parse " + testPair.Key); Assert.Equal(1, result.Count); var keyAndDescription = testPair.Value.First(); var resultKeyAndDescription = result.First(); diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/Binding/MvxBindingTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/Binding/MvxBindingTest.cs index 1a04ac517..bc1ab99cd 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/Binding/MvxBindingTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/Binding/MvxBindingTest.cs @@ -2,22 +2,26 @@ // 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 MvvmCross.Binding.Parse.Binding; -using MvvmCross.Test.Core; +using MvvmCross.Binding.Parse.Binding; +using MvvmCross.Test; using Xunit; namespace MvvmCross.Binding.Test.Parse.Binding { - public abstract class MvxBindingTest - : MvxIoCSupportingTest + [Collection("MvxTest")] + public abstract class MvxBindingTest : IClassFixture { + public MvxBindingTest(MvxTestFixture fixture) + { + } + protected void AssertAreEquivalent(MvxSerializableBindingSpecification expected, MvxSerializableBindingSpecification actual) { Assert.Equal(expected.Count, actual.Count); foreach (var kvp in expected) { - Assert.IsTrue(actual.ContainsKey(kvp.Key)); + Assert.True(actual.ContainsKey(kvp.Key)); AssertAreEquivalent(kvp.Value, actual[kvp.Key]); } } @@ -33,7 +37,7 @@ namespace MvvmCross.Binding.Test.Parse.Binding Assert.Equal(expected.Function, actual.Function); Assert.Equal(expected.Literal, actual.Literal); if (expected.Sources == null) - Assert.IsNull(actual.Sources); + Assert.Null(actual.Sources); else { Assert.Equal(expected.Sources.Count, actual.Sources.Count); @@ -42,4 +46,4 @@ namespace MvvmCross.Binding.Test.Parse.Binding } } } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/Binding/Swiss/MvxBaseSwissBindingTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/Binding/Swiss/MvxBaseSwissBindingTest.cs index 5462bf097..ffc599117 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/Binding/Swiss/MvxBaseSwissBindingTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/Binding/Swiss/MvxBaseSwissBindingTest.cs @@ -405,7 +405,7 @@ namespace MvvmCross.Binding.Test.Parse.Binding.Swiss var result = theParser.TryParseBindingSpecification(text, out specification); if (!result) Debug.WriteLine("Failed on: " + text); - Assert.IsTrue(result); + Assert.True(result); AssertAreEquivalent(expectedLookup, specification); } } diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/PropertyPath/MvxSourcePropertyPathParserTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/PropertyPath/MvxSourcePropertyPathParserTest.cs index 92ddac6e9..f082a1841 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/PropertyPath/MvxSourcePropertyPathParserTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Binding/Parse/PropertyPath/MvxSourcePropertyPathParserTest.cs @@ -19,7 +19,7 @@ namespace MvvmCross.Binding.Test.Parse.PropertyPath { var result = Tokenise(test); Assert.Equal(1, result.Count); - Assert.IsInstanceOf(result[0]); + Assert.IsType(result[0]); } } @@ -28,7 +28,7 @@ namespace MvvmCross.Binding.Test.Parse.PropertyPath { var result = Tokenise(" \t\r \n "); Assert.Equal(1, result.Count); - Assert.IsInstanceOf(result[0]); + Assert.IsType(result[0]); } [Fact] @@ -175,14 +175,14 @@ namespace MvvmCross.Binding.Test.Parse.PropertyPath private static void AssertIsSimplePropertyToken(MvxPropertyToken token, string text) { - Assert.IsInstanceOf(token); + Assert.IsType(token); Assert.Equal(text, ((MvxPropertyNamePropertyToken)token).PropertyName); } private static void AssertIsIndexerPropertyToken(MvxPropertyToken token, T value) { - Assert.IsInstanceOf>(token); - Assert.IsInstanceOf(token); + Assert.IsType>(token); + Assert.IsType(token); Assert.Equal(value, ((MvxIndexerPropertyToken)token).Key); } @@ -192,4 +192,4 @@ namespace MvvmCross.Binding.Test.Parse.PropertyPath return tokeniser.Parse(text); } } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/MvxTestCollection.cs b/MvvmCross.Tests/MvvmCross.UnitTest/MvxTestCollection.cs new file mode 100644 index 000000000..635c00c73 --- /dev/null +++ b/MvvmCross.Tests/MvvmCross.UnitTest/MvxTestCollection.cs @@ -0,0 +1,13 @@ +using MvvmCross.Test; +using Xunit; + +namespace MvvmCross.Plugins.Color.Test +{ + [CollectionDefinition("MvxTest")] + public class MvxTestCollection : ICollectionFixture + { + // This class has no code, and is never created. Its purpose is simply + // to be the place to apply [CollectionDefinition] and all the + // ICollectionFixture<> interfaces. + } +} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Navigation/NavigationCacheTests.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Navigation/NavigationCacheTests.cs index 735ad2c95..44d7f8e29 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Navigation/NavigationCacheTests.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Navigation/NavigationCacheTests.cs @@ -7,10 +7,9 @@ using Xunit; namespace MvvmCross.Test.Navigation { - public class NavigationCacheTests { - [Fact] + [Theory] [InlineData("a", 1, 1)] [InlineData("a", -1, -1)] [InlineData("a", int.MaxValue, int.MaxValue)] @@ -22,7 +21,7 @@ namespace MvvmCross.Test.Navigation SimpleTest(new MvxNavigationCache(), key, value, expected); } - [Fact] + [Theory] [InlineData("a", 1.0, 1.0)] [InlineData("a", -1.0, -1.0)] [InlineData("a", double.MaxValue, double.MaxValue)] @@ -34,7 +33,7 @@ namespace MvvmCross.Test.Navigation SimpleTest(new MvxNavigationCache(), key, value, expected); } - [Fact] + [Theory] [InlineData("a", "a", "a")] [InlineData("a", "", "")] [InlineData("a", null, null)] @@ -45,7 +44,7 @@ namespace MvvmCross.Test.Navigation private static void SimpleTest(IMvxNavigationCache cache, string key, T value, T expected) { - Assert.IsTrue(cache.AddValue(key, value)); + Assert.True(cache.AddValue(key, value)); var addedValue = cache.GetValueOrDefault(key); Assert.Equal(expected, addedValue); } @@ -72,17 +71,17 @@ namespace MvvmCross.Test.Navigation cache.AddValue("c", 0); cache.AddValue("d", 0); - Assert.IsTrue(cache.Contains("a")); - Assert.IsTrue(cache.Contains("b")); - Assert.IsTrue(cache.Contains("c")); - Assert.IsTrue(cache.Contains("d")); + Assert.True(cache.Contains("a")); + Assert.True(cache.Contains("b")); + Assert.True(cache.Contains("c")); + Assert.True(cache.Contains("d")); cache.Clear(); - Assert.IsFalse(cache.Contains("a")); - Assert.IsFalse(cache.Contains("b")); - Assert.IsFalse(cache.Contains("c")); - Assert.IsFalse(cache.Contains("d")); + Assert.False(cache.Contains("a")); + Assert.False(cache.Contains("b")); + Assert.False(cache.Contains("c")); + Assert.False(cache.Contains("d")); } [Fact] @@ -94,17 +93,17 @@ namespace MvvmCross.Test.Navigation cache.AddValue("g", 0); cache.AddValue("h", 0); - Assert.IsTrue(cache.Contains("e")); - Assert.IsTrue(cache.Contains("f")); - Assert.IsTrue(cache.Contains("g")); - Assert.IsTrue(cache.Contains("h")); + Assert.True(cache.Contains("e")); + Assert.True(cache.Contains("f")); + Assert.True(cache.Contains("g")); + Assert.True(cache.Contains("h")); cache.Remove("g"); - Assert.IsFalse(cache.Contains("g")); - Assert.IsTrue(cache.Contains("e")); - Assert.IsTrue(cache.Contains("f")); - Assert.IsTrue(cache.Contains("h")); + Assert.False(cache.Contains("g")); + Assert.True(cache.Contains("e")); + Assert.True(cache.Contains("f")); + Assert.True(cache.Contains("h")); } public class TestObject diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Navigation/NavigationServiceTests.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Navigation/NavigationServiceTests.cs index bf2983c48..ae6fc0a08 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Navigation/NavigationServiceTests.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Navigation/NavigationServiceTests.cs @@ -2,40 +2,37 @@ // 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; -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading.Tasks; using Moq; using MvvmCross.Core.Navigation; using MvvmCross.Core.Platform; using MvvmCross.Core.ViewModels; -using MvvmCross.Test.Core; using MvvmCross.Test.Mocks.Dispatchers; using MvvmCross.Test.Mocks.ViewModels; using Xunit; namespace MvvmCross.Test.Navigation { - + [Collection("MvxTest")] public class NavigationServiceTests - : MvxIoCSupportingTest + : IClassFixture { + private readonly MvxTestFixture _fixture; + + public NavigationServiceTests(MvxTestFixture fixture) + { + _fixture = fixture; + AdditionalSetup(fixture); + } + protected Mock MockDispatcher { get; set; } protected Mock MockLoader { get; set; } - - public void SetupTest() + + private void AdditionalSetup(MvxTestFixture fixture) { - Setup(); - - SetInvariantCulture(); - } - - protected override void AdditionalSetup() - { - base.AdditionalSetup(); - MockLoader = new Mock(); MockLoader.Setup( l => l.LoadViewModel(It.Is(val => val.ViewModelType == typeof(SimpleTestViewModel)), It.IsAny())) @@ -90,14 +87,14 @@ namespace MvvmCross.Test.Navigation { ViewDispatcher = MockDispatcher.Object, }; - Ioc.RegisterSingleton(navigationService); - Ioc.RegisterSingleton(new MvxStringToTypeParser()); + fixture.Ioc.RegisterSingleton(navigationService); + fixture.Ioc.RegisterSingleton(new MvxStringToTypeParser()); } [Fact] public async Task Test_NavigateNoBundle() { - var navigationService = Ioc.Resolve(); + var navigationService = _fixture.Ioc.Resolve(); await navigationService.Navigate(); @@ -112,7 +109,7 @@ namespace MvvmCross.Test.Navigation [Fact] public async Task Test_NavigateWithBundle() { - var navigationService = Ioc.Resolve(); + var navigationService = _fixture.Ioc.Resolve(); var mockVm = new Mock(); @@ -128,7 +125,7 @@ namespace MvvmCross.Test.Navigation [Fact] public async Task Test_NavigateViewModelInstance() { - var navigationService = Ioc.Resolve(); + var navigationService = _fixture.Ioc.Resolve(); var mockVm = new Mock(); @@ -141,13 +138,13 @@ namespace MvvmCross.Test.Navigation x => x.ShowViewModel(It.Is(t => t.ViewModelInstance == mockVm.Object)), Times.Once); - Assert.IsTrue(MockDispatcher.Object.Requests.Count > 0); + Assert.True(MockDispatcher.Object.Requests.Count > 0); } [Fact] public async Task Test_NavigateWithParameter() { - var navigationService = Ioc.Resolve(); + var navigationService = _fixture.Ioc.Resolve(); var parameter = "hello"; await navigationService.Navigate(parameter); @@ -159,13 +156,13 @@ namespace MvvmCross.Test.Navigation x => x.ShowViewModel(It.Is(t => t.ViewModelType == typeof(SimpleParameterTestViewModel))), Times.Once); - Assert.IsTrue(MockDispatcher.Object.Requests.Count > 0); + Assert.True(MockDispatcher.Object.Requests.Count > 0); } [Fact] public async Task Test_NavigateViewModelInstanceWithParameter() { - var navigationService = Ioc.Resolve(); + var navigationService = _fixture.Ioc.Resolve(); var mockVm = new Mock(); @@ -179,13 +176,13 @@ namespace MvvmCross.Test.Navigation x => x.ShowViewModel(It.Is(t => t.ViewModelInstance == mockVm.Object)), Times.Once); - Assert.IsTrue(MockDispatcher.Object.Requests.Count > 0); + Assert.True(MockDispatcher.Object.Requests.Count > 0); } [Fact] public async Task Test_NavigateTypeOfNoBundle() { - var navigationService = Ioc.Resolve(); + var navigationService = _fixture.Ioc.Resolve(); await navigationService.Navigate(typeof(SimpleTestViewModel)); @@ -200,7 +197,7 @@ namespace MvvmCross.Test.Navigation [Fact] public async Task Test_NavigateTypeOfWithBundle() { - var navigationService = Ioc.Resolve(); + var navigationService = _fixture.Ioc.Resolve(); var bundle = new MvxBundle(); bundle.Write(new { hello = "world" }); @@ -214,7 +211,7 @@ namespace MvvmCross.Test.Navigation [Fact] public async Task Test_NavigateTypeOfWithParameter() { - var navigationService = Ioc.Resolve(); + var navigationService = _fixture.Ioc.Resolve(); var parameter = "hello"; await navigationService.Navigate(typeof(SimpleParameterTestViewModel), parameter); @@ -226,13 +223,13 @@ namespace MvvmCross.Test.Navigation x => x.ShowViewModel(It.Is(t => t.ViewModelType == typeof(SimpleParameterTestViewModel))), Times.Once); - Assert.IsTrue(MockDispatcher.Object.Requests.Count > 0); + Assert.True(MockDispatcher.Object.Requests.Count > 0); } [Fact] public async Task Test_NavigateForResult() { - var navigationService = Ioc.Resolve(); + var navigationService = _fixture.Ioc.Resolve(); var result = await navigationService.Navigate(); @@ -243,14 +240,14 @@ namespace MvvmCross.Test.Navigation x => x.ShowViewModel(It.Is(t => t.ViewModelType == typeof(SimpleResultTestViewModel))), Times.Once); - Assert.IsTrue(MockDispatcher.Object.Requests.Count > 0); - Assert.IsTrue(result); + Assert.True(MockDispatcher.Object.Requests.Count > 0); + Assert.True(result); } [Fact] public async Task Test_NavigateCallbacks() { - var navigationService = Ioc.Resolve(); + var navigationService = _fixture.Ioc.Resolve(); int beforeNavigate = 0; int afterNavigate = 0; @@ -266,14 +263,14 @@ namespace MvvmCross.Test.Navigation tasks.Add(navigationService.Navigate("hello", new MvxBundle())); await Task.WhenAll(tasks); - Assert.IsTrue(beforeNavigate == 6); - Assert.IsTrue(afterNavigate == 6); + Assert.True(beforeNavigate == 6); + Assert.True(afterNavigate == 6); } [Fact] public async Task Test_CloseCallbacks() { - var navigationService = Ioc.Resolve(); + var navigationService = _fixture.Ioc.Resolve(); int beforeClose = 0; int afterClose = 0; @@ -285,14 +282,14 @@ namespace MvvmCross.Test.Navigation tasks.Add(navigationService.Close(new SimpleResultTestViewModel(), false)); await Task.WhenAll(tasks); - Assert.IsTrue(beforeClose == 2); - Assert.IsTrue(afterClose == 2); + Assert.True(beforeClose == 2); + Assert.True(afterClose == 2); } [Fact] public void Test_ChangePresentationCallbacks() { - var navigationService = Ioc.Resolve(); + var navigationService = _fixture.Ioc.Resolve(); int beforeChangePresentation = 0; int afterChangePresentation = 0; @@ -301,8 +298,8 @@ namespace MvvmCross.Test.Navigation navigationService.ChangePresentation(new MvxClosePresentationHint(new SimpleTestViewModel())); - Assert.IsTrue(beforeChangePresentation == 1); - Assert.IsTrue(afterChangePresentation == 1); + Assert.True(beforeChangePresentation == 1); + Assert.True(afterChangePresentation == 1); } } } diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Navigation/RoutingServiceTests.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Navigation/RoutingServiceTests.cs index 4701681a0..85a6934df 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Navigation/RoutingServiceTests.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Navigation/RoutingServiceTests.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Diagnostics; using System.IO; using System.Reflection; using System.Threading.Tasks; @@ -11,7 +10,7 @@ using Moq; using MvvmCross.Core.Navigation; using MvvmCross.Core.Platform; using MvvmCross.Core.ViewModels; -using MvvmCross.Test.Core; +using MvvmCross.Platform.Exceptions; using MvvmCross.Test.Mocks.Dispatchers; using MvvmCross.Test.Mocks.TestViewModels; using MvvmCross.Test.Mocks.ViewModels; @@ -25,37 +24,27 @@ using Xunit; namespace MvvmCross.Test.Navigation { - + [Collection("MvxTest")] public class RoutingServiceTests - : MvxIoCSupportingTest + : IClassFixture { protected Mock MockDispatcher; protected IMvxNavigationService RoutingService; + private readonly MvxTestFixture _fixture; - [OneTimeSetUp] - public static void SetupFixture() + public RoutingServiceTests(MvxTestFixture fixture) { + _fixture = fixture; + MvxNavigationService.LoadRoutes(new[] { typeof(RoutingServiceTests).Assembly }); - } - - - public void SetupTest() - { // ReSharper disable once AssignNullToNotNullAttribute Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - //Debug.Listeners.Clear(); - //Debug.Listeners.Add(new ConsoleTraceListener()); - //Trace.Listeners.Clear(); - //Trace.Listeners.Add(new ConsoleTraceListener()); - - Setup(); + AdditionalSetup(fixture); } - protected override void AdditionalSetup() + private void AdditionalSetup(MvxTestFixture fixture) { - base.AdditionalSetup(); - var mockLocator = new Mock(); mockLocator.Setup( m => m.Load(It.IsAny(), It.IsAny(), It.IsAny())).Returns(() => new SimpleTestViewModel()); @@ -66,7 +55,7 @@ namespace MvvmCross.Test.Navigation mockCollection.Setup(m => m.FindViewModelLocator(It.IsAny())) .Returns(() => mockLocator.Object); - Ioc.RegisterSingleton(mockLocator.Object); + fixture.Ioc.RegisterSingleton(mockLocator.Object); var loader = new MvxViewModelLoader(mockCollection.Object); MockDispatcher = new Mock(MockBehavior.Loose) { CallBase = true }; @@ -74,8 +63,8 @@ namespace MvvmCross.Test.Navigation { ViewDispatcher = MockDispatcher.Object, }; - Ioc.RegisterSingleton(navigationService); - Ioc.RegisterSingleton(new MvxStringToTypeParser()); + fixture.Ioc.RegisterSingleton(navigationService); + fixture.Ioc.RegisterSingleton(new MvxStringToTypeParser()); } [Fact] @@ -84,12 +73,9 @@ namespace MvvmCross.Test.Navigation var url = "mvx://fail/?id=" + Guid.NewGuid(); var canNavigate = await RoutingService.CanNavigate(url); - Assert.That(canNavigate, Is.False); + Assert.False(canNavigate); - Assert.CatchAsync(async () => - { - await RoutingService.Navigate(url); - }); + await Assert.ThrowsAsync(() => RoutingService.Navigate(url)); MockDispatcher.Verify(x => x.ShowViewModel(It.IsAny()), Times.Never); } diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Parse/MvxStringDictionaryTextSerializerTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Parse/MvxStringDictionaryTextSerializerTest.cs index 4840e998d..ae632fec3 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Parse/MvxStringDictionaryTextSerializerTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Parse/MvxStringDictionaryTextSerializerTest.cs @@ -6,20 +6,26 @@ using System.Collections.Generic; using MvvmCross.Core.Parse.StringDictionary; using MvvmCross.Core.ViewModels; using MvvmCross.Platform; -using MvvmCross.Test.Core; using MvvmCross.Test.Mocks.TestViewModels; using Xunit; namespace MvvmCross.Test.Parse { - + [Collection("MvxTest")] public class MvxStringDictionaryTextSerializerTest - : MvxIoCSupportingTest + : IClassFixture { + private readonly MvxTestFixture _fixture; + + public MvxStringDictionaryTextSerializerTest(MvxTestFixture fixture) + { + _fixture = fixture; + } + [Fact] public void Test_Round_Trip_Works_For_Normal_ViewModel_Requests() { - ClearAll(); + _fixture.ClearAll(); var viewModelNameLookup = new MvxViewModelByNameLookup(); viewModelNameLookup.AddAll(GetType().Assembly); @@ -42,7 +48,7 @@ namespace MvvmCross.Test.Parse Assert.Equal("1'\\", deserialized.ParameterValues["On'e"]); Assert.Equal("2", deserialized.ParameterValues["Two"]); Assert.Equal("3\"\'\\", deserialized.PresentationValues["Thre\"\'\\e"]); - Assert.Equal(null, deserialized.PresentationValues["Four"]); + Assert.Null(deserialized.PresentationValues["Four"]); } [Fact] @@ -63,4 +69,4 @@ namespace MvvmCross.Test.Parse Assert.Equal(0, deserialized.ParameterValues.Count); } } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxSimplePropertyDictionaryExtensionMethodsTests.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxSimplePropertyDictionaryExtensionMethodsTests.cs index 5f3f1fecd..e90ffb6a5 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxSimplePropertyDictionaryExtensionMethodsTests.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxSimplePropertyDictionaryExtensionMethodsTests.cs @@ -4,19 +4,19 @@ using System.Collections.Generic; using MvvmCross.Core.Platform; -using MvvmCross.Test.Core; using Xunit; namespace MvvmCross.Test.Platform { - - public class MvxSimplePropertyDictionaryExtensionMethodsTests : MvxIoCSupportingTest + [Collection("MvxTest")] + public class MvxSimplePropertyDictionaryExtensionMethodsTests : IClassFixture { - - public void SetUp() + private readonly MvxTestFixture _fixture; + + public MvxSimplePropertyDictionaryExtensionMethodsTests(MvxTestFixture fixture) { - ClearAll(); - Ioc.RegisterSingleton(new MvxStringToTypeParser()); + _fixture = fixture; + fixture.Ioc.RegisterSingleton(new MvxStringToTypeParser()); } [Fact] @@ -48,4 +48,4 @@ namespace MvvmCross.Test.Platform public string BasePropertyPublicSet { get; set; } } } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxStringToTypeParserTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxStringToTypeParserTest.cs index ce0da6610..6a476edf5 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxStringToTypeParserTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxStringToTypeParserTest.cs @@ -3,40 +3,42 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using MvvmCross.Core.Platform; -using MvvmCross.Test.Core; using Xunit; namespace MvvmCross.Test.Platform { - - public class MvxStringToTypeParserTest : MvxIoCSupportingTest + [Collection("MvxTest")] + public class MvxStringToTypeParserTest : IClassFixture { - [OneTimeSetUp] - public void FixtureSetUp() + private readonly MvxTestFixture _fixture; + + public MvxStringToTypeParserTest(MvxTestFixture fixture) { - SetInvariantCulture(); + _fixture = fixture; + _fixture.SetInvariantCulture(); } [Fact] public void Test_AllTypesAreSupported() { var parser = new MvxStringToTypeParser(); - Assert.IsTrue(parser.TypeSupported(typeof(string))); - Assert.IsTrue(parser.TypeSupported(typeof(int))); - Assert.IsTrue(parser.TypeSupported(typeof(long))); - Assert.IsTrue(parser.TypeSupported(typeof(short))); - Assert.IsTrue(parser.TypeSupported(typeof(float))); - Assert.IsTrue(parser.TypeSupported(typeof(uint))); - Assert.IsTrue(parser.TypeSupported(typeof(ulong))); - Assert.IsTrue(parser.TypeSupported(typeof(ushort))); - Assert.IsTrue(parser.TypeSupported(typeof(double))); - Assert.IsTrue(parser.TypeSupported(typeof(bool))); - Assert.IsTrue(parser.TypeSupported(typeof(Guid))); - Assert.IsTrue(parser.TypeSupported(typeof(StringSplitOptions))); + Assert.True(parser.TypeSupported(typeof(string))); + Assert.True(parser.TypeSupported(typeof(int))); + Assert.True(parser.TypeSupported(typeof(long))); + Assert.True(parser.TypeSupported(typeof(short))); + Assert.True(parser.TypeSupported(typeof(float))); + Assert.True(parser.TypeSupported(typeof(uint))); + Assert.True(parser.TypeSupported(typeof(ulong))); + Assert.True(parser.TypeSupported(typeof(ushort))); + Assert.True(parser.TypeSupported(typeof(double))); + Assert.True(parser.TypeSupported(typeof(bool))); + Assert.True(parser.TypeSupported(typeof(Guid))); + Assert.True(parser.TypeSupported(typeof(StringSplitOptions))); } - [Fact] + [Theory] [InlineData("Hello, World")] [InlineData("Foo Bar Baz")] [InlineData("Z͚̭͖͟A͖̘̪L̻̯̥̬ͅG̞̰̭͍͖ͅͅO̘!̜")] @@ -48,7 +50,7 @@ namespace MvvmCross.Test.Platform Assert.Equal(testData, parser.ReadValue(testData, typeof(string), "ignored")); } - [Fact] + [Theory] [InlineData("-123", -123.0)] [InlineData("1.23", 1.23)] [InlineData("1,23", 123.0)] @@ -63,7 +65,7 @@ namespace MvvmCross.Test.Platform Assert.Equal(expected, parser.ReadValue(testData, typeof(double), "ignored")); } - [Fact] + [Theory] [InlineData("-123", -123.0f)] [InlineData("1.23", 1.23f)] [InlineData("1,23", 123.0f)] @@ -78,7 +80,7 @@ namespace MvvmCross.Test.Platform Assert.Equal(expected, parser.ReadValue(testData, typeof(float), "ignored")); } - [Fact] + [Theory] [InlineData("-123", -123)] [InlineData("123", 123)] [InlineData("1.23", 0)] @@ -91,7 +93,7 @@ namespace MvvmCross.Test.Platform Assert.Equal(expected, parser.ReadValue(testData, typeof(int), "ignored")); } - [Fact] + [Theory] [InlineData("-123", -123L)] [InlineData("123", 123L)] [InlineData("1.23", 0L)] @@ -104,7 +106,7 @@ namespace MvvmCross.Test.Platform Assert.Equal(expected, parser.ReadValue(testData, typeof(long), "ignored")); } - [Fact] + [Theory] [InlineData("123", 123ul)] [InlineData("1.23", 0ul)] [InlineData("garbage", 0ul)] @@ -116,7 +118,7 @@ namespace MvvmCross.Test.Platform Assert.Equal(expected, parser.ReadValue(testData, typeof(ulong), "ignored")); } - [Fact] + [Theory] [InlineData("123", (ushort)123)] [InlineData("1.23", (ushort)0)] [InlineData("garbage", (ushort)0)] @@ -128,7 +130,7 @@ namespace MvvmCross.Test.Platform Assert.Equal(expected, parser.ReadValue(testData, typeof(ushort), "ignored")); } - [Fact] + [Theory] [InlineData("true", true)] [InlineData("True", true)] [InlineData("tRue", true)] @@ -152,25 +154,27 @@ namespace MvvmCross.Test.Platform Assert.Equal(expected, parser.ReadValue(testData, typeof(bool), "ignored")); } - private static object[] _guidCases = + public static IEnumerable GuidCases() { - new object[] { "{C3CF9078-0122-41BD-9E2D-D3199E937285}", Guid.Parse("{C3CF9078-0122-41BD-9E2D-D3199E937285}") }, - new object[] { "{C3CF9078-0122-41BD-9E2D-D3199E937285}".ToLowerInvariant(), Guid.Parse("{C3CF9078-0122-41BD-9E2D-D3199E937285}") }, - new object[] { "{8-0122-41BD-9E2D-D3199E937285}", Guid.Empty }, // invalid - new object[] { Guid.Empty.ToString(), Guid.Empty }, - new object[] { "", Guid.Empty }, - new object[] { "garbage", Guid.Empty }, - new object[] { null, Guid.Empty } - }; + yield return new object[] { "{C3CF9078-0122-41BD-9E2D-D3199E937285}", Guid.Parse("{C3CF9078-0122-41BD-9E2D-D3199E937285}") }; + yield return new object[] { "{C3CF9078-0122-41BD-9E2D-D3199E937285}".ToLowerInvariant(), Guid.Parse("{C3CF9078-0122-41BD-9E2D-D3199E937285}") }; + yield return new object[] { "{8-0122-41BD-9E2D-D3199E937285}", Guid.Empty }; // invalid + yield return new object[] { Guid.Empty.ToString(), Guid.Empty }; + yield return new object[] { "", Guid.Empty }; + yield return new object[] { "garbage", Guid.Empty }; + yield return new object[] { null, Guid.Empty }; + } + - [Test, TestCaseSource(nameof(_guidCases))] + [Theory] + [MemberData(nameof(GuidCases))] public void Test_GuidCanBeRead(string testData, Guid expected) { var parser = new MvxStringToTypeParser(); Assert.Equal(expected, parser.ReadValue(testData, typeof(Guid), "ignored")); } - [Fact] + [Theory] [InlineData("RemoveEmptyEntries", StringSplitOptions.RemoveEmptyEntries)] [InlineData("None", StringSplitOptions.None)] [InlineData("none", StringSplitOptions.None)] diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelByNameLookupTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelByNameLookupTest.cs index fce8d3f02..cbdae1abc 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelByNameLookupTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelByNameLookupTest.cs @@ -4,50 +4,56 @@ using System; using MvvmCross.Core.ViewModels; -using MvvmCross.Test.Core; using MvvmCross.Test.Mocks.TestViewModels; using Xunit; namespace MvvmCross.Test.Platform { - - public class MvxViewModelByNameLookupTest : MvxIoCSupportingTest + [Collection("MvxTest")] + public class MvxViewModelByNameLookupTest : IClassFixture { + private readonly MvxTestFixture _fixture; + + public MvxViewModelByNameLookupTest(MvxTestFixture fixture) + { + _fixture = fixture; + } + [Fact] public void Test_ViewModelByName_Finds_Expected_ViewModel() { - ClearAll(); + _fixture.ClearAll(); var assembly = GetType().Assembly; var finder = new MvxViewModelByNameLookup(); finder.AddAll(assembly); Type result; - Assert.IsTrue(finder.TryLookupByName("Test1ViewModel", out result)); + Assert.True(finder.TryLookupByName("Test1ViewModel", out result)); Assert.Equal(typeof(Test1ViewModel), result); - Assert.IsTrue(finder.TryLookupByName("Test2ViewModel", out result)); + Assert.True(finder.TryLookupByName("Test2ViewModel", out result)); Assert.Equal(typeof(Test2ViewModel), result); - Assert.IsTrue(finder.TryLookupByName("Test3ViewModel", out result)); + Assert.True(finder.TryLookupByName("Test3ViewModel", out result)); Assert.Equal(typeof(Test3ViewModel), result); - Assert.IsFalse(finder.TryLookupByName("AbstractTest1ViewModel", out result)); - Assert.IsNull(result); - Assert.IsFalse(finder.TryLookupByName("NoWayTestViewModel", out result)); - Assert.IsNull(result); - Assert.IsTrue(finder.TryLookupByFullName("MvvmCross.Test.Mocks.TestViewModels.Test1ViewModel", + Assert.False(finder.TryLookupByName("AbstractTest1ViewModel", out result)); + Assert.Null(result); + Assert.False(finder.TryLookupByName("NoWayTestViewModel", out result)); + Assert.Null(result); + Assert.True(finder.TryLookupByFullName("MvvmCross.Test.Mocks.TestViewModels.Test1ViewModel", out result)); Assert.Equal(typeof(Test1ViewModel), result); - Assert.IsTrue(finder.TryLookupByFullName("MvvmCross.Test.Mocks.TestViewModels.Test2ViewModel", + Assert.True(finder.TryLookupByFullName("MvvmCross.Test.Mocks.TestViewModels.Test2ViewModel", out result)); Assert.Equal(typeof(Test2ViewModel), result); - Assert.IsTrue(finder.TryLookupByFullName("MvvmCross.Test.Mocks.TestViewModels.Test3ViewModel", + Assert.True(finder.TryLookupByFullName("MvvmCross.Test.Mocks.TestViewModels.Test3ViewModel", out result)); Assert.Equal(typeof(Test3ViewModel), result); - Assert.IsFalse( + Assert.False( finder.TryLookupByFullName("MvvmCross.Test.Mocks.TestViewModels.AbstractTest1ViewModel", out result)); - Assert.IsNull(result); - Assert.IsFalse(finder.TryLookupByFullName( + Assert.Null(result); + Assert.False(finder.TryLookupByFullName( "MvvmCross.Test.Mocks.TestViewModels.NoWayTestViewModel", out result)); - Assert.IsNull(result); + Assert.Null(result); } } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelViewLookupBuilderTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelViewLookupBuilderTest.cs index 9a9be7ee8..f101783d6 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelViewLookupBuilderTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelViewLookupBuilderTest.cs @@ -3,27 +3,33 @@ // See the LICENSE file in the project root for more information. using MvvmCross.Core.ViewModels; -using MvvmCross.Test.Core; using MvvmCross.Test.Mocks.TestViewModels; using MvvmCross.Test.Mocks.TestViews; using Xunit; namespace MvvmCross.Test.Platform { - - public class MvxViewModelViewLookupBuilderTest : MvxIoCSupportingTest + [Collection("MvxTest")] + public class MvxViewModelViewLookupBuilderTest : IClassFixture { + private readonly MvxTestFixture _fixture; + + public MvxViewModelViewLookupBuilderTest(MvxTestFixture fixture) + { + _fixture = fixture; + } + [Fact] public void Test_Builder() { - ClearAll(); + _fixture.ClearAll(); var assembly = GetType().Assembly; var viewModelNameLookup = new MvxViewModelByNameLookup(); viewModelNameLookup.AddAll(assembly); var nameMapping = new MvxPostfixAwareViewToViewModelNameMapping("View", "Oddness"); var finder = new MvxViewModelViewTypeFinder(viewModelNameLookup, nameMapping); - Ioc.RegisterSingleton(finder); + _fixture.Ioc.RegisterSingleton(finder); var builder = new MvxViewModelViewLookupBuilder(); var result = builder.Build(new[] { assembly }); @@ -35,4 +41,4 @@ namespace MvvmCross.Test.Platform Assert.Equal(typeof(OddNameOddness), result[typeof(OddNameViewModel)]); } } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelViewTypeFinderTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelViewTypeFinderTest.cs index 926279002..cec275b1a 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelViewTypeFinderTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/Platform/MvxViewModelViewTypeFinderTest.cs @@ -3,20 +3,26 @@ // See the LICENSE file in the project root for more information. using MvvmCross.Core.ViewModels; -using MvvmCross.Test.Core; using MvvmCross.Test.Mocks.TestViewModels; using MvvmCross.Test.Mocks.TestViews; using Xunit; namespace MvvmCross.Test.Platform { - - public class MvxViewModelViewTypeFinderTest : MvxIoCSupportingTest + [Collection("MvxTest")] + public class MvxViewModelViewTypeFinderTest : IClassFixture { + private readonly MvxTestFixture _fixture; + + public MvxViewModelViewTypeFinderTest(MvxTestFixture fixture) + { + _fixture = fixture; + } + [Fact] public void Test_MvxViewModelViewTypeFinder() { - ClearAll(); + _fixture.ClearAll(); var assembly = GetType().Assembly; var viewModelNameLookup = new MvxViewModelByNameLookup(); @@ -36,9 +42,9 @@ namespace MvvmCross.Test.Platform // test for negatives result = test.FindTypeOrNull(typeof(AbstractTest1View)); - Assert.IsNull(result); + Assert.Null(result); result = test.FindTypeOrNull(typeof(NotReallyAView)); - Assert.IsNull(result); + Assert.Null(result); } } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxBundleTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxBundleTest.cs index fd8aa8a3b..18acea97f 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxBundleTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxBundleTest.cs @@ -6,21 +6,26 @@ using System; using System.Linq; using MvvmCross.Core.Platform; using MvvmCross.Core.ViewModels; -using MvvmCross.Test.Core; using MvvmCross.Test.Mocks.TestViewModels; using Xunit; namespace MvvmCross.Test.ViewModels { - - public class MvxBundleTest : MvxIoCSupportingTest + [Collection("MvxTest")] + public class MvxBundleTest : IClassFixture { + private readonly MvxTestFixture _fixture; + + public MvxBundleTest(MvxTestFixture fixture) + { + _fixture = fixture; + } + [Fact] public void Test_RoundTrip() { - ClearAll(); - - Ioc.RegisterSingleton(new MvxStringToTypeParser()); + _fixture.ClearAll(); + _fixture.Ioc.RegisterSingleton(new MvxStringToTypeParser()); var testObject = new BundleObject { @@ -56,9 +61,8 @@ namespace MvvmCross.Test.ViewModels [Fact] public void Test_FillArguments() { - ClearAll(); - - Ioc.RegisterSingleton(new MvxStringToTypeParser()); + _fixture.ClearAll(); + _fixture.Ioc.RegisterSingleton(new MvxStringToTypeParser()); var testObject = new BundleObject { @@ -92,4 +96,4 @@ namespace MvvmCross.Test.ViewModels Assert.Equal(expected, output); } } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxCommandCollectionTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxCommandCollectionTest.cs index ed9696e14..6a91187a9 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxCommandCollectionTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxCommandCollectionTest.cs @@ -6,15 +6,21 @@ using System.ComponentModel; using System.Windows.Input; using MvvmCross.Core.ViewModels; using MvvmCross.Platform.Core; -using MvvmCross.Test.Core; using MvvmCross.Test.Mocks.Dispatchers; using Xunit; namespace MvvmCross.Test.ViewModels { - - public class MvxCommandCollectionTest : MvxIoCSupportingTest + [Collection("MvxTest")] + public class MvxCommandCollectionTest : IClassFixture { + private MvxTestFixture _fixture; + + public MvxCommandCollectionTest(MvxTestFixture fixture) + { + _fixture = fixture; + } + public class CommandTestClass : INotifyPropertyChanged { public int CountMyCommandCalled { get; set; } @@ -145,14 +151,14 @@ namespace MvvmCross.Test.ViewModels [Fact] public void Test_Conventional_Command() { - ClearAll(); + _fixture.ClearAll(); var testObject = new CommandTestClass(); var collection = new MvxCommandCollectionBuilder() .BuildCollectionFor(testObject); var myCommand = collection["My"]; - Assert.IsNotNull(myCommand); + Assert.NotNull(myCommand); CheckCounts(testObject); myCommand.Execute(); CheckCounts(testObject, 1, 1); @@ -165,14 +171,14 @@ namespace MvvmCross.Test.ViewModels [Fact] public void Test_Conventional_Command_CanExecute() { - ClearAll(); + _fixture.ClearAll(); var testObject = new CommandTestClass(); var collection = new MvxCommandCollectionBuilder() .BuildCollectionFor(testObject); var myCommand = collection["My"]; - Assert.IsNotNull(myCommand); + Assert.NotNull(myCommand); CheckCounts(testObject); var result = myCommand.CanExecute(); CheckCounts(testObject, countCanExecuteMyCalled: 1); @@ -185,14 +191,14 @@ namespace MvvmCross.Test.ViewModels [Fact] public void Test_Conventional_Parameter_Command() { - ClearAll(); + _fixture.ClearAll(); var testObject = new CommandTestClass(); var collection = new MvxCommandCollectionBuilder() .BuildCollectionFor(testObject); var myCommand = collection["MyEx"]; - Assert.IsNotNull(myCommand); + Assert.NotNull(myCommand); CheckCounts(testObject); myCommand.Execute(); CheckCounts(testObject, countMyExCalled: 1, countCanExecuteMyExCalled: 1); @@ -205,14 +211,14 @@ namespace MvvmCross.Test.ViewModels [Fact] public void Test_Conventional_Parameter_Command_CanExecute() { - ClearAll(); + _fixture.ClearAll(); var testObject = new CommandTestClass(); var collection = new MvxCommandCollectionBuilder() .BuildCollectionFor(testObject); var myCommand = collection["MyEx"]; - Assert.IsNotNull(myCommand); + Assert.NotNull(myCommand); CheckCounts(testObject); var result = myCommand.CanExecute(); CheckCounts(testObject, countCanExecuteMyExCalled: 1); @@ -225,14 +231,14 @@ namespace MvvmCross.Test.ViewModels [Fact] public void Test_IntReturning_Command() { - ClearAll(); + _fixture.ClearAll(); var testObject = new CommandTestClass(); var collection = new MvxCommandCollectionBuilder() .BuildCollectionFor(testObject); var myCommand = collection["AnIntReturning"]; - Assert.IsNotNull(myCommand); + Assert.NotNull(myCommand); CheckCounts(testObject); myCommand.Execute(); CheckCounts(testObject, countIntReturningCalled: 1); @@ -245,14 +251,14 @@ namespace MvvmCross.Test.ViewModels [Fact] public void Test_Attribute1_Command() { - ClearAll(); + _fixture.ClearAll(); var testObject = new CommandTestClass(); var collection = new MvxCommandCollectionBuilder() .BuildCollectionFor(testObject); var myCommand = collection["CalledByAttr"]; - Assert.IsNotNull(myCommand); + Assert.NotNull(myCommand); CheckCounts(testObject); myCommand.Execute(); CheckCounts(testObject, countAttributedCalled: 1); @@ -265,14 +271,14 @@ namespace MvvmCross.Test.ViewModels [Fact] public void Test_Attribute2_Command() { - ClearAll(); + _fixture.ClearAll(); var testObject = new CommandTestClass(); var collection = new MvxCommandCollectionBuilder() .BuildCollectionFor(testObject); var myCommand = collection["CalledByAttr2"]; - Assert.IsNotNull(myCommand); + Assert.NotNull(myCommand); CheckCounts(testObject); myCommand.Execute(); CheckCounts(testObject, countAttributed2Called: 1, countCanExecuteAttributed2Called: 1); @@ -285,14 +291,14 @@ namespace MvvmCross.Test.ViewModels [Fact] public void Test_Attribute2_Command_CanExecute() { - ClearAll(); + _fixture.ClearAll(); var testObject = new CommandTestClass(); var collection = new MvxCommandCollectionBuilder() .BuildCollectionFor(testObject); var myCommand = collection["CalledByAttr2"]; - Assert.IsNotNull(myCommand); + Assert.NotNull(myCommand); CheckCounts(testObject); var result = myCommand.CanExecute(); CheckCounts(testObject, countCanExecuteAttributed2Called: 1); @@ -305,32 +311,32 @@ namespace MvvmCross.Test.ViewModels [Fact] public void Test_PropertyChanged_Raises_CanExecuteChange() { - ClearAll(); + _fixture.ClearAll(); var dispatcher = new InlineMockMainThreadDispatcher(); - Ioc.RegisterSingleton(dispatcher); + _fixture.Ioc.RegisterSingleton(dispatcher); var testObject = new CommandTestClass(); var collection = new MvxCommandCollectionBuilder() .BuildCollectionFor(testObject); var myCommand = collection["My"]; - Assert.IsNotNull(myCommand); + Assert.NotNull(myCommand); var countMy = 0; myCommand.CanExecuteChanged += (sender, args) => countMy++; var myExCommand = collection["MyEx"]; - Assert.IsNotNull(myExCommand); + Assert.NotNull(myExCommand); var countMyEx = 0; myExCommand.CanExecuteChanged += (sender, args) => countMyEx++; var calledByAttrCommand = collection["CalledByAttr"]; - Assert.IsNotNull(calledByAttrCommand); + Assert.NotNull(calledByAttrCommand); var countAttr = 0; calledByAttrCommand.CanExecuteChanged += (sender, args) => countAttr++; var calledByAttr2Command = collection["CalledByAttr2"]; - Assert.IsNotNull(calledByAttr2Command); + Assert.NotNull(calledByAttr2Command); var countAttr2 = 0; calledByAttr2Command.CanExecuteChanged += (sender, args) => countAttr2++; @@ -379,22 +385,22 @@ namespace MvvmCross.Test.ViewModels [Fact] public void Test_PropertyChanged_Raises_Multiple_CanExecuteChange() { - ClearAll(); + _fixture.ClearAll(); var dispatcher = new InlineMockMainThreadDispatcher(); - Ioc.RegisterSingleton(dispatcher); + _fixture.Ioc.RegisterSingleton(dispatcher); var testObject = new SharedCommandTestClass(); var collection = new MvxCommandCollectionBuilder() .BuildCollectionFor(testObject); var calledByAttrCommand = collection["CalledByAttr"]; - Assert.IsNotNull(calledByAttrCommand); + Assert.NotNull(calledByAttrCommand); var countAttr = 0; calledByAttrCommand.CanExecuteChanged += (sender, args) => countAttr++; var calledByAttr2Command = collection["CalledByAttr2"]; - Assert.IsNotNull(calledByAttr2Command); + Assert.NotNull(calledByAttr2Command); var countAttr2 = 0; calledByAttr2Command.CanExecuteChanged += (sender, args) => countAttr2++; @@ -430,4 +436,4 @@ namespace MvvmCross.Test.ViewModels Assert.Equal(countIntReturningCalled, testObject.CountAnIntReturningCalled); } } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxDefaultViewModelLocatorTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxDefaultViewModelLocatorTest.cs index ab9fd273e..d83b00cff 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxDefaultViewModelLocatorTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxDefaultViewModelLocatorTest.cs @@ -6,24 +6,30 @@ using System; using MvvmCross.Core.Platform; using MvvmCross.Core.ViewModels; using MvvmCross.Platform.Exceptions; -using MvvmCross.Test.Core; using MvvmCross.Test.Mocks.TestViewModels; using Xunit; namespace MvvmCross.Test.ViewModels { - - public class MvxDefaultViewModelLocatorTest : MvxIoCSupportingTest + [Collection("MvxTest")] + public class MvxDefaultViewModelLocatorTest : IClassFixture { + private readonly MvxTestFixture _fixture; + + public MvxDefaultViewModelLocatorTest(MvxTestFixture fixture) + { + _fixture = fixture; + } + [Fact] public void Test_NoReloadState() { - ClearAll(); + _fixture.ClearAll(); - Ioc.RegisterSingleton(new MvxStringToTypeParser()); + _fixture.Ioc.RegisterSingleton(new MvxStringToTypeParser()); var testThing = new MockTestThing(); - Ioc.RegisterSingleton(testThing); + _fixture.Ioc.RegisterSingleton(testThing); var testObject = new BundleObject { @@ -43,31 +49,31 @@ namespace MvvmCross.Test.ViewModels IMvxViewModel viewModel = toTest.Load(typeof(Test1ViewModel), bundle, null); - Assert.IsNotNull(viewModel); + Assert.NotNull(viewModel); var typedViewModel = (Test1ViewModel)viewModel; - Assert.AreSame(bundle, typedViewModel.BundleInit); - Assert.IsNull(typedViewModel.BundleState); - Assert.AreSame(testThing, typedViewModel.Thing); + Assert.Equal(bundle, typedViewModel.BundleInit); + Assert.Null(typedViewModel.BundleState); + Assert.Equal(testThing, typedViewModel.Thing); Assert.Equal(testObject, typedViewModel.TheInitBundleSet); - Assert.IsNull(typedViewModel.TheReloadBundleSet); + Assert.Null(typedViewModel.TheReloadBundleSet); Assert.Equal(testObject.TheGuid1, typedViewModel.TheInitGuid1Set); Assert.Equal(testObject.TheGuid2, typedViewModel.TheInitGuid2Set); Assert.Equal(testObject.TheString1, typedViewModel.TheInitString1Set); Assert.Equal(Guid.Empty, typedViewModel.TheReloadGuid1Set); Assert.Equal(Guid.Empty, typedViewModel.TheReloadGuid2Set); - Assert.Equal(null, typedViewModel.TheReloadString1Set); - Assert.IsTrue(typedViewModel.StartCalled); + Assert.Null(typedViewModel.TheReloadString1Set); + Assert.True(typedViewModel.StartCalled); } [Fact] public void Test_WithReloadState() { - ClearAll(); + _fixture.ClearAll(); - Ioc.RegisterSingleton(new MvxStringToTypeParser()); + _fixture.Ioc.RegisterSingleton(new MvxStringToTypeParser()); var testThing = new MockTestThing(); - Ioc.RegisterSingleton(testThing); + _fixture.Ioc.RegisterSingleton(testThing); var initBundleObject = new BundleObject { @@ -100,11 +106,11 @@ namespace MvvmCross.Test.ViewModels var toTest = new MvxDefaultViewModelLocator(); IMvxViewModel viewModel = toTest.Load(typeof(Test1ViewModel), initBundle, reloadBundle); - Assert.IsNotNull(viewModel); + Assert.NotNull(viewModel); var typedViewModel = (Test1ViewModel)viewModel; - Assert.AreSame(initBundle, typedViewModel.BundleInit); - Assert.AreSame(reloadBundle, typedViewModel.BundleState); - Assert.AreSame(testThing, typedViewModel.Thing); + Assert.Equal(initBundle, typedViewModel.BundleInit); + Assert.Equal(reloadBundle, typedViewModel.BundleState); + Assert.Equal(testThing, typedViewModel.Thing); Assert.Equal(initBundleObject, typedViewModel.TheInitBundleSet); Assert.Equal(reloadBundleObject, typedViewModel.TheReloadBundleSet); Assert.Equal(initBundleObject.TheGuid1, typedViewModel.TheInitGuid1Set); @@ -113,60 +119,54 @@ namespace MvvmCross.Test.ViewModels Assert.Equal(reloadBundleObject.TheGuid1, typedViewModel.TheReloadGuid1Set); Assert.Equal(reloadBundleObject.TheGuid2, typedViewModel.TheReloadGuid2Set); Assert.Equal(reloadBundleObject.TheString1, typedViewModel.TheReloadString1Set); - Assert.IsTrue(typedViewModel.StartCalled); + Assert.True(typedViewModel.StartCalled); } [Fact] public void Test_MissingDependency() { - ClearAll(); + _fixture.ClearAll(); var bundle = new MvxBundle(); var toTest = new MvxDefaultViewModelLocator(); - Assert.That( - () => { - IMvxViewModel viewModel = toTest.Load(typeof(Test4ViewModel), bundle, null); - }, - Throws.TypeOf().With.Message.StartWith("Problem creating viewModel")); + Assert.Throws(() => { + IMvxViewModel viewModel = toTest.Load(typeof(Test4ViewModel), bundle, null); + }); } [Fact] public void Test_FailingDependency() { - ClearAll(); + _fixture.ClearAll(); - Ioc.RegisterSingleton(() => new FailingMockTestThing()); + _fixture.Ioc.RegisterSingleton(() => new FailingMockTestThing()); var bundle = new MvxBundle(); var toTest = new MvxDefaultViewModelLocator(); - Assert.That( - () => { - IMvxViewModel viewModel = toTest.Load(typeof(Test4ViewModel), bundle, null); - }, - Throws.TypeOf().With.Message.StartWith("Problem creating viewModel")); + Assert.Throws(() => { + IMvxViewModel viewModel = toTest.Load(typeof(Test4ViewModel), bundle, null); + }); } [Fact] public void Test_FailingInitialisation() { - ClearAll(); + _fixture.ClearAll(); var testThing = new MockTestThing(); - Ioc.RegisterSingleton(testThing); + _fixture.Ioc.RegisterSingleton(testThing); var bundle = new MvxBundle(); var toTest = new MvxDefaultViewModelLocator(); - Assert.That( - () => { - IMvxViewModel viewModel = toTest.Load(typeof(Test4ViewModel), bundle, null); - }, - Throws.TypeOf().With.Message.StartWith("Problem running viewModel lifecycle")); + Assert.Throws(() => { + IMvxViewModel viewModel = toTest.Load(typeof(Test4ViewModel), bundle, null); + }); } } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxNotifyPropertyChangedTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxNotifyPropertyChangedTest.cs index 284c77849..a86001218 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxNotifyPropertyChangedTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxNotifyPropertyChangedTest.cs @@ -7,15 +7,21 @@ using System.Collections.Generic; using System.ComponentModel; using MvvmCross.Core.ViewModels; using MvvmCross.Platform.Core; -using MvvmCross.Test.Core; using MvvmCross.Test.Mocks.Dispatchers; using Xunit; namespace MvvmCross.Test.ViewModels { - public class MvxNotifyPropertyChangedTest : MvxIoCSupportingTest + public class MvxNotifyPropertyChangedTest : IClassFixture { + private readonly MvxTestFixture _fixture; + + public MvxNotifyPropertyChangedTest(MvxTestFixture fixture) + { + _fixture = fixture; + } + public class TestInpc : MvxNotifyPropertyChanged { public string Foo { get; set; } @@ -24,57 +30,57 @@ namespace MvvmCross.Test.ViewModels [Fact] public void Test_RaisePropertyChangedForExpression() { - ClearAll(); + _fixture.ClearAll(); var dispatcher = new InlineMockMainThreadDispatcher(); - Ioc.RegisterSingleton(dispatcher); + _fixture.Ioc.RegisterSingleton(dispatcher); var notified = new List(); var t = new TestInpc(); t.PropertyChanged += (sender, args) => notified.Add(args.PropertyName); t.RaisePropertyChanged(() => t.Foo); - Assert.That(notified.Count == 1); - Assert.That(notified[0] == "Foo"); + Assert.True(notified.Count == 1); + Assert.True(notified[0] == "Foo"); } [Fact] public void Test_RaisePropertyChangedForName() { - ClearAll(); + _fixture.ClearAll(); var dispatcher = new InlineMockMainThreadDispatcher(); - Ioc.RegisterSingleton(dispatcher); + _fixture.Ioc.RegisterSingleton(dispatcher); var notified = new List(); var t = new TestInpc(); t.PropertyChanged += (sender, args) => notified.Add(args.PropertyName); t.RaisePropertyChanged("Foo"); - Assert.That(notified.Count == 1); - Assert.That(notified[0] == "Foo"); + Assert.True(notified.Count == 1); + Assert.True(notified[0] == "Foo"); } [Fact] public void Test_RaisePropertyChangedDirect() { - ClearAll(); + _fixture.ClearAll(); var dispatcher = new InlineMockMainThreadDispatcher(); - Ioc.RegisterSingleton(dispatcher); + _fixture.Ioc.RegisterSingleton(dispatcher); var notified = new List(); var t = new TestInpc(); t.PropertyChanged += (sender, args) => notified.Add(args.PropertyName); t.RaisePropertyChanged(new PropertyChangedEventArgs("Foo")); - Assert.That(notified.Count == 1); - Assert.That(notified[0] == "Foo"); + Assert.True(notified.Count == 1); + Assert.True(notified[0] == "Foo"); } [Fact] public void Test_TurnOffUIThread() { - ClearAll(); + _fixture.ClearAll(); var dispatcher = new CountingMockMainThreadDispatcher(); - Ioc.RegisterSingleton(dispatcher); + _fixture.Ioc.RegisterSingleton(dispatcher); var notified = new List(); var t = new TestInpc(); @@ -82,16 +88,16 @@ namespace MvvmCross.Test.ViewModels t.ShouldAlwaysRaiseInpcOnUserInterfaceThread(false); t.RaisePropertyChanged(new PropertyChangedEventArgs("Foo")); - Assert.That(dispatcher.Count == 0); - Assert.That(notified.Count == 1); - Assert.That(notified[0] == "Foo"); + Assert.True(dispatcher.Count == 0); + Assert.True(notified.Count == 1); + Assert.True(notified[0] == "Foo"); t.ShouldAlwaysRaiseInpcOnUserInterfaceThread(true); t.RaisePropertyChanged(new PropertyChangedEventArgs("Foo")); Assert.Equal(1, dispatcher.Count); - Assert.That(notified.Count == 1); - Assert.That(notified[0] == "Foo"); + Assert.True(notified.Count == 1); + Assert.True(notified[0] == "Foo"); } public class Interceptor : IMvxInpcInterceptor @@ -107,13 +113,13 @@ namespace MvvmCross.Test.ViewModels [Fact] public void Test_Interceptor() { - ClearAll(); + _fixture.ClearAll(); var dispatcher = new CountingMockMainThreadDispatcher(); - Ioc.RegisterSingleton(dispatcher); + _fixture.Ioc.RegisterSingleton(dispatcher); var interceptor = new Interceptor(); - Ioc.RegisterSingleton(interceptor); + _fixture.Ioc.RegisterSingleton(interceptor); var notified = new List(); var t = new TestInpc(); @@ -121,17 +127,17 @@ namespace MvvmCross.Test.ViewModels interceptor.Handler = (s, e) => MvxInpcInterceptionResult.RaisePropertyChanged; t.RaisePropertyChanged(new PropertyChangedEventArgs("Foo")); - Assert.That(dispatcher.Count == 1); + Assert.True(dispatcher.Count == 1); interceptor.Handler = (s, e) => MvxInpcInterceptionResult.DoNotRaisePropertyChanged; t.RaisePropertyChanged(new PropertyChangedEventArgs("Foo")); - Assert.That(dispatcher.Count == 1); + Assert.True(dispatcher.Count == 1); interceptor.Handler = (s, e) => MvxInpcInterceptionResult.RaisePropertyChanged; t.RaisePropertyChanged(new PropertyChangedEventArgs("Foo")); - Assert.That(dispatcher.Count == 2); + Assert.True(dispatcher.Count == 2); } } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxSaveStateTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxSaveStateTest.cs index 437590a55..7ea31ac45 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxSaveStateTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxSaveStateTest.cs @@ -6,21 +6,27 @@ using System; using System.Collections.Generic; using MvvmCross.Core.Platform; using MvvmCross.Core.ViewModels; -using MvvmCross.Test.Core; using MvvmCross.Test.Mocks.TestViewModels; using Xunit; namespace MvvmCross.Test.ViewModels { - - public class MvxSaveStateTest : MvxIoCSupportingTest + [Collection("MvxTest")] + public class MvxSaveStateTest : IClassFixture { + private readonly MvxTestFixture _fixture; + + public MvxSaveStateTest(MvxTestFixture fixture) + { + _fixture = fixture; + } + [Fact] public void Test_SaveState() { - ClearAll(); + _fixture.ClearAll(); - Ioc.RegisterSingleton(new MvxStringToTypeParser()); + _fixture.Ioc.RegisterSingleton(new MvxStringToTypeParser()); var viewModel = new Test3ViewModel { @@ -53,7 +59,7 @@ namespace MvvmCross.Test.ViewModels [Fact] public void Test_NullSaveState() { - ClearAll(); + _fixture.ClearAll(); var viewModel = new Test3ViewModel(); @@ -61,4 +67,4 @@ namespace MvvmCross.Test.ViewModels Assert.Equal(0, bundle.Data.Count); } } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxViewModelLoaderTest.cs b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxViewModelLoaderTest.cs index 00075229f..c77bfbe6c 100644 --- a/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxViewModelLoaderTest.cs +++ b/MvvmCross.Tests/MvvmCross.UnitTest/ViewModels/MvxViewModelLoaderTest.cs @@ -7,32 +7,39 @@ using System.Collections.Generic; using Moq; using MvvmCross.Core.ViewModels; using MvvmCross.Platform.Exceptions; -using MvvmCross.Test.Core; using MvvmCross.Test.Mocks.TestViewModels; using Xunit; namespace MvvmCross.Test.ViewModels { - - public class MvxViewModelLoaderTest : MvxIoCSupportingTest + [Collection("MvxTest")] + public class MvxViewModelLoaderTest : IClassFixture { + private readonly MvxTestFixture _fixture; + + public MvxViewModelLoaderTest(MvxTestFixture fixture) + { + _fixture = fixture; + } + + [Fact] public void Test_LoaderForNull() { - ClearAll(); + _fixture.ClearAll(); var request = new MvxViewModelRequest(null, null); var state = new MvxBundle(); var loader = new MvxViewModelLoader(null); var viewModel = loader.LoadViewModel(request, state); - Assert.IsInstanceOf(viewModel); + Assert.IsType(viewModel); } [Fact] public void Test_NormalViewModel() { - ClearAll(); + _fixture.ClearAll(); IMvxViewModel outViewModel = new Test2ViewModel(); @@ -51,13 +58,13 @@ namespace MvvmCross.Test.ViewModels var loader = new MvxViewModelLoader(mockCollection.Object); var viewModel = loader.LoadViewModel(request, state); - Assert.AreSame(outViewModel, viewModel); + Assert.Equal(outViewModel, viewModel); } [Fact] public void Test_FailedViewModel() { - ClearAll(); + _fixture.ClearAll(); var mockLocator = new Mock(); mockLocator.Setup( @@ -80,7 +87,7 @@ namespace MvvmCross.Test.ViewModels [Fact] public void Test_FailedViewModelLocatorCollection() { - ClearAll(); + _fixture.ClearAll(); var mockCollection = new Mock(); mockCollection.Setup(m => m.FindViewModelLocator(It.IsAny())) @@ -96,4 +103,4 @@ namespace MvvmCross.Test.ViewModels }); } } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/Plugins.Color.UnitTest/ColorCollection.cs b/MvvmCross.Tests/Plugins.Color.UnitTest/ColorCollection.cs new file mode 100644 index 000000000..155756055 --- /dev/null +++ b/MvvmCross.Tests/Plugins.Color.UnitTest/ColorCollection.cs @@ -0,0 +1,20 @@ +// MvxColorValueConverterTest.cs +// (c) Copyright Cirrious Ltd. http://www.cirrious.com +// MvvmCross is licensed using Microsoft Public License (Ms-PL) +// Contributions and inspirations noted in readme.md and license.txt +// +// Project Lead - Stuart Lodge, @slodge, me@slodge.com + +using MvvmCross.Test; +using Xunit; + +namespace MvvmCross.Plugins.Color.Test +{ + [CollectionDefinition("Color")] + public class ColorCollection : ICollectionFixture + { + // This class has no code, and is never created. Its purpose is simply + // to be the place to apply [CollectionDefinition] and all the + // ICollectionFixture<> interfaces. + } +} diff --git a/MvvmCross.Tests/Plugins.Color.UnitTest/MvxColorValueConverterTest.cs b/MvvmCross.Tests/Plugins.Color.UnitTest/MvxColorValueConverterTest.cs index e5a7edc85..9047eb02a 100644 --- a/MvvmCross.Tests/Plugins.Color.UnitTest/MvxColorValueConverterTest.cs +++ b/MvvmCross.Tests/Plugins.Color.UnitTest/MvxColorValueConverterTest.cs @@ -36,12 +36,4 @@ namespace MvvmCross.Plugins.Color.Test } } } - - [CollectionDefinition("Color")] - public class DatabaseCollection : ICollectionFixture - { - // This class has no code, and is never created. Its purpose is simply - // to be the place to apply [CollectionDefinition] and all the - // ICollectionFixture<> interfaces. - } } diff --git a/MvvmCross.Tests/Plugins.JsonLocalization.UnitTest/MvxDictionaryTextProviderTest.cs b/MvvmCross.Tests/Plugins.JsonLocalization.UnitTest/MvxDictionaryTextProviderTest.cs index c4b3f8b52..870b27fe0 100644 --- a/MvvmCross.Tests/Plugins.JsonLocalization.UnitTest/MvxDictionaryTextProviderTest.cs +++ b/MvvmCross.Tests/Plugins.JsonLocalization.UnitTest/MvxDictionaryTextProviderTest.cs @@ -5,25 +5,12 @@ using System.Collections.Generic; using MvvmCross.Plugins.JsonLocalization.Tests.Mocks; using Xunit; -using NUnit.Framework.Internal; namespace MvvmCross.Plugins.JsonLocalization.Tests { public class MvxDictionaryTextProviderTest { - - public void Setup() - { - } - - [TearDown] - public void TearDown() - { - } - - #region Tests covertin the 'GetText' method - [Fact] public void GetTextWithExistingValueReturnsTheValueWhenMaskingErrors() { @@ -77,17 +64,13 @@ namespace MvvmCross.Plugins.JsonLocalization.Tests "NonExistingKey")); } - #endregion - - #region Tests covering the 'TryGetText' method - [Fact] public void TryGetTextForExistingValueReturnsTrueWhenMaskingErrors() { var textProvider = TestDictionaryTextProvider.CreateAndInitializeWithDummyData(true); string value; - Assert.IsTrue(textProvider.TryGetText(out value, TestDictionaryTextProvider.LocalizationNamespace, TestDictionaryTextProvider.TypeKey, "DummyKey")); + Assert.True(textProvider.TryGetText(out value, TestDictionaryTextProvider.LocalizationNamespace, TestDictionaryTextProvider.TypeKey, "DummyKey")); } [Fact] @@ -96,7 +79,7 @@ namespace MvvmCross.Plugins.JsonLocalization.Tests var textProvider = TestDictionaryTextProvider.CreateAndInitializeWithDummyData(false); string value; - Assert.IsTrue(textProvider.TryGetText(out value, TestDictionaryTextProvider.LocalizationNamespace, TestDictionaryTextProvider.TypeKey, "DummyKey")); + Assert.True(textProvider.TryGetText(out value, TestDictionaryTextProvider.LocalizationNamespace, TestDictionaryTextProvider.TypeKey, "DummyKey")); } [Fact] @@ -105,7 +88,7 @@ namespace MvvmCross.Plugins.JsonLocalization.Tests var textProvider = TestDictionaryTextProvider.CreateAndInitializeWithDummyData(true); string value; - Assert.IsFalse(textProvider.TryGetText(out value, TestDictionaryTextProvider.LocalizationNamespace, TestDictionaryTextProvider.TypeKey, "NonExistingKey")); + Assert.False(textProvider.TryGetText(out value, TestDictionaryTextProvider.LocalizationNamespace, TestDictionaryTextProvider.TypeKey, "NonExistingKey")); } [Fact] @@ -114,7 +97,7 @@ namespace MvvmCross.Plugins.JsonLocalization.Tests var textProvider = TestDictionaryTextProvider.CreateAndInitializeWithDummyData(false); string value; - Assert.IsFalse(textProvider.TryGetText(out value, TestDictionaryTextProvider.LocalizationNamespace, TestDictionaryTextProvider.TypeKey, "NonExistingKey")); + Assert.False(textProvider.TryGetText(out value, TestDictionaryTextProvider.LocalizationNamespace, TestDictionaryTextProvider.TypeKey, "NonExistingKey")); } [Fact] @@ -144,7 +127,5 @@ namespace MvvmCross.Plugins.JsonLocalization.Tests Assert.Equal(expected, actual); } - - #endregion } } diff --git a/MvvmCross.Tests/Plugins.Messenger.UnitTest/MessengerHubTest.cs b/MvvmCross.Tests/Plugins.Messenger.UnitTest/MessengerHubTest.cs index 94522b322..7a0f39979 100644 --- a/MvvmCross.Tests/Plugins.Messenger.UnitTest/MessengerHubTest.cs +++ b/MvvmCross.Tests/Plugins.Messenger.UnitTest/MessengerHubTest.cs @@ -45,15 +45,15 @@ namespace MvvmCross.Plugins.Messenger.Test var messageReceived = false; messenger.Subscribe(m => - { - Assert.That(m, Is.EqualTo(message)); - Assert.That(m.Sender, Is.EqualTo(this)); - messageReceived = true; - }); + { + Assert.Equal(message, m); + Assert.Equal(this, m.Sender); + messageReceived = true; + }); messenger.Publish(message); - Assert.IsTrue(messageReceived); + Assert.True(messageReceived); } [Fact] @@ -65,19 +65,19 @@ namespace MvvmCross.Plugins.Messenger.Test var messageReceived = 0; messenger.Subscribe(m => - { - Assert.That(m, Is.EqualTo(message)); - Assert.That(m.Sender, Is.EqualTo(this)); - messageReceived++; - }); + { + Assert.Equal(message, m); + Assert.Equal(this, m.Sender); + messageReceived++; + }); var otherMessageReceived = 0; messenger.Subscribe(m => - { - Assert.That(m, Is.EqualTo(otherMessage)); - Assert.That(m.Sender, Is.EqualTo(this)); - otherMessageReceived++; - }); + { + Assert.Equal(otherMessage, m); + Assert.Equal(this, m.Sender); + otherMessageReceived++; + }); messenger.Publish(otherMessage); Assert.Equal(0, messageReceived); @@ -104,7 +104,7 @@ namespace MvvmCross.Plugins.Messenger.Test public void UnsubscribePreventsMessagesBeingReceived() { var messenger = new MvxMessengerHub(); - Action action = _ => Assert.That(false, "This event should not fire!"); + Action action = _ => Assert.True(false, "This event should not fire!"); var id = messenger.Subscribe(action); messenger.Unsubscribe(id); @@ -115,7 +115,7 @@ namespace MvvmCross.Plugins.Messenger.Test public void DisposeTokenPreventsMessagesBeingReceived() { var messenger = new MvxMessengerHub(); - Action action = _ => Assert.That(false, "This event should not fire!"); + Action action = _ => Assert.True(false, "This event should not fire!"); var id = messenger.Subscribe(action); id.Dispose(); @@ -165,28 +165,28 @@ namespace MvvmCross.Plugins.Messenger.Test public void HasSubscriptionsForIsCorrect() { var messenger = new MvxMessengerHub(); - Assert.Equal(false, messenger.HasSubscriptionsFor()); - Assert.Equal(false, messenger.HasSubscriptionsFor()); + Assert.False(messenger.HasSubscriptionsFor()); + Assert.False(messenger.HasSubscriptionsFor()); var changeToken = messenger.Subscribe(message => { }); - Assert.Equal(true, messenger.HasSubscriptionsFor()); - Assert.Equal(false, messenger.HasSubscriptionsFor()); + Assert.True(messenger.HasSubscriptionsFor()); + Assert.False(messenger.HasSubscriptionsFor()); var token = messenger.Subscribe(m => { // stuff }); - Assert.Equal(true, messenger.HasSubscriptionsFor()); - Assert.Equal(true, messenger.HasSubscriptionsFor()); + Assert.True(messenger.HasSubscriptionsFor()); + Assert.True(messenger.HasSubscriptionsFor()); messenger.Unsubscribe(token); - Assert.Equal(true, messenger.HasSubscriptionsFor()); - Assert.Equal(false, messenger.HasSubscriptionsFor()); + Assert.True(messenger.HasSubscriptionsFor()); + Assert.False(messenger.HasSubscriptionsFor()); } [Fact] public void CountSubscriptionsForIsCorrect() { var messenger = new MvxMessengerHub(); - Assert.Equal(false, messenger.HasSubscriptionsFor()); - Assert.Equal(false, messenger.HasSubscriptionsFor()); + Assert.False(messenger.HasSubscriptionsFor()); + Assert.False(messenger.HasSubscriptionsFor()); var changeToken = messenger.Subscribe(message => { }); Assert.Equal(1, messenger.CountSubscriptionsFor()); Assert.Equal(0, messenger.CountSubscriptionsFor()); @@ -216,32 +216,32 @@ namespace MvvmCross.Plugins.Messenger.Test var testTag = "TestTag"; var notExistingTag = "NotExistingTag"; var messenger = new MvxMessengerHub(); - Assert.Equal(false, messenger.HasSubscriptionsFor()); - Assert.Equal(false, messenger.HasSubscriptionsForTag(testTag)); - Assert.Equal(false, messenger.HasSubscriptionsFor()); - Assert.Equal(false, messenger.HasSubscriptionsForTag(null)); - Assert.Equal(false, messenger.HasSubscriptionsForTag(notExistingTag)); + Assert.False(messenger.HasSubscriptionsFor()); + Assert.False(messenger.HasSubscriptionsForTag(testTag)); + Assert.False(messenger.HasSubscriptionsFor()); + Assert.False(messenger.HasSubscriptionsForTag(null)); + Assert.False(messenger.HasSubscriptionsForTag(notExistingTag)); var changeToken = messenger.Subscribe(message => { }); - Assert.Equal(true, messenger.HasSubscriptionsForTag(null)); - Assert.Equal(false, messenger.HasSubscriptionsForTag(testTag)); - Assert.Equal(false, messenger.HasSubscriptionsForTag(testTag)); - Assert.Equal(false, messenger.HasSubscriptionsForTag(null)); - Assert.Equal(false, messenger.HasSubscriptionsForTag(notExistingTag)); + Assert.True(messenger.HasSubscriptionsForTag(null)); + Assert.False(messenger.HasSubscriptionsForTag(testTag)); + Assert.False(messenger.HasSubscriptionsForTag(testTag)); + Assert.False(messenger.HasSubscriptionsForTag(null)); + Assert.False(messenger.HasSubscriptionsForTag(notExistingTag)); var token = messenger.Subscribe(m => { // stuff }, tag: testTag); - Assert.Equal(true, messenger.HasSubscriptionsForTag(null)); - Assert.Equal(false, messenger.HasSubscriptionsForTag(testTag)); - Assert.Equal(true, messenger.HasSubscriptionsForTag(testTag)); - Assert.Equal(false, messenger.HasSubscriptionsForTag(null)); - Assert.Equal(false, messenger.HasSubscriptionsForTag(notExistingTag)); + Assert.True(messenger.HasSubscriptionsForTag(null)); + Assert.False(messenger.HasSubscriptionsForTag(testTag)); + Assert.True(messenger.HasSubscriptionsForTag(testTag)); + Assert.False(messenger.HasSubscriptionsForTag(null)); + Assert.False(messenger.HasSubscriptionsForTag(notExistingTag)); messenger.Unsubscribe(token); - Assert.Equal(true, messenger.HasSubscriptionsForTag(null)); - Assert.Equal(false, messenger.HasSubscriptionsForTag(testTag)); - Assert.Equal(false, messenger.HasSubscriptionsForTag(testTag)); - Assert.Equal(false, messenger.HasSubscriptionsForTag(null)); - Assert.Equal(false, messenger.HasSubscriptionsForTag(notExistingTag)); + Assert.True(messenger.HasSubscriptionsForTag(null)); + Assert.False(messenger.HasSubscriptionsForTag(testTag)); + Assert.False(messenger.HasSubscriptionsForTag(testTag)); + Assert.False(messenger.HasSubscriptionsForTag(null)); + Assert.False(messenger.HasSubscriptionsForTag(notExistingTag)); } [Fact] @@ -315,18 +315,18 @@ namespace MvvmCross.Plugins.Messenger.Test var testTag1 = "TestTag1"; var testTag2 = "TestTag2"; var messenger = new MvxMessengerHub(); - Assert.IsEmpty(messenger.GetSubscriptionTagsFor()); - Assert.IsEmpty(messenger.GetSubscriptionTagsFor()); + Assert.Empty(messenger.GetSubscriptionTagsFor()); + Assert.Empty(messenger.GetSubscriptionTagsFor()); var changeToken = messenger.Subscribe(message => { }); Assert.Equal(1, messenger.GetSubscriptionTagsFor().Count); - Assert.Equal(null, messenger.GetSubscriptionTagsFor()[0]); - Assert.IsEmpty(messenger.GetSubscriptionTagsFor()); + Assert.Null(messenger.GetSubscriptionTagsFor()[0]); + Assert.Empty(messenger.GetSubscriptionTagsFor()); var token = messenger.Subscribe(m => { // stuff }, tag: testTag1); Assert.Equal(1, messenger.GetSubscriptionTagsFor().Count); - Assert.Equal(null, messenger.GetSubscriptionTagsFor()[0]); + Assert.Null(messenger.GetSubscriptionTagsFor()[0]); Assert.Equal(1, messenger.GetSubscriptionTagsFor().Count); Assert.Equal(testTag1, messenger.GetSubscriptionTagsFor()[0]); var token2 = messenger.Subscribe(m => @@ -334,7 +334,7 @@ namespace MvvmCross.Plugins.Messenger.Test // stuff }, tag: testTag1); Assert.Equal(1, messenger.GetSubscriptionTagsFor().Count); - Assert.Equal(null, messenger.GetSubscriptionTagsFor()[0]); + Assert.Null(messenger.GetSubscriptionTagsFor()[0]); Assert.Equal(2, messenger.GetSubscriptionTagsFor().Count); Assert.Equal(testTag1, messenger.GetSubscriptionTagsFor()[0]); Assert.Equal(testTag1, messenger.GetSubscriptionTagsFor()[1]); @@ -343,25 +343,25 @@ namespace MvvmCross.Plugins.Messenger.Test // stuff }, tag: testTag2); Assert.Equal(1, messenger.GetSubscriptionTagsFor().Count); - Assert.Equal(null, messenger.GetSubscriptionTagsFor()[0]); + Assert.Null(messenger.GetSubscriptionTagsFor()[0]); Assert.Equal(3, messenger.GetSubscriptionTagsFor().Count); Assert.Equal(2, messenger.GetSubscriptionTagsFor().Where(x => x == testTag1).Count()); Assert.Equal(1, messenger.GetSubscriptionTagsFor().Where(x => x == testTag2).Count()); messenger.Unsubscribe(token); Assert.Equal(1, messenger.GetSubscriptionTagsFor().Count); - Assert.Equal(null, messenger.GetSubscriptionTagsFor()[0]); + Assert.Null(messenger.GetSubscriptionTagsFor()[0]); Assert.Equal(2, messenger.GetSubscriptionTagsFor().Count); Assert.Equal(1, messenger.GetSubscriptionTagsFor().Where(x => x == testTag1).Count()); Assert.Equal(1, messenger.GetSubscriptionTagsFor().Where(x => x == testTag2).Count()); messenger.Unsubscribe(token2); Assert.Equal(1, messenger.GetSubscriptionTagsFor().Count); - Assert.Equal(null, messenger.GetSubscriptionTagsFor()[0]); + Assert.Null(messenger.GetSubscriptionTagsFor()[0]); Assert.Equal(1, messenger.GetSubscriptionTagsFor().Count); Assert.Equal(0, messenger.GetSubscriptionTagsFor().Where(x => x == testTag1).Count()); Assert.Equal(1, messenger.GetSubscriptionTagsFor().Where(x => x == testTag2).Count()); messenger.Unsubscribe(token3); Assert.Equal(1, messenger.GetSubscriptionTagsFor().Count); - Assert.Equal(null, messenger.GetSubscriptionTagsFor()[0]); + Assert.Null(messenger.GetSubscriptionTagsFor()[0]); Assert.Equal(0, messenger.GetSubscriptionTagsFor().Count); } @@ -419,4 +419,4 @@ namespace MvvmCross.Plugins.Messenger.Test #warning TODO - weak references need more testing here really #warning TODO - async and ui threading need testing here really } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/Plugins.Network.UnitTest/RestCollection.cs b/MvvmCross.Tests/Plugins.Network.UnitTest/RestCollection.cs new file mode 100644 index 000000000..19c4b13c0 --- /dev/null +++ b/MvvmCross.Tests/Plugins.Network.UnitTest/RestCollection.cs @@ -0,0 +1,20 @@ +// SimpleRestTest.cs +// (c) Copyright Cirrious Ltd. http://www.cirrious.com +// MvvmCross is licensed using Microsoft Public License (Ms-PL) +// Contributions and inspirations noted in readme.md and license.txt +// +// Project Lead - Stuart Lodge, @slodge, me@slodge.com + +using MvvmCross.Test; +using Xunit; + +namespace MvvmCross.Plugins.Network.Test +{ + [CollectionDefinition("Rest")] + public class RestCollection : ICollectionFixture + { + // This class has no code, and is never created. Its purpose is simply + // to be the place to apply [CollectionDefinition] and all the + // ICollectionFixture<> interfaces. + } +} diff --git a/MvvmCross.Tests/Plugins.Network.UnitTest/SimpleRestTest.cs b/MvvmCross.Tests/Plugins.Network.UnitTest/SimpleRestTest.cs index 3d1b0f72a..655422cb1 100644 --- a/MvvmCross.Tests/Plugins.Network.UnitTest/SimpleRestTest.cs +++ b/MvvmCross.Tests/Plugins.Network.UnitTest/SimpleRestTest.cs @@ -8,25 +8,17 @@ using System.Threading.Tasks; using MvvmCross.Plugins.Json; using MvvmCross.Plugins.Network.Rest; using MvvmCross.Plugins.Network.Test.TestClasses.GoogleBooks; -using MvvmCross.Test.Core; using Xunit; namespace MvvmCross.Plugins.Network.Test { - - public class SimpleRestTest - : MvxIoCSupportingTest - { - - public void SetUp() - { - } + [Collection("Rest")] + public class SimpleRestTest + { [Fact] public async Task GetDataFromGoogleBooks() { - ClearAll(); - // not a real test yet.... var url = BooksService.GetSearchUrl("MonoTouch"); @@ -40,12 +32,12 @@ namespace MvvmCross.Plugins.Network.Test Exception exception = null; theResponse = await client.MakeRequestForAsync(request); - Assert.IsNotNull(theResponse); - Assert.IsNull(exception); - Assert.IsNotNull(theResponse.Result); + Assert.NotNull(theResponse); + Assert.Null(exception); + Assert.NotNull(theResponse.Result); Assert.Equal(HttpStatusCode.OK, theResponse.StatusCode); - Assert.IsTrue(theResponse.Result.items.Count == 10); - Assert.IsTrue(theResponse.Result.items[0].ToString().Contains("MonoTouch")); + Assert.True(theResponse.Result.items.Count == 10); + Assert.True(theResponse.Result.items[0].ToString().Contains("MonoTouch")); } } -} \ No newline at end of file +} diff --git a/MvvmCross.Tests/Plugins.ResxLocalization.UnitTest/MvxResxTextProviderTests.cs b/MvvmCross.Tests/Plugins.ResxLocalization.UnitTest/MvxResxTextProviderTests.cs index 60575c320..88faced12 100644 --- a/MvvmCross.Tests/Plugins.ResxLocalization.UnitTest/MvxResxTextProviderTests.cs +++ b/MvvmCross.Tests/Plugins.ResxLocalization.UnitTest/MvxResxTextProviderTests.cs @@ -13,18 +13,11 @@ namespace MvvmCross.Plugins.ResxLocalization.Tests private MockResourceManager _resourceManager; - public void SetUp() + public MvxResxTextProviderTests() { _resourceManager = new MockResourceManager(); } - [TearDown] - public void TearDown() - { - } - - #region Tests covering the 'GetText' method - [Fact] public void GetTextForExistingValueSupplyingNameOnlyReturnsDummyName() { @@ -71,13 +64,9 @@ namespace MvvmCross.Plugins.ResxLocalization.Tests var textProvider = new MvxResxTextProvider(_resourceManager); var actual = textProvider.GetText(null, null, "NonExistingKey"); - Assert.IsNull(actual); + Assert.Null(actual); } - #endregion - - #region Tests covering the 'TryGetText' method - [Fact] public void TryGetTextForExistingValueSupplyingNameOnlyReturnsTrue() { @@ -85,7 +74,7 @@ namespace MvvmCross.Plugins.ResxLocalization.Tests var expected = MockResourceManager.DummyName; string actual; - Assert.IsTrue(textProvider.TryGetText(out actual, null, null, MockResourceManager.DummyName)); + Assert.True(textProvider.TryGetText(out actual, null, null, MockResourceManager.DummyName)); Assert.Equal(expected, actual); } @@ -96,7 +85,7 @@ namespace MvvmCross.Plugins.ResxLocalization.Tests var expected = $"{MockResourceManager.LocalizationNamespace}.{MockResourceManager.DummyName}"; string actual; - Assert.IsTrue(textProvider.TryGetText(out actual, MockResourceManager.LocalizationNamespace, null, MockResourceManager.DummyName)); + Assert.True(textProvider.TryGetText(out actual, MockResourceManager.LocalizationNamespace, null, MockResourceManager.DummyName)); Assert.Equal(expected, actual); } @@ -107,7 +96,7 @@ namespace MvvmCross.Plugins.ResxLocalization.Tests var expected = $"{MockResourceManager.TypeKey}.{MockResourceManager.DummyName}"; string actual; - Assert.IsTrue(textProvider.TryGetText(out actual, null, MockResourceManager.TypeKey, MockResourceManager.DummyName)); + Assert.True(textProvider.TryGetText(out actual, null, MockResourceManager.TypeKey, MockResourceManager.DummyName)); Assert.Equal(expected, actual); } @@ -118,7 +107,7 @@ namespace MvvmCross.Plugins.ResxLocalization.Tests var expected = $"{MockResourceManager.LocalizationNamespace}.{MockResourceManager.TypeKey}.{MockResourceManager.DummyName}"; string actual; - Assert.IsTrue(textProvider.TryGetText(out actual, MockResourceManager.LocalizationNamespace, MockResourceManager.TypeKey, MockResourceManager.DummyName)); + Assert.True(textProvider.TryGetText(out actual, MockResourceManager.LocalizationNamespace, MockResourceManager.TypeKey, MockResourceManager.DummyName)); Assert.Equal(expected, actual); } @@ -128,10 +117,8 @@ namespace MvvmCross.Plugins.ResxLocalization.Tests var textProvider = new MvxResxTextProvider(_resourceManager); string actual; - Assert.IsFalse(textProvider.TryGetText(out actual, null, null, "NonExistingKey")); - Assert.IsNull(actual); + Assert.False(textProvider.TryGetText(out actual, null, null, "NonExistingKey")); + Assert.Null(actual); } - - #endregion } } diff --git a/MvvmCross.sln b/MvvmCross.sln index 9046baba1..2b2b17f5b 100644 --- a/MvvmCross.sln +++ b/MvvmCross.sln @@ -115,7 +115,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Playground.Droid", "Project EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Playground.Forms.Droid", "Projects\Playground\Playground.Forms.Droid\Playground.Forms.Droid.csproj", "{A8A8B9B3-34FA-4769-AE81-4D80F9BDC3BB}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvvmCross.Test", "MvvmCross.Tests\MvvmCross.Test\MvvmCross.Test.csproj", "{8DFE6A59-AD7D-4916-ABF3-D2D1B0F55858}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MvvmCross.Test", "MvvmCross.Tests\MvvmCross.Test\MvvmCross.Test.csproj", "{8DFE6A59-AD7D-4916-ABF3-D2D1B0F55858}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/MvvmCross/Base/Logging/LogProviders/ConsoleLogProvider.cs b/MvvmCross/Base/Logging/LogProviders/ConsoleLogProvider.cs index 5189e4275..5a4ab9f90 100644 --- a/MvvmCross/Base/Logging/LogProviders/ConsoleLogProvider.cs +++ b/MvvmCross/Base/Logging/LogProviders/ConsoleLogProvider.cs @@ -5,9 +5,12 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.Runtime.CompilerServices; using System.Text; using MvvmCross.Platform.Logging; +[assembly: InternalsVisibleTo("MvvmCross.Test")] + namespace MvvmCross.Platform.Logging.LogProviders { internal sealed class ConsoleLogProvider : MvxBaseLogProvider