/// <summary>
/// Tests the sync logic with custom <see cref="AppList"/>s.
/// </summary>
/// <param name="resetMode">The <see cref="SyncResetMode"/> to pass to <see cref="SyncIntegrationManager.Sync"/>.</param>
/// <param name="appListLocal">The current local <see cref="AppList"/>.</param>
/// <param name="appListLast">The state of the <see cref="AppList"/> after the last successful sync.</param>
/// <param name="appListServer">The current server-side <see cref="AppList"/>.</param>
private void TestSync(SyncResetMode resetMode, AppList appListLocal, AppList appListLast, AppList appListServer)
{
appListLocal.SaveXml(_appListPath);
if (appListLast != null) appListLast.SaveXml(_appListPath + SyncIntegrationManager.AppListLastSyncSuffix);
using (var stream = File.Create(_appListPath + ".zip"))
appListServer.SaveXmlZip(stream);
using (var appListServerFile = File.OpenRead(_appListPath + ".zip"))
using (var syncServer = new MicroServer("app-list", appListServerFile))
{
using (var integrationManager = new SyncIntegrationManager(_appListPath, new SyncServer {Uri = syncServer.ServerUri, Username = "******", Password = "******"}, interfaceId => new Feed(), new SilentTaskHandler()))
integrationManager.Sync(resetMode);
appListServer = AppList.LoadXmlZip(syncServer.FileContent);
}
appListLocal = XmlStorage.LoadXml<AppList>(_appListPath);
appListLast = XmlStorage.LoadXml<AppList>(_appListPath + SyncIntegrationManager.AppListLastSyncSuffix);
Assert.AreEqual(appListLocal, appListServer, "Server and local data should be equal after sync");
Assert.AreEqual(appListLocal, appListLast, "Last sync snapshot and local data should be equal after sync");
}