コード例 #1
0
        protected override void AdditionalSetup()
        {
            MvxSingletonCache.Instance
            .Settings
            .AlwaysRaiseInpcOnUserInterfaceThread = false;

            var helper = new MvxUnitTestCommandHelper();

            Ioc.RegisterSingleton <IMvxCommandHelper>(helper);

            mapperMock = new Mock <IMapper>();
            Ioc.RegisterSingleton <IMapper>(mapperMock.Object);

            navigationMock = new Mock <IMvxNavigationService>();
            Ioc.RegisterSingleton <IMvxNavigationService>(navigationMock.Object);

            weatherServiceMock = new Mock <IWeatherService>();
            Ioc.RegisterSingleton <IWeatherService>(weatherServiceMock.Object);

            alertMock = new Mock <IAlertService>();
            Ioc.RegisterSingleton <IAlertService>(alertMock.Object);

            MockFixtures.MockConnectivity(out connectivityMock);
            Ioc.RegisterSingleton <IConnectivityService>(connectivityMock.Object);

            MockWeather();
        }
コード例 #2
0
        protected override void AdditionalSetup()
        {
            //MockDispatcher = new MockDispatcher();
            //Ioc.RegisterSingleton<IMvxViewDispatcher>(MockDispatcher);
            var dispatcher = new MvxWindowsMainThreadDispatcher(Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher);

            Ioc.RegisterSingleton <IMvxMainThreadDispatcher>(dispatcher);

            Ioc.RegisterSingleton <IDialogService>(new MockDialogService());

            // for navigation parsing
            Ioc.RegisterSingleton <IMvxStringToTypeParser>(new MvxStringToTypeParser());

            var navService = new Mock <IMvxNavigationService>();

            Ioc.RegisterSingleton <IMvxNavigationService>(navService.Object);

            // to allow View Model commands to work in unit tests
            MvxSingletonCache.Instance.Settings.AlwaysRaiseInpcOnUserInterfaceThread = false;
            var helper = new MvxUnitTestCommandHelper();

            Ioc.RegisterSingleton <IMvxCommandHelper>(helper);

            SetupMockAuthenticationService();
        }
コード例 #3
0
        protected override void AdditionalSetup()
        {
            MvxSingletonCache.Instance.Settings.AlwaysRaiseInpcOnUserInterfaceThread = false;

            var helper = new MvxUnitTestCommandHelper();

            Ioc.RegisterSingleton <IMvxCommandHelper>(helper);
        }
コード例 #4
0
        public void Testing_Unregistered_Item_Will_Throw_Test()
        {
            var helper = new MvxUnitTestCommandHelper();

            var fakeCommand = new object { };

            Action act = () => helper.HasCalledRaisePropertyChangedFor(fakeCommand);

            Assert.Throws <Exception>(act);
        }
コード例 #5
0
        public void Can_Add_Item_To_Helper_Test()
        {
            var helper = new MvxUnitTestCommandHelper();

            var fakeCommand = new object { };

            helper.WillCallRaisePropertyChangedFor(fakeCommand);

            helper.RaiseCanExecuteChanged(fakeCommand);

            Assert.True(helper.HasCalledRaisePropertyChangedFor(fakeCommand));
        }
コード例 #6
0
        protected override void AdditionalSetup()
        {
            MvxSingletonCache.Instance
            .Settings
            .AlwaysRaiseInpcOnUserInterfaceThread = false;

            var helper = new MvxUnitTestCommandHelper();

            Ioc.RegisterSingleton <IMvxCommandHelper>(helper);

            geolocationMock = new Mock <IGeolocationService>();
            Ioc.RegisterSingleton <IGeolocationService>(geolocationMock.Object);

            geocodingMock = new Mock <IGeocodingService>();
            Ioc.RegisterSingleton <IGeocodingService>(geocodingMock.Object);
        }
コード例 #7
0
        public CustomTestFixture()
        {
            UnitTestCommandHelper = new MvxUnitTestCommandHelper();
            Ioc.RegisterSingleton <IMvxCommandHelper>(UnitTestCommandHelper);

            var plugin = new TestAssetPlugin();

            plugin.AddColor(Color.FromArgb(255, 0, 0), "Red");
            plugin.AddColor(Color.FromArgb(0, 0, 255), "Blue");
            FontToAdd = new Font()
            {
                Name = "Bold", FontFilename = "Bold.otf", Color = plugin.GetColor("Blue")
            };
            plugin.AddFont(FontToAdd);

            Ioc.RegisterSingleton <IAssetPlugin>(plugin);
        }
コード例 #8
0
        protected override void AdditionalSetup()
        {
            base.AdditionalSetup();

            // for navigation parsing
            Ioc.RegisterSingleton <IMvxStringToTypeParser>(new MvxStringToTypeParser());

            // for navigation
            MvxNavigationService navigationService = new MvxNavigationService(null, null)
            {
                ViewDispatcher = MockDispatcher,
            }
            ;

            navigationService.LoadRoutes(new[] { typeof(WPF.UI.ViewModels.ClassManagementViewModel).Assembly });
            Ioc.RegisterSingleton <IMvxNavigationService>(navigationService);

            // for commands
            var commandHelper = new MvxUnitTestCommandHelper();

            Ioc.RegisterSingleton <IMvxCommandHelper>(commandHelper);

            // for theme
            var themeService = new WPF.UI.Services.ThemeService();

            Ioc.RegisterSingleton <WPF.UI.Services.IThemeService>(themeService);

            // for permission
            var userPermissions = new UserPermissions();

            Ioc.RegisterSingleton <IUserPermissions>(userPermissions);

            // for ldap
            var ldapService = new LdapService();

            Ioc.RegisterSingleton <ILdapService>(ldapService);
        }
コード例 #9
0
        protected override void AdditionalSetup()
        {
            MvxSingletonCache.Instance
            .Settings
            .AlwaysRaiseInpcOnUserInterfaceThread = false;

            var helper = new MvxUnitTestCommandHelper();

            Ioc.RegisterSingleton <IMvxCommandHelper>(helper);

            apiMock = new Mock <IApiClient>();
            apiMock.Setup(a => a.GetWeatherByCityNameAsync(It.IsAny <string>()))
            .Throws <AggregateException>();
            apiMock.Setup(a => a.GetWeatherByCityNameAsync(null))
            .Throws <ArgumentException>();
            apiMock.Setup(a => a.GetWeatherByCityNameAsync(CurrentWeatherTestData.FakeCurrentWeather.City.Name))
            .ReturnsAsync(CurrentWeatherTestData.FakeCurrentWeather);
            Ioc.RegisterSingleton <IApiClient>(apiMock.Object);

            connectivityMock = new Mock <IConnectivityService>();
            connectivityMock.Setup(c => c.IsConnected)
            .Returns(true);
            Ioc.RegisterSingleton <IConnectivityService>(connectivityMock.Object);
        }
コード例 #10
0
        public void Helper_Can_Construct_Test()
        {
            var helper = new MvxUnitTestCommandHelper();

            Assert.IsType <MvxUnitTestCommandHelper>(helper);
        }