// 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 . using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using CalDavSynchronizer.Contracts; using CalDavSynchronizer.DataAccess; using CalDavSynchronizer.Implementation; using CalDavSynchronizer.Implementation.ComWrappers; using CalDavSynchronizer.Implementation.Events; using CalDavSynchronizer.IntegrationTests.TestBase; using DDay.iCal; using GenSync.EntityRelationManagement; using NUnit.Framework; namespace CalDavSynchronizer.IntegrationTests.ChunkedSynchronizationTest { public class TaskTest : GenericTwoWayTestBase { private TestComponentContainer _testComponentContainer; [OneTimeSetUp] public void OneTimeSetup() { _testComponentContainer = new TestComponentContainer(); } protected override Options GetOptions() => _testComponentContainer.TestOptionsFactory.CreateSogoTasks(); protected override TaskTestSynchronizer CreateSynchronizer(Options options) { return new TaskTestSynchronizer(options, _testComponentContainer); } protected override IEqualityComparer AIdComparer { get; } = StringComparer.InvariantCulture; protected override IEqualityComparer BIdComparer { get; } = WebResourceName.Comparer; protected override IReadOnlyList<(string AId, WebResourceName BId)> GetRelations() { return Synchronizer.Components.EntityRelationDataAccess.LoadEntityRelationData() .Select(r => (r.AtypeId, r.BtypeId)) .ToArray(); } protected override async Task> CreateInA(IEnumerable contents) { return await Synchronizer.Outlook.CreateEntities( contents.Select>( c => a => { a.Inner.Subject = c; })); } protected override async Task> CreateInB(IEnumerable contents) { return await Synchronizer.Server.CreateEntities( contents.Select>( c => a => { var todo = new Todo(); todo.Summary = c; a.Todos.Add(todo); })); } protected override async Task UpdateInA(IEnumerable<(string Id, string Content)> updates) { await Synchronizer.Outlook.UpdateEntities(updates, c => w => w.Inner.Subject = c); } protected override async Task UpdateInB(IEnumerable<(WebResourceName Id, string Content)> updates) { await Synchronizer.Server.UpdateEntities(updates, c => w => w.Todos[0].Summary = c); } protected override async Task> GetFromA(ICollection ids) { return await Synchronizer.Outlook.GetEntities(ids, e => e.Inner.Subject, e => e.Dispose()); } protected override async Task> GetFromB(ICollection ids) { return await Synchronizer.Server.GetEntities(ids, e => e.Todos[0].Summary); } protected override async Task DeleteInA(IEnumerable ids) { await Synchronizer.Outlook.DeleteEntities(ids); } protected override async Task DeleteInB(IEnumerable ids) { await Synchronizer.Server.DeleteEntities(ids); } [Test] [TestCase(null, 7, false, Category = TestCategories.BasicCrud)] [TestCase(2, 7, false)] [TestCase(7, 7, false)] [TestCase(29, 7, false)] [TestCase(1, 7, false)] public override Task Test(int? chunkSize, int itemsPerOperation, bool useWebDavCollectionSync) { return base.Test(chunkSize, itemsPerOperation, useWebDavCollectionSync); } } }