Exemple #1
0
        public async Task SyncAgentWithValidSyncProvidersShouldSync()
        {
            ListSyncProvider <int> source = new ListSyncProvider <int> {
                Items = new List <int> {
                    5, 4, 9
                }
            }
            , destination = new ListSyncProvider <int> {
                Items = new List <int> {
                    6, 10, 5
                }
            };

            var syncAgent = SyncAgent <int> .Create()
                            .Configure((c) => c.SyncMode.SyncModePreset = SyncModePreset.MirrorToDestination)
                            .SetComparerAgent(ComparerAgent <int> .Create())
                            .SetSourceProvider(source)
                            .SetDestinationProvider(destination);

            await syncAgent.SyncAsync(CancellationToken.None).ConfigureAwait(false);

            source.Items.Should().BeEquivalentTo(new List <int> {
                5, 4, 9
            });
            destination.Items.Should().BeEquivalentTo(source.Items);

            syncAgent.ToString().Should().Be($"{nameof(syncAgent.Configurations)}: {{{syncAgent.Configurations}}}");
        }
Exemple #2
0
        public void ListSyncProviderShouldHaveAValidStringForNonNullableItems()
        {
            var provider = new ListSyncProvider <int>();

            provider.Items = new List <int>();
            provider.Items.Add(1);

            provider.ToString().Should().Be(provider.Items.ToString());
        }
Exemple #3
0
        public void Sync_DestinationComparerSyncProviderIsSetWithoutSettingComparerAgent()
        {
            ListSyncProvider <int> source = new ListSyncProvider <int> {
                Items = new List <int> {
                    5, 4, 9
                }
            }
            , destination = new ListSyncProvider <int> {
                Items = new List <int> {
                    6, 10, 5
                }
            };

            Func <Task> act = async() => await SyncAgent <int> .Create()
                              .Configure((c) => c.SyncMode.SyncModePreset = SyncModePreset.MirrorToDestination)
                              .SetDestinationProvider(destination)
                              .SetSourceProvider(source)
                              .SyncAsync(CancellationToken.None).ConfigureAwait(false);

            act.Should().Throw <NullReferenceException>().WithMessage($"The {nameof(SyncAgent<int>.ComparerAgent)} must be set first.");
        }
Exemple #4
0
        public void ListSyncProviderShouldHaveAValidStringForNullableItems()
        {
            var provider = new ListSyncProvider <int>();

            provider.ToString().Should().NotBeNullOrWhiteSpace();
        }