public void Sync_Class_NullableComparerAgent() { Func <Task> act = async() => await BatchSyncAgent <int?, Event> .Create() .SyncAsync(CancellationToken.None).ConfigureAwait(false); act.Should().ThrowAsync <NullReferenceException>().WithMessage($"The {nameof(BatchSyncAgent<int?, Event>.ComparerAgent)} cannot be null."); }
private static IBatchSyncAgent <int?, Event> CreateSyncAgent() { return(BatchSyncAgent <int?, Event> .Create() .Configure((c) => c.BatchSize = 3) .SetComparerAgent(KeyComparerAgent <int?> .Create()) .SetKeySelector(x => x.Id) .SetCompareItemFunc((s, d) => { if (s.Title == d.Title && s.ModifiedDate == d.ModifiedDate) { return MatchComparisonResultType.Same; } else if (s.ModifiedDate < d.ModifiedDate) { return MatchComparisonResultType.NewerDestination; } else if (s.ModifiedDate > d.ModifiedDate) { return MatchComparisonResultType.NewerSource; } else { return MatchComparisonResultType.Conflict; } })); }
public void Sync_Class_NullableKeySelector() { Func <Task> act = async() => await BatchSyncAgent <int?, Event> .Create() .SetComparerAgent(KeyComparerAgent <int?> .Create()) .SetCompareItemFunc((s, d) => MatchComparisonResultType.Conflict) .SyncAsync(CancellationToken.None).ConfigureAwait(false); act.Should().ThrowAsync <NullReferenceException>().WithMessage($"The {nameof(BatchSyncAgent<int?, Event>.KeySelector)} cannot be null."); }
public void Sync_Class_DestinationProviderIsNotSet() { Func <Task> act = async() => await BatchSyncAgent <int?, Event> .Create() .SetComparerAgent(KeyComparerAgent <int?> .Create()) .SetKeySelector(x => x.Id) .SetCompareItemFunc((s, d) => MatchComparisonResultType.Conflict) .SetSourceProvider(CreateSourceEventDictionary()) .SyncAsync(CancellationToken.None).ConfigureAwait(false); act.Should().ThrowAsync <NullReferenceException>().WithMessage($"The {nameof(BatchSyncAgent<int?, Event>.DestinationProvider)} cannot be null."); }
internal static IBatchSyncAgent <int, Hobby> CreateSyncAgent(IDictionary <int, Hobby> sourceDictionary, IDictionary <int, Hobby> destinationDictionary) { return(BatchSyncAgent <int, Hobby> .Create() .SetComparerAgent(KeyComparerAgent <int> .Create()) .SetKeySelector(x => x.Id) .SetCompareItemFunc((s, d) => { if (s.Name == d.Name) { return MatchComparisonResultType.Same; } else { return MatchComparisonResultType.Conflict; } }) .SetSourceProvider(sourceDictionary) .SetDestinationProvider(destinationDictionary)); }