Fix a whole bunch of tests
This commit is contained in:
Родитель
409765880f
Коммит
937abb1c39
|
@ -3,6 +3,7 @@
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using MvvmCross.Binding;
|
||||||
using MvvmCross.Core;
|
using MvvmCross.Core;
|
||||||
using MvvmCross.Core.Platform;
|
using MvvmCross.Core.Platform;
|
||||||
using MvvmCross.Platform.Core;
|
using MvvmCross.Platform.Core;
|
||||||
|
@ -30,12 +31,13 @@ namespace MvvmCross.Test
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ClearAll()
|
public virtual void ClearAll(IMvxIocOptions options = null)
|
||||||
{
|
{
|
||||||
// fake set up of the IoC
|
// fake set up of the IoC
|
||||||
Reset();
|
Reset();
|
||||||
Ioc = MvxIoCProvider.Initialize(CreateIocOptions());
|
Ioc = MvxIoCProvider.Initialize(options ?? CreateIocOptions());
|
||||||
Ioc.RegisterSingleton(Ioc);
|
Ioc.RegisterSingleton(Ioc);
|
||||||
|
CreateLog();
|
||||||
InitializeSingletonCache();
|
InitializeSingletonCache();
|
||||||
InitializeMvxSettings();
|
InitializeMvxSettings();
|
||||||
AdditionalSetup();
|
AdditionalSetup();
|
||||||
|
@ -43,7 +45,11 @@ namespace MvvmCross.Test
|
||||||
|
|
||||||
public void InitializeSingletonCache()
|
public void InitializeSingletonCache()
|
||||||
{
|
{
|
||||||
MvxSingletonCache.Initialize();
|
if (MvxSingletonCache.Instance == null)
|
||||||
|
MvxSingletonCache.Initialize();
|
||||||
|
|
||||||
|
if (MvxBindingSingletonCache.Instance == null)
|
||||||
|
MvxBindingSingletonCache.Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void InitializeMvxSettings()
|
protected virtual void InitializeMvxSettings()
|
||||||
|
@ -53,7 +59,18 @@ namespace MvvmCross.Test
|
||||||
|
|
||||||
protected virtual void AdditionalSetup()
|
protected virtual void AdditionalSetup()
|
||||||
{
|
{
|
||||||
Ioc.RegisterSingleton<IMvxLogProvider>(new TestLogProvider());
|
}
|
||||||
|
|
||||||
|
protected virtual void CreateLog()
|
||||||
|
{
|
||||||
|
var logProvider = new TestLogProvider();
|
||||||
|
Ioc.RegisterSingleton<IMvxLogProvider>(logProvider);
|
||||||
|
|
||||||
|
var globalLog = logProvider.GetLogFor<MvxLog>();
|
||||||
|
MvxLog.Instance = globalLog;
|
||||||
|
Ioc.RegisterSingleton(globalLog);
|
||||||
|
|
||||||
|
var pluginLog = logProvider.GetLogFor("MvxPlugin");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetInvariantCulture()
|
public void SetInvariantCulture()
|
||||||
|
|
|
@ -9,12 +9,21 @@ using MvvmCross.Platform.IoC;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using MvvmCross.Test;
|
||||||
|
|
||||||
namespace MvvmCross.Platform.Test
|
namespace MvvmCross.Platform.Test
|
||||||
{
|
{
|
||||||
|
[Collection("MvxTest")]
|
||||||
public class MvxIocTest
|
public class MvxIocTest
|
||||||
{
|
{
|
||||||
|
private readonly MvxTestFixture _fixture;
|
||||||
|
|
||||||
|
public MvxIocTest(MvxTestFixture fixture)
|
||||||
|
{
|
||||||
|
_fixture = fixture;
|
||||||
|
_fixture.ClearAll();
|
||||||
|
}
|
||||||
|
|
||||||
public interface IA
|
public interface IA
|
||||||
{
|
{
|
||||||
IB B { get; }
|
IB B { get; }
|
||||||
|
@ -112,19 +121,16 @@ namespace MvvmCross.Platform.Test
|
||||||
public void TryResolve_CircularButSafeDynamicWithOptionOff_ReturnsTrue()
|
public void TryResolve_CircularButSafeDynamicWithOptionOff_ReturnsTrue()
|
||||||
{
|
{
|
||||||
COdd.FirstTime = true;
|
COdd.FirstTime = true;
|
||||||
MvxSingleton.ClearAllSingletons();
|
_fixture.ClearAll(new MvxIocOptions()
|
||||||
var options = new MvxIocOptions()
|
|
||||||
{
|
{
|
||||||
TryToDetectDynamicCircularReferences = false
|
TryToDetectDynamicCircularReferences = false
|
||||||
};
|
});
|
||||||
var instance = MvxIoCProvider.Initialize(options);
|
|
||||||
|
|
||||||
Mvx.RegisterType<IA, A>();
|
_fixture.Ioc.RegisterType<IA, A>();
|
||||||
Mvx.RegisterType<IB, B>();
|
_fixture.Ioc.RegisterType<IB, B>();
|
||||||
Mvx.RegisterType<IC, COdd>();
|
_fixture.Ioc.RegisterType<IC, COdd>();
|
||||||
|
|
||||||
IA a;
|
var result = _fixture.Ioc.TryResolve(out IA a);
|
||||||
var result = Mvx.TryResolve(out a);
|
|
||||||
Assert.True(result);
|
Assert.True(result);
|
||||||
Assert.NotNull(a);
|
Assert.NotNull(a);
|
||||||
}
|
}
|
||||||
|
@ -133,15 +139,13 @@ namespace MvvmCross.Platform.Test
|
||||||
public void TryResolve_CircularButSafeDynamicWithOptionOn_ReturnsFalse()
|
public void TryResolve_CircularButSafeDynamicWithOptionOn_ReturnsFalse()
|
||||||
{
|
{
|
||||||
COdd.FirstTime = true;
|
COdd.FirstTime = true;
|
||||||
MvxSingleton.ClearAllSingletons();
|
_fixture.ClearAll();
|
||||||
var instance = MvxIoCProvider.Initialize();
|
|
||||||
|
|
||||||
Mvx.RegisterType<IA, A>();
|
_fixture.Ioc.RegisterType<IA, A>();
|
||||||
Mvx.RegisterType<IB, B>();
|
_fixture.Ioc.RegisterType<IB, B>();
|
||||||
Mvx.RegisterType<IC, COdd>();
|
_fixture.Ioc.RegisterType<IC, COdd>();
|
||||||
|
|
||||||
IA a;
|
var result = _fixture.Ioc.TryResolve(out IA a);
|
||||||
var result = Mvx.TryResolve(out a);
|
|
||||||
Assert.False(result);
|
Assert.False(result);
|
||||||
Assert.Null(a);
|
Assert.Null(a);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,175 +0,0 @@
|
||||||
// Licensed to the .NET Foundation under one or more agreements.
|
|
||||||
// The .NET Foundation licenses this file to you under the MS-PL license.
|
|
||||||
// See the LICENSE file in the project root for more information.
|
|
||||||
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using Xunit;
|
|
||||||
|
|
||||||
namespace MvvmCross.Platform.Test
|
|
||||||
{
|
|
||||||
|
|
||||||
public class ReflectionExtensionsTests
|
|
||||||
{
|
|
||||||
private class TestClass
|
|
||||||
{
|
|
||||||
public static readonly object PublicStaticField = new object();
|
|
||||||
|
|
||||||
public object PublicInstanceField1 = new object();
|
|
||||||
public object PublicInstanceField2 = new object();
|
|
||||||
|
|
||||||
private object _privateInstanceField1 = new object();
|
|
||||||
|
|
||||||
public TestClass()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public TestClass(object param1)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TestSubClass : TestBaseClass
|
|
||||||
{
|
|
||||||
public object PublicSubInstanceField1 = new object();
|
|
||||||
|
|
||||||
private object _privateInstanceField1 = new object();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TestBaseClass
|
|
||||||
{
|
|
||||||
public object PublicBaseInstanceField1 = new object();
|
|
||||||
public object PublicBaseInstanceField2 = new object();
|
|
||||||
|
|
||||||
private object _privateBaseInstanceField1 = new object();
|
|
||||||
|
|
||||||
public TestBaseClass()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Fields
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void TestGetStaticFields()
|
|
||||||
{
|
|
||||||
// Act
|
|
||||||
var fields = typeof(TestClass).GetFields(BindingFlags.Static);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Equal(1, fields.Count());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void TestGetPublicInstanceFields()
|
|
||||||
{
|
|
||||||
// Act
|
|
||||||
var fields = typeof(TestClass).GetFields(BindingFlags.Public | BindingFlags.Instance);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Equal(2, fields.Count());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void TestGetAllInstanceFields()
|
|
||||||
{
|
|
||||||
// Act
|
|
||||||
var fields = typeof(TestClass).GetFields(BindingFlags.Instance);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Equal(3, fields.Count());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void TestGetAllFields()
|
|
||||||
{
|
|
||||||
// Act
|
|
||||||
var fields = typeof(TestClass).GetFields();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Equal(3, fields.Count());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void TestGetInstanceFieldByNameStaticFieldSpecified()
|
|
||||||
{
|
|
||||||
// Act
|
|
||||||
var field = typeof(TestClass).GetField("PublicStaticField", BindingFlags.Public | BindingFlags.Static);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.NotNull(field);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void TestGetInstanceFieldByNameReturnsNullIfStaticFieldSpecified()
|
|
||||||
{
|
|
||||||
// Act
|
|
||||||
var field = typeof(TestClass).GetField("PublicStaticField", BindingFlags.Public | BindingFlags.Instance);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Null(field);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void TestGetInstanceFieldByNameInstanceFieldSpecified()
|
|
||||||
{
|
|
||||||
// Act
|
|
||||||
var field = typeof(TestClass).GetField("PublicInstanceField1", BindingFlags.Public | BindingFlags.Instance);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.NotNull(field);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void TestGetStaticFieldByNameReturnsNullIfInstanceFieldSpecified()
|
|
||||||
{
|
|
||||||
// Act
|
|
||||||
var field = typeof(TestClass).GetField("PublicInstanceField1", BindingFlags.Public | BindingFlags.Static);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Null(field);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void TestFlattenHierarchyGetsAllFields()
|
|
||||||
{
|
|
||||||
// Act
|
|
||||||
var fields = typeof(TestSubClass).GetFields(BindingFlags.Public | BindingFlags.FlattenHierarchy);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Equal(3, fields.Count());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void TestFlattenHierarchyGetsOnlyDeclaredFields()
|
|
||||||
{
|
|
||||||
// Act
|
|
||||||
var fields = typeof(TestSubClass).GetFields(BindingFlags.Public);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Equal(1, fields.Count());
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Fields
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void TestGetConstructors()
|
|
||||||
{
|
|
||||||
// Act
|
|
||||||
var ctors = typeof(TestClass).GetConstructors();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Equal(2, ctors.Count());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void TestGetBaseConstructor()
|
|
||||||
{
|
|
||||||
// Act
|
|
||||||
var ctors = typeof(TestSubClass).GetConstructors();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Equal(1, ctors.Count());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -20,7 +20,7 @@ using Xunit;
|
||||||
namespace MvvmCross.Binding.Test.Binders
|
namespace MvvmCross.Binding.Test.Binders
|
||||||
{
|
{
|
||||||
[Collection("MvxTest")]
|
[Collection("MvxTest")]
|
||||||
public class MvxSourceStepTests : IClassFixture<MvxTestFixture>
|
public class MvxSourceStepTests
|
||||||
{
|
{
|
||||||
private readonly MvxTestFixture _fixture;
|
private readonly MvxTestFixture _fixture;
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ using Xunit;
|
||||||
namespace MvvmCross.Binding.Test.Bindings
|
namespace MvvmCross.Binding.Test.Bindings
|
||||||
{
|
{
|
||||||
[Collection("MvxTest")]
|
[Collection("MvxTest")]
|
||||||
public class MvxFullBindingConstructionTest : IClassFixture<MvxTestFixture>
|
public class MvxFullBindingConstructionTest
|
||||||
{
|
{
|
||||||
private readonly MvxTestFixture _fixture;
|
private readonly MvxTestFixture _fixture;
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ using Xunit;
|
||||||
namespace MvvmCross.Binding.Test.Bindings
|
namespace MvvmCross.Binding.Test.Bindings
|
||||||
{
|
{
|
||||||
[Collection("MvxTest")]
|
[Collection("MvxTest")]
|
||||||
public class MvxFullBindingTest : IClassFixture<MvxTestFixture>
|
public class MvxFullBindingTest
|
||||||
{
|
{
|
||||||
private readonly MvxTestFixture _fixture;
|
private readonly MvxTestFixture _fixture;
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ using Xunit;
|
||||||
namespace MvvmCross.Binding.Test.Bindings
|
namespace MvvmCross.Binding.Test.Bindings
|
||||||
{
|
{
|
||||||
[Collection("MvxTest")]
|
[Collection("MvxTest")]
|
||||||
public class MvxFullBindingValueConversionTest : IClassFixture<MvxTestFixture>
|
public class MvxFullBindingValueConversionTest
|
||||||
{
|
{
|
||||||
private readonly MvxTestFixture _fixture;
|
private readonly MvxTestFixture _fixture;
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ using Xunit;
|
||||||
namespace MvvmCross.Binding.Test.ExpressionParse
|
namespace MvvmCross.Binding.Test.ExpressionParse
|
||||||
{
|
{
|
||||||
[Collection("MvxTest")]
|
[Collection("MvxTest")]
|
||||||
public class MvxExpressionBindingTest : IClassFixture<MvxTestFixture>
|
public class MvxExpressionBindingTest
|
||||||
{
|
{
|
||||||
private readonly MvxTestFixture _fixture;
|
private readonly MvxTestFixture _fixture;
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@ using Xunit;
|
||||||
|
|
||||||
namespace MvvmCross.Binding.Test.ExtensionMethods
|
namespace MvvmCross.Binding.Test.ExtensionMethods
|
||||||
{
|
{
|
||||||
|
[Collection("MvxTest")]
|
||||||
public class MakeSafeValueTest : IClassFixture<MvxTestFixture>
|
public class MakeSafeValueTest
|
||||||
{
|
{
|
||||||
private readonly MvxTestFixture _fixture;
|
private readonly MvxTestFixture _fixture;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ namespace MvvmCross.Binding.Test.ExtensionMethods
|
||||||
public void TestIntValues()
|
public void TestIntValues()
|
||||||
{
|
{
|
||||||
_fixture.ClearAll();
|
_fixture.ClearAll();
|
||||||
Mvx.RegisterSingleton<IMvxAutoValueConverters>(new MockAutoValueConverters());
|
_fixture.Ioc.RegisterSingleton<IMvxAutoValueConverters>(new MockAutoValueConverters());
|
||||||
|
|
||||||
Assert.Equal(0, typeof(int).MakeSafeValue(0));
|
Assert.Equal(0, typeof(int).MakeSafeValue(0));
|
||||||
Assert.Equal(0, typeof(int).MakeSafeValue(null));
|
Assert.Equal(0, typeof(int).MakeSafeValue(null));
|
||||||
|
@ -55,7 +55,7 @@ namespace MvvmCross.Binding.Test.ExtensionMethods
|
||||||
public void TestDoubleValues()
|
public void TestDoubleValues()
|
||||||
{
|
{
|
||||||
_fixture.ClearAll();
|
_fixture.ClearAll();
|
||||||
Mvx.RegisterSingleton<IMvxAutoValueConverters>(new MockAutoValueConverters());
|
_fixture.Ioc.RegisterSingleton<IMvxAutoValueConverters>(new MockAutoValueConverters());
|
||||||
|
|
||||||
Assert.Equal(0.0, typeof(double).MakeSafeValue(0.0));
|
Assert.Equal(0.0, typeof(double).MakeSafeValue(0.0));
|
||||||
Assert.Equal(0.0, typeof(double).MakeSafeValue(null));
|
Assert.Equal(0.0, typeof(double).MakeSafeValue(null));
|
||||||
|
@ -71,16 +71,16 @@ namespace MvvmCross.Binding.Test.ExtensionMethods
|
||||||
public void TestFloatValues()
|
public void TestFloatValues()
|
||||||
{
|
{
|
||||||
_fixture.ClearAll();
|
_fixture.ClearAll();
|
||||||
Mvx.RegisterSingleton<IMvxAutoValueConverters>(new MockAutoValueConverters());
|
_fixture.Ioc.RegisterSingleton<IMvxAutoValueConverters>(new MockAutoValueConverters());
|
||||||
|
|
||||||
Assert.Equal(0.0f, typeof(double).MakeSafeValue(0.0f));
|
Assert.Equal(0.0f, typeof(float).MakeSafeValue(0.0f));
|
||||||
Assert.Equal(0.0f, typeof(double).MakeSafeValue(null));
|
Assert.Equal(0.0f, typeof(float).MakeSafeValue(null));
|
||||||
Assert.Equal(1.0f, typeof(double).MakeSafeValue(1.0f));
|
Assert.Equal(1.0f, typeof(float).MakeSafeValue(1.0f));
|
||||||
Assert.Equal(0.0f, typeof(double?).MakeSafeValue(0.0f));
|
Assert.Equal(0.0f, typeof(float?).MakeSafeValue(0.0f));
|
||||||
Assert.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(float?).MakeSafeValue(1.0f));
|
||||||
Assert.Equal(1.0f, typeof(double).MakeSafeValue(1f));
|
Assert.Equal(1.0f, typeof(float).MakeSafeValue(1f));
|
||||||
Assert.Equal(0.0f, typeof(double?).MakeSafeValue(0f));
|
Assert.Equal(0.0f, typeof(float?).MakeSafeValue(0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MyTest
|
public class MyTest
|
||||||
|
@ -95,7 +95,7 @@ namespace MvvmCross.Binding.Test.ExtensionMethods
|
||||||
public void TestStringValues()
|
public void TestStringValues()
|
||||||
{
|
{
|
||||||
_fixture.ClearAll();
|
_fixture.ClearAll();
|
||||||
Mvx.RegisterSingleton<IMvxAutoValueConverters>(new MockAutoValueConverters());
|
_fixture.Ioc.RegisterSingleton<IMvxAutoValueConverters>(new MockAutoValueConverters());
|
||||||
|
|
||||||
Assert.Equal("0", typeof(string).MakeSafeValue(0.0));
|
Assert.Equal("0", typeof(string).MakeSafeValue(0.0));
|
||||||
Assert.Null(typeof(string).MakeSafeValue(null));
|
Assert.Null(typeof(string).MakeSafeValue(null));
|
||||||
|
@ -115,7 +115,7 @@ namespace MvvmCross.Binding.Test.ExtensionMethods
|
||||||
public void TestEnumValues()
|
public void TestEnumValues()
|
||||||
{
|
{
|
||||||
_fixture.ClearAll();
|
_fixture.ClearAll();
|
||||||
Mvx.RegisterSingleton<IMvxAutoValueConverters>(new MockAutoValueConverters());
|
_fixture.Ioc.RegisterSingleton<IMvxAutoValueConverters>(new MockAutoValueConverters());
|
||||||
|
|
||||||
Assert.Equal(SampleEnum.Defaulto, typeof(SampleEnum).MakeSafeValue(0));
|
Assert.Equal(SampleEnum.Defaulto, typeof(SampleEnum).MakeSafeValue(0));
|
||||||
Assert.Equal(SampleEnum.Defaulto, typeof(SampleEnum).MakeSafeValue(null));
|
Assert.Equal(SampleEnum.Defaulto, typeof(SampleEnum).MakeSafeValue(null));
|
||||||
|
@ -128,7 +128,7 @@ namespace MvvmCross.Binding.Test.ExtensionMethods
|
||||||
public void TestBoolValues()
|
public void TestBoolValues()
|
||||||
{
|
{
|
||||||
_fixture.ClearAll();
|
_fixture.ClearAll();
|
||||||
Mvx.RegisterSingleton<IMvxAutoValueConverters>(new MockAutoValueConverters());
|
_fixture.Ioc.RegisterSingleton<IMvxAutoValueConverters>(new MockAutoValueConverters());
|
||||||
|
|
||||||
Assert.False((bool)typeof(bool).MakeSafeValue(0));
|
Assert.False((bool)typeof(bool).MakeSafeValue(0));
|
||||||
Assert.False((bool)typeof(bool).MakeSafeValue(null));
|
Assert.False((bool)typeof(bool).MakeSafeValue(null));
|
||||||
|
@ -159,7 +159,7 @@ namespace MvvmCross.Binding.Test.ExtensionMethods
|
||||||
public void TestObjectValues()
|
public void TestObjectValues()
|
||||||
{
|
{
|
||||||
_fixture.ClearAll();
|
_fixture.ClearAll();
|
||||||
Mvx.RegisterSingleton<IMvxAutoValueConverters>(new MockAutoValueConverters());
|
_fixture.Ioc.RegisterSingleton<IMvxAutoValueConverters>(new MockAutoValueConverters());
|
||||||
|
|
||||||
var foo = new Foo();
|
var foo = new Foo();
|
||||||
Assert.Equal(foo, typeof(FooBase).MakeSafeValue(foo));
|
Assert.Equal(foo, typeof(FooBase).MakeSafeValue(foo));
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace MvvmCross.Binding.Test.Parse.Binding.Swiss
|
||||||
Path = "Foo",
|
Path = "Foo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ConverterParameter = 12
|
ConverterParameter = 12L
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace MvvmCross.Binding.Test.Parse.Binding.Swiss
|
||||||
},
|
},
|
||||||
new MvxSerializableBindingDescription()
|
new MvxSerializableBindingDescription()
|
||||||
{
|
{
|
||||||
Literal = 12,
|
Literal = 12L,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ namespace MvvmCross.Binding.Test.Parse.Binding.Swiss
|
||||||
{
|
{
|
||||||
Path = "Foo2",
|
Path = "Foo2",
|
||||||
Converter = "Second",
|
Converter = "Second",
|
||||||
FallbackValue = 23,
|
FallbackValue = 23L,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -236,7 +236,7 @@ namespace MvvmCross.Binding.Test.Parse.Binding.Swiss
|
||||||
},
|
},
|
||||||
new MvxSerializableBindingDescription()
|
new MvxSerializableBindingDescription()
|
||||||
{
|
{
|
||||||
Literal = 23,
|
Literal = 23L,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ namespace MvvmCross.Binding.Test.Parse.Binding.Swiss
|
||||||
{
|
{
|
||||||
Path = "Foo2",
|
Path = "Foo2",
|
||||||
Converter = "Second",
|
Converter = "Second",
|
||||||
FallbackValue = 23,
|
FallbackValue = 23L,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -348,7 +348,7 @@ namespace MvvmCross.Binding.Test.Parse.Binding.Swiss
|
||||||
{
|
{
|
||||||
Path = "Foo2",
|
Path = "Foo2",
|
||||||
Converter = "Second",
|
Converter = "Second",
|
||||||
FallbackValue = 23,
|
FallbackValue = 23L,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -175,14 +175,14 @@ namespace MvvmCross.Binding.Test.Parse.PropertyPath
|
||||||
|
|
||||||
private static void AssertIsSimplePropertyToken(MvxPropertyToken token, string text)
|
private static void AssertIsSimplePropertyToken(MvxPropertyToken token, string text)
|
||||||
{
|
{
|
||||||
Assert.IsType<MvxPropertyNamePropertyToken>(token);
|
Assert.IsAssignableFrom<MvxPropertyNamePropertyToken>(token);
|
||||||
Assert.Equal(text, ((MvxPropertyNamePropertyToken)token).PropertyName);
|
Assert.Equal(text, ((MvxPropertyNamePropertyToken)token).PropertyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AssertIsIndexerPropertyToken<T, TSpecific>(MvxPropertyToken token, T value)
|
private static void AssertIsIndexerPropertyToken<T, TSpecific>(MvxPropertyToken token, T value)
|
||||||
{
|
{
|
||||||
Assert.IsType<MvxIndexerPropertyToken<T>>(token);
|
Assert.IsAssignableFrom<MvxIndexerPropertyToken<T>>(token);
|
||||||
Assert.IsType<TSpecific>(token);
|
Assert.IsAssignableFrom<TSpecific>(token);
|
||||||
Assert.Equal(value, ((MvxIndexerPropertyToken<T>)token).Key);
|
Assert.Equal(value, ((MvxIndexerPropertyToken<T>)token).Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,12 @@ using System.Linq;
|
||||||
using MvvmCross.Core.ViewModels;
|
using MvvmCross.Core.ViewModels;
|
||||||
using MvvmCross.Core.Views;
|
using MvvmCross.Core.Views;
|
||||||
using MvvmCross.Platform.Core;
|
using MvvmCross.Platform.Core;
|
||||||
|
using MvvmCross.Platform.Logging;
|
||||||
|
|
||||||
namespace MvvmCross.Test.Mocks.Dispatchers
|
namespace MvvmCross.Test.Mocks.Dispatchers
|
||||||
{
|
{
|
||||||
public class NavigationMockDispatcher
|
public class NavigationMockDispatcher
|
||||||
: MvxMainThreadDispatcher, IMvxViewDispatcher
|
: IMvxMainThreadDispatcher, IMvxViewDispatcher
|
||||||
{
|
{
|
||||||
public readonly List<MvxViewModelRequest> Requests = new List<MvxViewModelRequest>();
|
public readonly List<MvxViewModelRequest> Requests = new List<MvxViewModelRequest>();
|
||||||
public readonly List<MvxPresentationHint> Hints = new List<MvxPresentationHint>();
|
public readonly List<MvxPresentationHint> Hints = new List<MvxPresentationHint>();
|
||||||
|
@ -32,7 +33,7 @@ namespace MvvmCross.Test.Mocks.Dispatchers
|
||||||
debugString += $"with parameters: {string.Join(",", request.ParameterValues.Select(pair => $"{{ {pair.Key}={pair.Value} }}"))}";
|
debugString += $"with parameters: {string.Join(",", request.ParameterValues.Select(pair => $"{{ {pair.Key}={pair.Value} }}"))}";
|
||||||
else
|
else
|
||||||
debugString += "without parameters";
|
debugString += "without parameters";
|
||||||
Debug.WriteLine(debugString);
|
MvxTestLog.Instance.Log(MvxLogLevel.Debug, () => debugString);
|
||||||
|
|
||||||
Requests.Add(request);
|
Requests.Add(request);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Licensed to the .NET Foundation under one or more agreements.
|
// Licensed to the .NET Foundation under one or more agreements.
|
||||||
// The .NET Foundation licenses this file to you under the MS-PL license.
|
// The .NET Foundation licenses this file to you under the MS-PL license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
@ -16,13 +16,13 @@ namespace MvvmCross.Test.Navigation
|
||||||
{
|
{
|
||||||
[Collection("MvxTest")]
|
[Collection("MvxTest")]
|
||||||
public class NavigationServiceTests
|
public class NavigationServiceTests
|
||||||
: IClassFixture<MvxTestFixture>
|
|
||||||
{
|
{
|
||||||
private readonly MvxTestFixture _fixture;
|
private readonly MvxTestFixture _fixture;
|
||||||
|
|
||||||
public NavigationServiceTests(MvxTestFixture fixture)
|
public NavigationServiceTests(MvxTestFixture fixture)
|
||||||
{
|
{
|
||||||
_fixture = fixture;
|
_fixture = fixture;
|
||||||
|
_fixture.ClearAll();
|
||||||
AdditionalSetup(fixture);
|
AdditionalSetup(fixture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ namespace MvvmCross.Test.Navigation
|
||||||
{
|
{
|
||||||
[Collection("MvxTest")]
|
[Collection("MvxTest")]
|
||||||
public class RoutingServiceTests
|
public class RoutingServiceTests
|
||||||
: IClassFixture<MvxTestFixture>
|
|
||||||
{
|
{
|
||||||
protected Mock<NavigationMockDispatcher> MockDispatcher;
|
protected Mock<NavigationMockDispatcher> MockDispatcher;
|
||||||
protected IMvxNavigationService RoutingService;
|
protected IMvxNavigationService RoutingService;
|
||||||
|
@ -35,6 +34,7 @@ namespace MvvmCross.Test.Navigation
|
||||||
public RoutingServiceTests(MvxTestFixture fixture)
|
public RoutingServiceTests(MvxTestFixture fixture)
|
||||||
{
|
{
|
||||||
_fixture = fixture;
|
_fixture = fixture;
|
||||||
|
_fixture.ClearAll();
|
||||||
|
|
||||||
MvxNavigationService.LoadRoutes(new[] { typeof(RoutingServiceTests).Assembly });
|
MvxNavigationService.LoadRoutes(new[] { typeof(RoutingServiceTests).Assembly });
|
||||||
// ReSharper disable once AssignNullToNotNullAttribute
|
// ReSharper disable once AssignNullToNotNullAttribute
|
||||||
|
|
|
@ -13,7 +13,6 @@ namespace MvvmCross.Test.Parse
|
||||||
{
|
{
|
||||||
[Collection("MvxTest")]
|
[Collection("MvxTest")]
|
||||||
public class MvxStringDictionaryTextSerializerTest
|
public class MvxStringDictionaryTextSerializerTest
|
||||||
: IClassFixture<MvxTestFixture>
|
|
||||||
{
|
{
|
||||||
private readonly MvxTestFixture _fixture;
|
private readonly MvxTestFixture _fixture;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Licensed to the .NET Foundation under one or more agreements.
|
// Licensed to the .NET Foundation under one or more agreements.
|
||||||
// The .NET Foundation licenses this file to you under the MS-PL license.
|
// The .NET Foundation licenses this file to you under the MS-PL license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ using Xunit;
|
||||||
namespace MvvmCross.Test.Platform
|
namespace MvvmCross.Test.Platform
|
||||||
{
|
{
|
||||||
[Collection("MvxTest")]
|
[Collection("MvxTest")]
|
||||||
public class MvxSimplePropertyDictionaryExtensionMethodsTests : IClassFixture<MvxTestFixture>
|
public class MvxSimplePropertyDictionaryExtensionMethodsTests
|
||||||
{
|
{
|
||||||
private readonly MvxTestFixture _fixture;
|
private readonly MvxTestFixture _fixture;
|
||||||
|
|
||||||
|
|
|
@ -10,13 +10,14 @@ using Xunit;
|
||||||
namespace MvvmCross.Test.Platform
|
namespace MvvmCross.Test.Platform
|
||||||
{
|
{
|
||||||
[Collection("MvxTest")]
|
[Collection("MvxTest")]
|
||||||
public class MvxStringToTypeParserTest : IClassFixture<MvxTestFixture>
|
public class MvxStringToTypeParserTest
|
||||||
{
|
{
|
||||||
private readonly MvxTestFixture _fixture;
|
private readonly MvxTestFixture _fixture;
|
||||||
|
|
||||||
public MvxStringToTypeParserTest(MvxTestFixture fixture)
|
public MvxStringToTypeParserTest(MvxTestFixture fixture)
|
||||||
{
|
{
|
||||||
_fixture = fixture;
|
_fixture = fixture;
|
||||||
|
_fixture.ClearAll();
|
||||||
_fixture.SetInvariantCulture();
|
_fixture.SetInvariantCulture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ using Xunit;
|
||||||
namespace MvvmCross.Test.Platform
|
namespace MvvmCross.Test.Platform
|
||||||
{
|
{
|
||||||
[Collection("MvxTest")]
|
[Collection("MvxTest")]
|
||||||
public class MvxViewModelByNameLookupTest : IClassFixture<MvxTestFixture>
|
public class MvxViewModelByNameLookupTest
|
||||||
{
|
{
|
||||||
private readonly MvxTestFixture _fixture;
|
private readonly MvxTestFixture _fixture;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Licensed to the .NET Foundation under one or more agreements.
|
// Licensed to the .NET Foundation under one or more agreements.
|
||||||
// The .NET Foundation licenses this file to you under the MS-PL license.
|
// The .NET Foundation licenses this file to you under the MS-PL license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ using Xunit;
|
||||||
namespace MvvmCross.Test.Platform
|
namespace MvvmCross.Test.Platform
|
||||||
{
|
{
|
||||||
[Collection("MvxTest")]
|
[Collection("MvxTest")]
|
||||||
public class MvxViewModelViewLookupBuilderTest : IClassFixture<MvxTestFixture>
|
public class MvxViewModelViewLookupBuilderTest
|
||||||
{
|
{
|
||||||
private readonly MvxTestFixture _fixture;
|
private readonly MvxTestFixture _fixture;
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ using Xunit;
|
||||||
namespace MvvmCross.Test.Platform
|
namespace MvvmCross.Test.Platform
|
||||||
{
|
{
|
||||||
[Collection("MvxTest")]
|
[Collection("MvxTest")]
|
||||||
public class MvxViewModelViewTypeFinderTest : IClassFixture<MvxTestFixture>
|
public class MvxViewModelViewTypeFinderTest
|
||||||
{
|
{
|
||||||
private readonly MvxTestFixture _fixture;
|
private readonly MvxTestFixture _fixture;
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ using Xunit;
|
||||||
namespace MvvmCross.Test.ViewModels
|
namespace MvvmCross.Test.ViewModels
|
||||||
{
|
{
|
||||||
[Collection("MvxTest")]
|
[Collection("MvxTest")]
|
||||||
public class MvxBundleTest : IClassFixture<MvxTestFixture>
|
public class MvxBundleTest
|
||||||
{
|
{
|
||||||
private readonly MvxTestFixture _fixture;
|
private readonly MvxTestFixture _fixture;
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ using Xunit;
|
||||||
namespace MvvmCross.Test.ViewModels
|
namespace MvvmCross.Test.ViewModels
|
||||||
{
|
{
|
||||||
[Collection("MvxTest")]
|
[Collection("MvxTest")]
|
||||||
public class MvxCommandCollectionTest : IClassFixture<MvxTestFixture>
|
public class MvxCommandCollectionTest
|
||||||
{
|
{
|
||||||
private MvxTestFixture _fixture;
|
private MvxTestFixture _fixture;
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ using Xunit;
|
||||||
namespace MvvmCross.Test.ViewModels
|
namespace MvvmCross.Test.ViewModels
|
||||||
{
|
{
|
||||||
[Collection("MvxTest")]
|
[Collection("MvxTest")]
|
||||||
public class MvxDefaultViewModelLocatorTest : IClassFixture<MvxTestFixture>
|
public class MvxDefaultViewModelLocatorTest
|
||||||
{
|
{
|
||||||
private readonly MvxTestFixture _fixture;
|
private readonly MvxTestFixture _fixture;
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@ using Xunit;
|
||||||
|
|
||||||
namespace MvvmCross.Test.ViewModels
|
namespace MvvmCross.Test.ViewModels
|
||||||
{
|
{
|
||||||
|
[Collection("MvxTest")]
|
||||||
public class MvxNotifyPropertyChangedTest : IClassFixture<MvxTestFixture>
|
public class MvxNotifyPropertyChangedTest
|
||||||
{
|
{
|
||||||
private readonly MvxTestFixture _fixture;
|
private readonly MvxTestFixture _fixture;
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ using Xunit;
|
||||||
namespace MvvmCross.Test.ViewModels
|
namespace MvvmCross.Test.ViewModels
|
||||||
{
|
{
|
||||||
[Collection("MvxTest")]
|
[Collection("MvxTest")]
|
||||||
public class MvxSaveStateTest : IClassFixture<MvxTestFixture>
|
public class MvxSaveStateTest
|
||||||
{
|
{
|
||||||
private readonly MvxTestFixture _fixture;
|
private readonly MvxTestFixture _fixture;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Licensed to the .NET Foundation under one or more agreements.
|
// Licensed to the .NET Foundation under one or more agreements.
|
||||||
// The .NET Foundation licenses this file to you under the MS-PL license.
|
// The .NET Foundation licenses this file to you under the MS-PL license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ using Xunit;
|
||||||
namespace MvvmCross.Test.ViewModels
|
namespace MvvmCross.Test.ViewModels
|
||||||
{
|
{
|
||||||
[Collection("MvxTest")]
|
[Collection("MvxTest")]
|
||||||
public class MvxViewModelLoaderTest : IClassFixture<MvxTestFixture>
|
public class MvxViewModelLoaderTest
|
||||||
{
|
{
|
||||||
private readonly MvxTestFixture _fixture;
|
private readonly MvxTestFixture _fixture;
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,20 @@
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using MvvmCross.Plugins.JsonLocalization.Tests.Mocks;
|
using MvvmCross.Plugins.JsonLocalization.Tests.Mocks;
|
||||||
|
using MvvmCross.Test;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace MvvmCross.Plugins.JsonLocalization.Tests
|
namespace MvvmCross.Plugins.JsonLocalization.Tests
|
||||||
{
|
{
|
||||||
|
public class MvxDictionaryTextProviderTest : IClassFixture<MvxTestFixture>
|
||||||
public class MvxDictionaryTextProviderTest
|
|
||||||
{
|
{
|
||||||
|
private readonly MvxTestFixture _fixture;
|
||||||
|
|
||||||
|
public MvxDictionaryTextProviderTest(MvxTestFixture fixture)
|
||||||
|
{
|
||||||
|
_fixture = fixture;
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void GetTextWithExistingValueReturnsTheValueWhenMaskingErrors()
|
public void GetTextWithExistingValueReturnsTheValueWhenMaskingErrors()
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,13 +5,20 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using MvvmCross.Test;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace MvvmCross.Plugins.Messenger.Test
|
namespace MvvmCross.Plugins.Messenger.Test
|
||||||
{
|
{
|
||||||
|
public class MessengerHubTest : IClassFixture<MvxTestFixture>
|
||||||
public class MessengerHubTest
|
|
||||||
{
|
{
|
||||||
|
private readonly MvxTestFixture _fixture;
|
||||||
|
|
||||||
|
public MessengerHubTest(MvxTestFixture fixture)
|
||||||
|
{
|
||||||
|
_fixture = fixture;
|
||||||
|
}
|
||||||
|
|
||||||
#region TestClasses
|
#region TestClasses
|
||||||
|
|
||||||
private class TestMessage : MvxMessage
|
private class TestMessage : MvxMessage
|
||||||
|
@ -32,10 +39,6 @@ namespace MvvmCross.Plugins.Messenger.Test
|
||||||
|
|
||||||
#endregion TestClasses
|
#endregion TestClasses
|
||||||
|
|
||||||
|
|
||||||
public void SetUp()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void SubscribeAndPublishAllowsMessageToBeReceived()
|
public void SubscribeAndPublishAllowsMessageToBeReceived()
|
||||||
|
|
Загрузка…
Ссылка в новой задаче