Пример #1
0
        public void Sync_Class_SourceProviderIsNotSet()
        {
            Func <Task> act = async() => await BatchSyncAgent <int?, Event> .Create()
                              .SetComparerAgent(KeyComparerAgent <int?> .Create())
                              .SetKeySelector(x => x.Id)
                              .SetCompareItemFunc((s, d) => MatchComparisonResultType.Conflict)
                              .SetDestinationProvider(CreateDestinationEventDictionary())
                              .SyncAsync(CancellationToken.None).ConfigureAwait(false);

            act.Should().Throw <NullReferenceException>().WithMessage($"The {nameof(BatchSyncAgent<int?, Event>.SourceProvider)} cannot be null.");
        }
Пример #2
0
 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));
 }