RefreshList() public method

public RefreshList ( ) : void
return void
コード例 #1
0
        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));
        }
コード例 #2
0
        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());
        }