public void ExecuteTaskSuccessfulWhenValidItemCallsAppropriateMethods()
            {
                //arrange
                var bookingCounts = new List<PropertyOfflineBookingsCount>
                    {
                        new PropertyOfflineBookingsCount
                            {
                                CurrencyCode = "GBP",
                                OfflineBookingCount = 10,
                                PeriodDateTime = new DateTime(2014, 1, 1, 0, 0, 0, DateTimeKind.Utc),
                                PropertyShortname = "TestBus1",
                                TaxRegistered = false
                            }
                    };
                
                var settlementManagerMock = new Mock<ISettlementManager>();
                settlementManagerMock.Setup(sm => sm.GetOfflineTransactionCounts(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<OfflineSourceEnum>()))
                                     .Returns(bookingCounts);
                                    
                var serviceManagerMock = new Mock<ISettlementServiceManager>();
                serviceManagerMock.Setup(sm => sm.SendStoreOfflineCountsRequest(It.IsAny<List<PropertyOfflineBookingsCount>>(), It.IsAny<string>()))
                                  .Returns(true);

                var offlineTransactionCountsTask = new OfflineTransactionCountsTask(settlementManagerMock.Object, serviceManagerMock.Object);
                

                //act
                offlineTransactionCountsTask.ExecuteTask();


                //assert
                settlementManagerMock.Verify(
                    sm => sm.GetOfflineTransactionCounts(It.IsAny<DateTime>(),
                                                            It.IsAny<DateTime>(),
                                                            It.IsAny<OfflineSourceEnum>()),
                    Times.Exactly(2));      // once for web and once for mobile


                serviceManagerMock.Verify(
                    sm => sm.SendStoreOfflineCountsRequest(It.IsAny<List<PropertyOfflineBookingsCount>>(), It.IsAny<string>()),
                    Times.Exactly(2));      // once for web and once for mobile
            }
            public void ExecuteTaskContinuesEvenIfSomeRequestsFail()
            {
                //arrange
                const int chunckSize = 120;
                const int numberOfCounts = 1200;

                var bookingCounts = new List<PropertyOfflineBookingsCount>();
                for (var i = 0; i < numberOfCounts; i++)
                {
                    bookingCounts.Add(new PropertyOfflineBookingsCount
                    {
                        CurrencyCode = "GBP",
                        OfflineBookingCount = i % 10,
                        PeriodDateTime = new DateTime(2014, 1, 1, 0, 0, 0, DateTimeKind.Utc),
                        PropertyShortname = "TestBus" + i,
                        TaxRegistered = false
                    });
                }

                var settlementManagerMock = new Mock<ISettlementManager>();
                settlementManagerMock.Setup(sm => sm.GetOfflineTransactionCounts(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<OfflineSourceEnum>()))
                                     .Returns(bookingCounts);

                var serviceManagerMock = new Mock<ISettlementServiceManager>();
                serviceManagerMock.Setup(sm => sm.SendStoreOfflineCountsRequest(It.IsAny<List<PropertyOfflineBookingsCount>>(), It.IsAny<string>()))
                                  .Returns(false);  // all requests fail

                var offlineTransactionCountsTask = new OfflineTransactionCountsTask(settlementManagerMock.Object, serviceManagerMock.Object);


                //act
                offlineTransactionCountsTask.ExecuteTask();
                

                //assert
                settlementManagerMock.Verify(
                    sm => sm.GetOfflineTransactionCounts(It.IsAny<DateTime>(),
                                                            It.IsAny<DateTime>(),
                                                            It.IsAny<OfflineSourceEnum>()),
                    Times.Exactly(2));      // once for web and once for mobile

                serviceManagerMock.Verify(
                    sm => sm.SendStoreOfflineCountsRequest(It.IsAny<List<PropertyOfflineBookingsCount>>(), It.IsAny<string>()),
                    Times.Exactly(2 * (numberOfCounts / chunckSize))); // 10 batches for web and 10 batches for mobile
            }
            public void ExecuteRequestDoesNotCallSettlementIfThereAreNoCountsToSend()
            {
                //arrange

                var settlementManagerMock = new Mock<ISettlementManager>();
                settlementManagerMock.Setup(sm => sm.GetOfflineTransactionCounts(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<OfflineSourceEnum>()))
                                     .Returns(new List<PropertyOfflineBookingsCount>());    // return empty list of counts

                var serviceManagerMock = new Mock<ISettlementServiceManager>();

                var offlineTransactionCountsTask = new OfflineTransactionCountsTask(settlementManagerMock.Object, serviceManagerMock.Object);

                //act
                offlineTransactionCountsTask.ExecuteTask();

                //assert
                serviceManagerMock.Verify(
                    sm => sm.SendStoreOfflineCountsRequest(It.IsAny<List<PropertyOfflineBookingsCount>>(), It.IsAny<string>()),
                    Times.Never);
            }