1
0
mirror of https://github.com/aluxnimm/outlookcaldavsynchronizer.git synced 2025-10-06 00:12:52 +02:00
Files

87 lines
3.5 KiB
C#
Raw Permalink Normal View History

// This file is Part of CalDavSynchronizer (http://outlookcaldavsynchronizer.sourceforge.net/)
// Copyright (c) 2015 Gerhard Zehetbauer
// Copyright (c) 2015 Alexander Nimmervoll
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
2017-04-16 01:06:12 +02:00
using System.Linq;
using System.Threading.Tasks;
2017-05-20 10:36:38 +02:00
using CalDavSynchronizer.Contracts;
using CalDavSynchronizer.Implementation;
using CalDavSynchronizer.IntegrationTests.Infrastructure;
using CalDavSynchronizer.IntegrationTests.TestBase;
using GenSync.Logging;
using NUnit.Framework;
namespace CalDavSynchronizer.IntegrationTests
{
[TestFixture]
2017-05-20 10:36:38 +02:00
public class GoogleContactFixture
{
2017-05-20 10:36:38 +02:00
private TestComponentContainer _testComponentContainer;
[OneTimeSetUp]
public void OneTimeSetup()
{
_testComponentContainer = new TestComponentContainer();
}
2018-01-25 21:13:27 +01:00
[Test]
2017-05-20 10:36:38 +02:00
[TestCase(40, 201 , 50)]
[TestCase(40, 201 , 100)]
[TestCase(40, 201 , 700)]
[Apartment(System.Threading.ApartmentState.STA)]
2017-05-12 23:25:00 +02:00
public async Task GenericTest(int numberOfGroups, int numberOfContacts, int chunkSize)
{
2017-12-21 22:50:55 +01:00
var options = _testComponentContainer.TestOptionsFactory.CreateGoogleContacts();
options.SynchronizationMode = SynchronizationMode.ReplicateOutlookIntoServer;
2017-05-12 23:25:00 +02:00
options.IsChunkedSynchronizationEnabled = true;
options.ChunkSize = chunkSize;
2017-05-20 10:36:38 +02:00
var synchronizer = await CreateSynchronizer(options);
2017-05-20 10:36:38 +02:00
await synchronizer.ClearEventRepositoriesAndCache();
2017-05-20 10:36:38 +02:00
var groupNames = synchronizer.GetOrCreateGoogleGroups(numberOfGroups);
await synchronizer.CreateContactsInOutlook(synchronizer.CreateTestContactData(groupNames, numberOfContacts));
2017-05-20 10:36:38 +02:00
await synchronizer.SynchronizeAndCheck(
unchangedA: 0, addedA: numberOfContacts, changedA: 0, deletedA: 0,
unchangedB: 0, addedB: 0, changedB: 0, deletedB: 0,
createA: 0, updateA: 0, deleteA: 0,
createB: numberOfContacts, updateB: 0, deleteB: 0);
2017-05-20 10:36:38 +02:00
var outlook1IdsByGoogleId = synchronizer.Components.GoogleContactsEntityRelationDataAccess.LoadEntityRelationData().ToDictionary(r => r.BtypeId, r => r.AtypeId);
2017-05-12 23:25:00 +02:00
Assert.That(outlook1IdsByGoogleId.Count, Is.EqualTo(numberOfContacts));
2017-05-20 10:36:38 +02:00
await synchronizer.Outlook.DeleteAllEntities();
options.SynchronizationMode = SynchronizationMode.ReplicateServerIntoOutlook;
2017-05-20 10:36:38 +02:00
synchronizer = await CreateSynchronizer(options);
2017-05-20 10:36:38 +02:00
await synchronizer.SynchronizeAndCheck(
unchangedA: 0, addedA: 0, changedA: 0, deletedA: numberOfContacts,
unchangedB: numberOfContacts, addedB: 0, changedB: 0, deletedB: 0,
createA: numberOfContacts, updateA: 0, deleteA: 0,
createB: 0, updateB: 0, deleteB: 0);
}
2017-05-20 10:36:38 +02:00
private async Task<GoogleContactTestSynchronizer> CreateSynchronizer(Options options)
{
var synchronizer = new GoogleContactTestSynchronizer(options, _testComponentContainer);
await synchronizer.Initialize();
return synchronizer;
}
}
}