public void Test_PropertyChanged_Raises_Multiple_CanExecuteChange() { ClearAll(); var dispatcher = new InlineMockMainThreadDispatcher(); Ioc.RegisterSingleton <IMvxMainThreadDispatcher>(dispatcher); var testObject = new SharedCommandTestClass(); var collection = new MvxCommandCollectionBuilder() .BuildCollectionFor(testObject); var calledByAttrCommand = collection["CalledByAttr"]; Assert.IsNotNull(calledByAttrCommand); var countAttr = 0; calledByAttrCommand.CanExecuteChanged += (sender, args) => countAttr++; var calledByAttr2Command = collection["CalledByAttr2"]; Assert.IsNotNull(calledByAttr2Command); var countAttr2 = 0; calledByAttr2Command.CanExecuteChanged += (sender, args) => countAttr2++; testObject.RaisePropertyChanged("CanExecuteAttributed"); Assert.AreEqual(1, countAttr); Assert.AreEqual(1, countAttr2); testObject.RaisePropertyChanged("CanExecuteAttributed"); Assert.AreEqual(2, countAttr); Assert.AreEqual(2, countAttr2); }
public BaseViewModel() { Settings = Mvx.Resolve <ISettingsService>(); Service = Mvx.Resolve <IJabbrService>(); Messenger = Mvx.Resolve <IMvxMessenger>(); Commands = new MvxCommandCollectionBuilder().BuildCollectionFor(this); }
public override async Task Initialize() { await base.Initialize(); Commands = new MvxCommandCollectionBuilder() .BuildCollectionFor(this); PickRandomCommand(); }
public void IncludeMvvmcross64() { _ = new MvxSettings(); _ = new MvxStringToTypeParser(); //?? //_ = new MvxPluginManager(null); //should not be required _ = new MvxViewModelLoader(null); _ = new MvxNavigationService(null, null); _ = new MvxViewModelByNameLookup(); _ = new MvxViewModelViewTypeFinder(null, null); _ = new MvxViewModelViewLookupBuilder(); _ = new MvxCommandCollectionBuilder(); _ = new MvxStringDictionaryNavigationSerializer(); _ = new MvxChildViewModelCache(); _ = new MvxWeakCommandHelper(); }
public void Test_Attribute2_Command() { var testObject = new CommandTestClass(); var collection = new MvxCommandCollectionBuilder() .BuildCollectionFor(testObject); var myCommand = collection["CalledByAttr2"]; Assert.IsNotNull(myCommand); CheckCounts(testObject); myCommand.Execute(); CheckCounts(testObject, countAttributed2Called: 1, countCanExecuteAttributed2Called: 1); myCommand.Execute(); myCommand.Execute(); myCommand.Execute(); CheckCounts(testObject, countAttributed2Called: 4, countCanExecuteAttributed2Called: 4); }
public void Test_Conventional_Parameter_Command() { var testObject = new CommandTestClass(); var collection = new MvxCommandCollectionBuilder() .BuildCollectionFor(testObject); var myCommand = collection["MyEx"]; Assert.IsNotNull(myCommand); CheckCounts(testObject); myCommand.Execute(); CheckCounts(testObject, countMyExCalled: 1, countCanExecuteMyExCalled: 1); myCommand.Execute(); myCommand.Execute(); myCommand.Execute(); CheckCounts(testObject, countMyExCalled: 4, countCanExecuteMyExCalled: 4); }
public void Test_Conventional_Command_CanExecute() { var testObject = new CommandTestClass(); var collection = new MvxCommandCollectionBuilder() .BuildCollectionFor(testObject); var myCommand = collection["My"]; Assert.IsNotNull(myCommand); CheckCounts(testObject); var result = myCommand.CanExecute(); CheckCounts(testObject, countCanExecuteMyCalled: 1); result = myCommand.CanExecute(); result = myCommand.CanExecute(); result = myCommand.CanExecute(); CheckCounts(testObject, countCanExecuteMyCalled: 4); }
public void Test_IntReturning_Command() { ClearAll(); var testObject = new CommandTestClass(); var collection = new MvxCommandCollectionBuilder() .BuildCollectionFor(testObject); var myCommand = collection["AnIntReturning"]; Assert.IsNotNull(myCommand); CheckCounts(testObject); myCommand.Execute(); CheckCounts(testObject, countIntReturningCalled: 1); myCommand.Execute(); myCommand.Execute(); myCommand.Execute(); CheckCounts(testObject, countIntReturningCalled: 4); }
public void Test_Conventional_Command() { ClearAll(); var testObject = new CommandTestClass(); var collection = new MvxCommandCollectionBuilder() .BuildCollectionFor(testObject); var myCommand = collection["My"]; Assert.IsNotNull(myCommand); CheckCounts(testObject); myCommand.Execute(); CheckCounts(testObject, 1, 1); myCommand.Execute(); myCommand.Execute(); myCommand.Execute(); CheckCounts(testObject, 4, 4); }
public void Test_Attribute1_Command() { ClearAll(); var testObject = new CommandTestClass(); var collection = new MvxCommandCollectionBuilder() .BuildCollectionFor(testObject); var myCommand = collection["CalledByAttr"]; Assert.IsNotNull(myCommand); this.CheckCounts(testObject); myCommand.Execute(); this.CheckCounts(testObject, countAttributedCalled: 1); myCommand.Execute(); myCommand.Execute(); myCommand.Execute(); this.CheckCounts(testObject, countAttributedCalled: 4); }
public void Test_Attribute2_Command_CanExecute() { ClearAll(); var testObject = new CommandTestClass(); var collection = new MvxCommandCollectionBuilder() .BuildCollectionFor(testObject); var myCommand = collection["CalledByAttr2"]; Assert.IsNotNull(myCommand); this.CheckCounts(testObject); var result = myCommand.CanExecute(); this.CheckCounts(testObject, countCanExecuteAttributed2Called: 1); result = myCommand.CanExecute(); result = myCommand.CanExecute(); result = myCommand.CanExecute(); this.CheckCounts(testObject, countCanExecuteAttributed2Called: 4); }
public void Test_Conventional_Parameter_Command_CanExecute() { _fixture.ClearAll(); var testObject = new CommandTestClass(); var collection = new MvxCommandCollectionBuilder() .BuildCollectionFor(testObject); var myCommand = collection["MyEx"]; Assert.NotNull(myCommand); CheckCounts(testObject); var result = myCommand.CanExecute(); CheckCounts(testObject, countCanExecuteMyExCalled: 1); result = myCommand.CanExecute(); result = myCommand.CanExecute(); result = myCommand.CanExecute(); CheckCounts(testObject, countCanExecuteMyExCalled: 4); }
public void Include(MvxCommandCollectionBuilder builder) { _ = new MvxCommandCollectionBuilder(); }
public void Init() { Commands = new MvxCommandCollectionBuilder() .BuildCollectionFor(this); PickRandomCommand(); }
public void Test_PropertyChanged_Raises_CanExecuteChange() { ClearAll(); var dispatcher = new InlineMockMainThreadDispatcher(); Ioc.RegisterSingleton <IMvxMainThreadDispatcher>(dispatcher); var testObject = new CommandTestClass(); var collection = new MvxCommandCollectionBuilder() .BuildCollectionFor(testObject); var myCommand = collection["My"]; Assert.IsNotNull(myCommand); var countMy = 0; myCommand.CanExecuteChanged += (sender, args) => countMy++; var myExCommand = collection["MyEx"]; Assert.IsNotNull(myExCommand); var countMyEx = 0; myExCommand.CanExecuteChanged += (sender, args) => countMyEx++; var calledByAttrCommand = collection["CalledByAttr"]; Assert.IsNotNull(calledByAttrCommand); var countAttr = 0; calledByAttrCommand.CanExecuteChanged += (sender, args) => countAttr++; var calledByAttr2Command = collection["CalledByAttr2"]; Assert.IsNotNull(calledByAttr2Command); var countAttr2 = 0; calledByAttr2Command.CanExecuteChanged += (sender, args) => countAttr2++; CheckCounts(testObject); testObject.RaisePropertyChanged("CanExecuteAttributed2"); Assert.AreEqual(0, countMy); Assert.AreEqual(0, countMyEx); Assert.AreEqual(0, countAttr); Assert.AreEqual(1, countAttr2); testObject.RaisePropertyChanged("CanExecuteAttributed2"); Assert.AreEqual(0, countMy); Assert.AreEqual(0, countMyEx); Assert.AreEqual(0, countAttr); Assert.AreEqual(2, countAttr2); testObject.RaisePropertyChanged("CanExecuteAttributed"); Assert.AreEqual(0, countMy); Assert.AreEqual(0, countMyEx); Assert.AreEqual(0, countAttr); Assert.AreEqual(2, countAttr2); testObject.RaisePropertyChanged("CanExecuteMyCommand"); testObject.RaisePropertyChanged("CanExecuteMyCommand"); testObject.RaisePropertyChanged("CanExecuteMyCommand"); Assert.AreEqual(3, countMy); Assert.AreEqual(0, countMyEx); Assert.AreEqual(0, countAttr); Assert.AreEqual(2, countAttr2); testObject.RaisePropertyChanged("CanExecuteMyExCommand"); testObject.RaisePropertyChanged("CanExecuteMyCommand"); testObject.RaisePropertyChanged("CanExecuteMyExCommand"); testObject.RaisePropertyChanged("CanExecuteMyCommand"); testObject.RaisePropertyChanged("CanExecuteMyExCommand"); testObject.RaisePropertyChanged("CanExecuteMyExCommand"); testObject.RaisePropertyChanged("CanExecuteMyExCommand"); testObject.RaisePropertyChanged("CanExecuteMyExCommand"); Assert.AreEqual(5, countMy); Assert.AreEqual(6, countMyEx); Assert.AreEqual(0, countAttr); Assert.AreEqual(2, countAttr2); }