Example #1
0
        public void ExecuteInvokesActionAssignedToType()
        {
            _switch.Set(typeof(int), () => 0);
            _switch.Set(typeof(string), () => 1);

            var result = _switch.Execute(typeof(string));

            Assert.AreEqual(1, result);
        }
Example #2
0
        public void ExecuteInvokesActionAssignedToType()
        {
            _switch.Set(typeof(int), IntegerAction);
            _switch.Set(typeof(string), StringAction);

            _switch.Execute(typeof(int));

            Assert.IsTrue(_intActionInvoked);
            Assert.IsFalse(_stringActionInvoked);
        }
        public void ExecutesFallbackActionAssignedInConstructorWhenExecutedTypeNotFoundOrNull()
        {
            var swithWithFallback = new TypeSwitch<int>( () => 0 );
            swithWithFallback.Set( typeof(int), () => 1 );

            var result = swithWithFallback.Execute( typeof(bool) );

            Assert.AreEqual( 0, result );
        }
Example #4
0
        public void ExecutesFallbackActionAssignedInConstructorWhenExecutedTypeNotFoundOrNull()
        {
            var swithWithFallback = new TypeSwitch(StringAction);

            swithWithFallback.Set(typeof(int), IntegerAction);

            swithWithFallback.Execute(typeof(bool));

            Assert.IsTrue(_stringActionInvoked);
        }
Example #5
0
        public void ExecutesFallbackActionAssignedInConstructorWhenExecutedTypeNotFoundOrNull()
        {
            var swithWithFallback = new TypeSwitch <int>(() => 0);

            swithWithFallback.Set(typeof(int), () => 1);

            var result = swithWithFallback.Execute(typeof(bool));

            Assert.AreEqual(0, result);
        }
Example #6
0
        public ViewSelector()
        {
            _switch = new TypeSwitch<DataTemplate>( () => base.SelectTemplate( null, null ) );

            _switch.Set( typeof(ComponentManagementViewModel), () => ComponentView );
            _switch.Set( typeof(LocationManagementViewModel), () => LocationsView );
            _switch.Set( typeof(PalletManagementViewModel), () => PalletView );
            _switch.Set( typeof(PalletSummaryViewModel), () => PalletSummaryView );
            _switch.Set( typeof(NavigationViewModel), () => NavigationView );
            _switch.Set( typeof( SettingsViewModel ), () => SettingsView );
        }