예제 #1
0
            public async void NoPending_Requested()
            {
                var service = new PushSyncService(MockPushSyncStore(new SyncAction[] { }).Object, MockDigitPushServiceCLient(),
                                                  Mock.Of <IFocusStore>());
                var res = await service.RequestLocationSync(userId, Now, Now);

                Assert.True(res.SyncRequested);
                Assert.False(res.SyncPendingFor.HasValue);
            }
예제 #2
0
            public async void PendingBeforeDeadline_NotRequested()
            {
                var service = new PushSyncService(MockPushSyncStore(new[] { new SyncAction()
                                                                            {
                                                                                Id       = "locationSync",
                                                                                Deadline = Now.AddMinutes(15)
                                                                            } }).Object, MockDigitPushServiceCLient(),
                                                  Mock.Of <IFocusStore>());
                var res = await service.RequestLocationSync(userId, Now, Now.AddMinutes(30));

                Assert.False(res.SyncRequested);
                Assert.Equal(Now.AddMinutes(15), res.SyncPendingFor);
            }
예제 #3
0
            public async void Earlier_NotAdded()
            {
                var mockPushSyncStore = MockPushSyncStore(new[] { new SyncAction()
                                                                  {
                                                                      Id       = "locationSync",
                                                                      Deadline = Now.AddMinutes(10)
                                                                  } });
                var service = new PushSyncService(mockPushSyncStore.Object, MockDigitPushServiceCLient(),
                                                  Mock.Of <IFocusStore>());
                await service.SetLocationRequestedExternal(userId, Now.AddMinutes(25));

                mockPushSyncStore.Verify(v => v.AddSyncAction(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTimeOffset>()), Times.Never);
            }
예제 #4
0
            public async void None_Add()
            {
                var mockPushSyncStore = MockPushSyncStore(new[] { new SyncAction()
                                                                  {
                                                                      Id       = "other",
                                                                      Deadline = Now.AddMinutes(10)
                                                                  } });
                var service = new PushSyncService(mockPushSyncStore.Object, MockDigitPushServiceCLient(),
                                                  Mock.Of <IFocusStore>());
                await service.SetLocationRequestedExternal(userId, Now.AddMinutes(25));

                mockPushSyncStore.Verify(v => v.AddSyncAction(userId, "locationSync", Now.AddMinutes(25)), Times.Once);
            }
예제 #5
0
            public async void RequestMissed_RequestAgain()
            {
                var missedDeadline = Now.Add(-DeviceSyncConstants.PushMissed);
                var service        = new PushSyncService(MockPushSyncStore(new[] { new SyncAction()
                                                                                   {
                                                                                       Id       = "test",
                                                                                       Deadline = missedDeadline
                                                                                   } }).Object, MockDigitPushServiceCLient(),
                                                         Mock.Of <IFocusStore>());

                var res = await service.RequestLocationSync(userId, Now.AddSeconds(1), Now.AddSeconds(1));

                Assert.True(res.SyncRequested);
                Assert.Null(res.SyncPendingFor);
            }
예제 #6
0
            public async void RequestPending_NotRequested()
            {
                var missedDeadline = Now.AddMinutes(-10);
                var service        = new PushSyncService(MockPushSyncStore(new[] { new SyncAction()
                                                                                   {
                                                                                       Id       = "test",
                                                                                       Deadline = missedDeadline
                                                                                   } }).Object, MockDigitPushServiceCLient(),
                                                         Mock.Of <IFocusStore>());

                var res = await service.RequestLocationSync(userId, Now, Now);

                Assert.False(res.SyncRequested);
                Assert.Equal(missedDeadline, res.SyncPendingFor);
            }