public void ErrorCallbackSetsListAndClearsIsRefreshing() { var mockFinder = new Mock <ISpheroFinder>(); Ioc.RegisterServiceInstance(mockFinder.Object); Action <IList <IAvailableSphero> > successCallback = null; Action <Exception> failureCallback = null; mockFinder.Setup( finder => finder.Find(It.IsAny <Action <IList <IAvailableSphero> > >(), It.IsAny <Action <Exception> >())) .Callback((Action <IList <IAvailableSphero> > onSuccess, Action <Exception> onError) => { successCallback = onSuccess; failureCallback = onError; }); var service = new SpheroListService(); Assert.IsTrue(service.IsRefreshing); Assert.IsNull(service.AvailableSpheros); failureCallback(new Exception()); Assert.IsFalse(service.IsRefreshing); Assert.IsNull(service.AvailableSpheros); }
public void CallingRefreshAfterCausesNewRefresh() { var mockFinder = new Mock <ISpheroFinder>(); Ioc.RegisterServiceInstance(mockFinder.Object); Action <IList <IAvailableSphero> > successCallback = null; Action <Exception> failureCallback = null; mockFinder.Setup( finder => finder.Find(It.IsAny <Action <IList <IAvailableSphero> > >(), It.IsAny <Action <Exception> >())) .Callback((Action <IList <IAvailableSphero> > onSuccess, Action <Exception> onError) => { successCallback = onSuccess; failureCallback = onError; }); var service = new SpheroListService(); Assert.IsTrue(service.IsRefreshing); Assert.IsNull(service.AvailableSpheros); var mockList = new List <IAvailableSphero>(); successCallback(mockList); Assert.IsFalse(service.IsRefreshing); service.RefreshList(); Assert.IsTrue(service.IsRefreshing); mockFinder.Verify( finder => finder.Find(It.IsAny <Action <IList <IAvailableSphero> > >(), It.IsAny <Action <Exception> >()), Times.Exactly(2)); }
public void ConstructionCallsRefreshList() { var mockFinder = new Mock <ISpheroFinder>(); Ioc.RegisterServiceInstance(mockFinder.Object); var service = new SpheroListService(); Assert.IsTrue(service.IsRefreshing); Assert.IsNull(service.AvailableSpheros); mockFinder.Verify( finder => finder.Find(It.IsAny <Action <IList <IAvailableSphero> > >(), It.IsAny <Action <Exception> >()), Times.Once()); }
public void CallingRefreshMultipleTimesConcurrentlyJustResultsInOneCall() { var mockFinder = new Mock <ISpheroFinder>(); Ioc.RegisterServiceInstance(mockFinder.Object); var service = new SpheroListService(); Assert.IsTrue(service.IsRefreshing); Assert.IsNull(service.AvailableSpheros); service.RefreshList(); service.RefreshList(); service.RefreshList(); service.RefreshList(); service.RefreshList(); mockFinder.Verify( finder => finder.Find(It.IsAny <Action <IList <IAvailableSphero> > >(), It.IsAny <Action <Exception> >()), Times.Once()); }
public App() { Cirrious.MvvmCross.Plugins.File.PluginLoader.Instance.EnsureLoaded(); Cirrious.MvvmCross.Plugins.ResourceLoader.PluginLoader.Instance.EnsureLoaded(); Cirrious.MvvmCross.Plugins.Sphero.PluginLoader.Instance.EnsureLoaded(); Cirrious.MvvmCross.Plugins.XamPhotos.PluginLoader.Instance.EnsureLoaded(); Cirrious.MvvmCross.Plugins.Share.PluginLoader.Instance.EnsureLoaded(); // register the list service var spheroListService = new SpheroListService(); this.RegisterServiceInstance <ISpheroListService>(spheroListService); // register the speed service var spheroSpeedService = new SpheroSpeedService(); this.RegisterServiceInstance <ISpheroSpeedService>(spheroSpeedService); // set the start object var startApplicationObject = new StartApplicationObject(); this.RegisterServiceInstance <IMvxStartNavigation>(startApplicationObject); }