Created
March 24, 2017 12:49
-
-
Save Cheesebaron/99dd5f4ff662e6750aadd037e330cd6c to your computer and use it in GitHub Desktop.
MvvmCross xUnit Fixture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MvxFixture : IDisposable | |
{ | |
public MvxFixture() | |
{ | |
MvxTest.Initialize(); | |
} | |
~MvxFixture() | |
{ | |
Dispose(false); | |
} | |
public void Dispose() | |
{ | |
Dispose(true); | |
} | |
protected virtual void Dispose(bool disposing) | |
{ | |
if (disposing) | |
{ | |
// dispose shit here... | |
} | |
} | |
} | |
[CollectionDefinition("MvxTests")] | |
public class MvxTestCollection : ICollectionFixture<MvxFixture> | |
{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class MvxTest | |
{ | |
private static bool _initialized; | |
public static void Initialize() | |
{ | |
if (_initialized) return; | |
MvxSingleton.ClearAllSingletons(); | |
var ioc = MvxSimpleIoCContainer.Initialize(); | |
ioc.RegisterSingleton(ioc); | |
ioc.RegisterSingleton<IMvxTrace>(new TestTrace()); | |
MvxSingletonCache.Initialize(); | |
InitializeMvxSettings(ioc); | |
AdditionalSetup(ioc); | |
MvxTrace.Initialize(); | |
_initialized = true; | |
} | |
private static void InitializeMvxSettings(IMvxIoCProvider ioc) | |
{ | |
ioc.RegisterSingleton<IMvxSettings>(new MvxSettings()); | |
} | |
private static void AdditionalSetup(IMvxIoCProvider ioc) | |
{ | |
ioc.RegisterSingleton<IMvxTextProvider>(new ResxTextProvider()); | |
// register more shit here... | |
} | |
public static void SetInvariantCulture() | |
{ | |
var invariantCulture = CultureInfo.InvariantCulture; | |
CultureInfo.DefaultThreadCurrentCulture = invariantCulture; | |
CultureInfo.DefaultThreadCurrentUICulture = invariantCulture; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment