private void SetupProviders(SyncClass[] localModified, SyncClass[] remoteModified, int[] localDeletedIds, int[] remoteDeletedIds)
 {
     _remoteProvider.GetModifiedEntries(Arg.Any<DateTime?>()).Returns(remoteModified ?? new SyncClass[0]);
     _localProvider.GetModifiedEntries(Arg.Any<DateTime?>()).Returns(localModified ?? new SyncClass[0]);
     _remoteProvider.GetDeletedEntries(Arg.Any<DateTime?>()).Returns(remoteDeletedIds ?? new int[0]);
     _localProvider.GetDeletedEntries(Arg.Any<DateTime?>()).Returns(localDeletedIds ?? new int[0]);
 }
        public void SingleLocalEntrySavesRemotely()
        {
            //Arrange
            var syncClass = new SyncClass { Id = 1 };
            SetupProviders(new[] { syncClass }, null, null, null);

            //Act
            var results = _syncService.PerformSynchronisation();

            //Assert
            _remoteProvider.Received().SaveEntries(Arg.Is<List<SyncClass>>(l => l.First() == syncClass));
            Assert.Equal(0, results.NumberConflicts);
            Assert.Equal(1, results.NumberUpdatedRemote);
            Assert.Equal(0, results.NumberUpdatedLocal);
            Assert.Equal(0, results.NumberDeletedRemote);
            Assert.Equal(0, results.NumberDeletedLocal);
        }
        public void ConflictedEntryWithRemoteWinsResolver()
        {
            //Arrange
            var syncClass = new SyncClass { Id = 1, Data = "Original Data" };
            var modifiedSyncClass = new SyncClass { Id = 1, Data = "Local modified Data" };
            SetupProviders(new[] { modifiedSyncClass }, new[] { syncClass }, null, null);

            //Act
            var results = _syncService.PerformSynchronisation();

            //Assert
            _localProvider.Received().SaveEntries(Arg.Is<List<SyncClass>>(l => l.First() == syncClass));
            Assert.Equal(1, results.NumberConflicts);
            Assert.Equal(0, results.NumberUpdatedRemote);
            Assert.Equal(1, results.NumberUpdatedLocal);
            Assert.Equal(0, results.NumberDeletedRemote);
            Assert.Equal(0, results.NumberDeletedLocal);
        }
Exemple #4
0
        public void SingleLocalEntrySavesRemotely()
        {
            //Arrange
            var syncClass = new SyncClass {
                Id = 1
            };

            SetupProviders(new[] { syncClass }, null, null, null);

            //Act
            var results = _syncService.PerformSynchronisation();

            //Assert
            _remoteProvider.Received().SaveEntries(Arg.Is <List <SyncClass> >(l => l.First() == syncClass));
            Assert.Equal(0, results.NumberConflicts);
            Assert.Equal(1, results.NumberUpdatedRemote);
            Assert.Equal(0, results.NumberUpdatedLocal);
            Assert.Equal(0, results.NumberDeletedRemote);
            Assert.Equal(0, results.NumberDeletedLocal);
        }
Exemple #5
0
        public void ConflictedEntryWithRemoteWinsResolver()
        {
            //Arrange
            var syncClass = new SyncClass {
                Id = 1, Data = "Original Data"
            };
            var modifiedSyncClass = new SyncClass {
                Id = 1, Data = "Local modified Data"
            };

            SetupProviders(new[] { modifiedSyncClass }, new[] { syncClass }, null, null);

            //Act
            var results = _syncService.PerformSynchronisation();

            //Assert
            _localProvider.Received().SaveEntries(Arg.Is <List <SyncClass> >(l => l.First() == syncClass));
            Assert.Equal(1, results.NumberConflicts);
            Assert.Equal(0, results.NumberUpdatedRemote);
            Assert.Equal(1, results.NumberUpdatedLocal);
            Assert.Equal(0, results.NumberDeletedRemote);
            Assert.Equal(0, results.NumberDeletedLocal);
        }