Ejemplo n.º 1
0
        public void GetItemsDelegatesToTheStrategy()
        {
            MergedDataSet dataSet = new MergedDataSet();

            IDataSet provider = Mocks.Stub <IDataSet>();

            dataSet.AddDataSet(provider);

            IMergeStrategy strategy = Mocks.StrictMock <IMergeStrategy>();

            dataSet.Strategy = strategy;

            IEnumerable <IDataItem> results = Mocks.Stub <IEnumerable <IDataItem> >();

            DataBinding[] bindings = new DataBinding[0];

            using (Mocks.Record())
            {
                Expect.Call(strategy.Merge(null, null, false)).IgnoreArguments().Do((MergeDelegate) delegate(IList <IDataProvider> mergeProviders, ICollection <DataBinding> mergeBindings,
                                                                                                             bool includeDynamicItems)
                {
                    Assert.IsTrue(includeDynamicItems);

                    Assert.AreElementsEqual(new IDataProvider[] { provider }, mergeProviders);
                    Assert.AreSame(bindings, mergeBindings);
                    return(results);
                });
            }

            using (Mocks.Playback())
            {
                Assert.AreSame(results, dataSet.GetItems(bindings, true));
            }
        }
Ejemplo n.º 2
0
        public void Synchronize()
        {
            _logger.Trace("Getting notes from source");

            foreach (var sourceNote in _sourceRepository.GetNotes())
            {
                _logger.Info($"Synchronizing note: {sourceNote.Created} - {sourceNote.Title} ");

                Note note;
                if (!_targetRepository.TryGetNote(sourceNote.Id, out note))
                {
                    _logger.Debug($"Note {sourceNote.Id} does not exist on target.");
                    // This note does not exist yet.
                    // Create a new note
                    note = new Note
                    {
                        Created = sourceNote.Created,
                        Id      = sourceNote.Id
                    };
                }

                // Merge the note using the merge strategy
                if (!_mergeStrategy.Merge(sourceNote, note))
                {
                    _logger.Warn($"Merge conflict for note {sourceNote.Id}. Skipping note.");
                    // We have a merge conflict.
                    continue;
                }

                _logger.Debug($"Saving note {sourceNote.Id}");
                _targetRepository.SaveNote(note);
            }
        }
        private async Task <GitignoreFile> GetGitIgnoreFileFromGithub(string providedNames)
        {
            var names = _concatedNamesProcessor.Process(providedNames);

            var gitIgnoreFiles = await DownloadAllGitIgnoreFiles(names);

            EnsureAllGitIgnoreFilesWhereDownloaded(gitIgnoreFiles, names);

            return(_mergeStrategy.Merge(gitIgnoreFiles));
        }
Ejemplo n.º 4
0
 public object Merge(IMergeStrategy strategy)
 {
     return(strategy.Merge(Value));
 }
Ejemplo n.º 5
0
 /// <inheritdoc />
 protected override IEnumerable <IDataItem> GetItemsImpl(ICollection <DataBinding> bindings, bool includeDynamicItems)
 {
     IDataProvider[] providers = GenericCollectionUtils.ToArray(DataSets);
     return(strategy.Merge(providers, bindings, includeDynamicItems));
 }