[KOE-57] Moved test projects to build repository

This commit is contained in:
Patrick Simpson 2017-01-02 13:19:41 +01:00
parent b12c557b6c
commit 51cb0c7fa1
36 changed files with 0 additions and 2944 deletions

View File

@ -5,12 +5,6 @@ VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AcaciaZPushPlugin", "AcaciaZPushPlugin\AcaciaZPushPlugin.csproj", "{1A7427A5-F814-4B07-98B2-C67D758B65D6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{3BAA09C4-9E3C-4088-901C-E03489366468}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginUnitTests", "Test\PluginUnitTests\PluginUnitTests.csproj", "{1862C3CA-3347-4180-B076-D018BAA70F40}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OutlookIntegrationTests", "Test\OutlookIntegrationTests\OutlookIntegrationTests.csproj", "{A1AA144C-ABCE-462D-ADB4-6EC25AC062B7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginDebugger", "PluginDebugger\PluginDebugger.csproj", "{9258AD17-0A25-4669-A95C-93EC70882551}"
EndProject
Global
@ -35,30 +29,6 @@ Global
{1A7427A5-F814-4B07-98B2-C67D758B65D6}.Release|x64.Build.0 = Release|Any CPU
{1A7427A5-F814-4B07-98B2-C67D758B65D6}.Release|x86.ActiveCfg = Release|Any CPU
{1A7427A5-F814-4B07-98B2-C67D758B65D6}.Release|x86.Build.0 = Release|Any CPU
{1862C3CA-3347-4180-B076-D018BAA70F40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1862C3CA-3347-4180-B076-D018BAA70F40}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1862C3CA-3347-4180-B076-D018BAA70F40}.Debug|x64.ActiveCfg = Debug|Any CPU
{1862C3CA-3347-4180-B076-D018BAA70F40}.Debug|x64.Build.0 = Debug|Any CPU
{1862C3CA-3347-4180-B076-D018BAA70F40}.Debug|x86.ActiveCfg = Debug|Any CPU
{1862C3CA-3347-4180-B076-D018BAA70F40}.Debug|x86.Build.0 = Debug|Any CPU
{1862C3CA-3347-4180-B076-D018BAA70F40}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1862C3CA-3347-4180-B076-D018BAA70F40}.Release|Any CPU.Build.0 = Release|Any CPU
{1862C3CA-3347-4180-B076-D018BAA70F40}.Release|x64.ActiveCfg = Release|Any CPU
{1862C3CA-3347-4180-B076-D018BAA70F40}.Release|x64.Build.0 = Release|Any CPU
{1862C3CA-3347-4180-B076-D018BAA70F40}.Release|x86.ActiveCfg = Release|Any CPU
{1862C3CA-3347-4180-B076-D018BAA70F40}.Release|x86.Build.0 = Release|Any CPU
{A1AA144C-ABCE-462D-ADB4-6EC25AC062B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A1AA144C-ABCE-462D-ADB4-6EC25AC062B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A1AA144C-ABCE-462D-ADB4-6EC25AC062B7}.Debug|x64.ActiveCfg = Debug|Any CPU
{A1AA144C-ABCE-462D-ADB4-6EC25AC062B7}.Debug|x64.Build.0 = Debug|Any CPU
{A1AA144C-ABCE-462D-ADB4-6EC25AC062B7}.Debug|x86.ActiveCfg = Debug|Any CPU
{A1AA144C-ABCE-462D-ADB4-6EC25AC062B7}.Debug|x86.Build.0 = Debug|Any CPU
{A1AA144C-ABCE-462D-ADB4-6EC25AC062B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A1AA144C-ABCE-462D-ADB4-6EC25AC062B7}.Release|Any CPU.Build.0 = Release|Any CPU
{A1AA144C-ABCE-462D-ADB4-6EC25AC062B7}.Release|x64.ActiveCfg = Release|Any CPU
{A1AA144C-ABCE-462D-ADB4-6EC25AC062B7}.Release|x64.Build.0 = Release|Any CPU
{A1AA144C-ABCE-462D-ADB4-6EC25AC062B7}.Release|x86.ActiveCfg = Release|Any CPU
{A1AA144C-ABCE-462D-ADB4-6EC25AC062B7}.Release|x86.Build.0 = Release|Any CPU
{9258AD17-0A25-4669-A95C-93EC70882551}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9258AD17-0A25-4669-A95C-93EC70882551}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9258AD17-0A25-4669-A95C-93EC70882551}.Debug|x64.ActiveCfg = Debug|Any CPU
@ -75,8 +45,4 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{1862C3CA-3347-4180-B076-D018BAA70F40} = {3BAA09C4-9E3C-4088-901C-E03489366468}
{A1AA144C-ABCE-462D-ADB4-6EC25AC062B7} = {3BAA09C4-9E3C-4088-901C-E03489366468}
EndGlobalSection
EndGlobal

View File

@ -1,54 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AcaciaTest.Framework
{
/// <summary>
/// TODO: These need to be injected
/// </summary>
public static class Config
{
public static readonly string[] OUTLOOK_PATHS =
{
@"C:\Program Files (x86)\Microsoft Office\root\Office16\OUTLOOK.EXE",
@"C:\Program Files\Microsoft Office\Office15\OUTLOOK.EXE"
};
public const string OUTLOOK_DEFAULT_PROFILE = "Test";
public const int OUTLOOK_START_TIMEOUT = 10000;
public const int OUTLOOK_STOP_TIMEOUT = 5000;
public const string OUTLOOK_RIBBON_TAB_NAME = "Kopano";
public const string OUTLOOK_RIBBON_GROUP_NAME = "Kopano";
public const string MAIL_SERVER = "zarafa.demo";
public const string MAIL_SERVER_USER = "root";
public const string MAIL_SERVER_PASS = "zardemo";
public const string MAIL_ACCOUNT_PREFIX = "demo";
}
}

View File

@ -1,73 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using Microsoft.Test.Input;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Automation;
namespace AcaciaTest.Framework
{
public static class AutomationExtensions
{
#region Searching
public static AutomationElement DescendantByName(this AutomationElement element, params string[] path)
{
return element.DescendantByCondition(
path.Select(value => new PropertyCondition(AutomationElement.NameProperty, value, PropertyConditionFlags.IgnoreCase)));
}
public static AutomationElement DescendantByCondition(this AutomationElement element, IEnumerable<Condition> conditionPath)
{
if (!conditionPath.Any())
return element;
var result = conditionPath.Aggregate(
element,
(parentElement, nextCondition) => parentElement == null
? null
: parentElement.FindFirst(TreeScope.Children, nextCondition));
return result;
}
#endregion
#region Mouse
/// <summary>
/// Performs a mouse click in the center of the element.
/// </summary>
public static AutomationElement MouseClick(this AutomationElement element, MouseButton button = MouseButton.Left)
{
Rect r = element.Current.BoundingRectangle;
Mouse.MoveTo(new System.Drawing.Point((int)(r.X + r.Width / 2), (int)(r.Y + r.Height / 2)));
Mouse.Click(button);
return element;
}
#endregion
}
}

View File

@ -1,67 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AcaciaTest.Framework
{
/// <summary>
/// A simple builder for kopano python
/// </summary>
public class KopanoPython
{
private readonly MailServer server;
private readonly StringBuilder code = new StringBuilder();
public KopanoPython(MailServer server)
{
this.server = server;
// Add the defaults
code
.AppendLine("from MAPI.Util import *")
.AppendLine("import kopano")
.AppendLine("k = kopano.Server()");
}
public KopanoPython User(string name)
{
code.Append("k.user('").Append(name).Append("')");
return this;
}
public KopanoPython Append(string text, bool line = true)
{
code.Append(text);
if (line)
code.AppendLine();
return this;
}
public string Exec()
{
string code = this.code.ToString();
return server.ExecuteCommand("python 2>&1", code);
}
}
}

View File

@ -1,93 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace AcaciaTest.Framework
{
/// <summary>
/// A mail account. This combines both the server-side and client-side accounts and provides methods to manipulate and
/// access both.
/// </summary>
public class MailAccount : IDisposable
{
private readonly MailServer _server;
private readonly string _username;
public string EmailAddress
{
get
{
// TODO
return "k.stiedemann@zarafa.demo";
//return _username + "@" + _server.ServerURL;
}
}
public string FullName
{
get
{
// TODO
return "Kayla Stiedemann";
}
}
internal MailAccount(MailServer server, string username)
{
this._server = server;
this._username = username;
}
public void Dispose()
{
}
/// <summary>
/// Clears any data in the account
/// </summary>
public void Clear()
{
_server.Python().User(_username).Append(".store.inbox.empty()").Exec();
}
/// <summary>
/// Delivers a message to the account
/// </summary>
public void DeliverMessage(MailMessage message, bool unread = true)
{
string cmd = "zarafa-dagent " + (unread ? "" : "-r ") + _username;
string messageContent = message.ToMessage();
_server.ExecuteCommand(cmd, messageContent);
}
/// <summary>
/// Registers the account in the outlook profile.
/// </summary>
/// <param name="outlook"></param>
public void Register(OutlookTester outlook)
{
throw new NotImplementedException(); // TODO
}
}
}

View File

@ -1,86 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace AcaciaTest.Framework
{
public struct MailMessage
{
public string Subject;
public string From;
public string To;
public DateTime? Date;
public string Body;
private Dictionary<string, string> _headers;
public Dictionary<string, string> Headers
{
get
{
if (_headers == null)
_headers = new Dictionary<string, string>();
return _headers;
}
set { _headers = value; }
}
public string ToMessage()
{
Dictionary<string, string> allHeaders = new Dictionary<string, string>();
// Default headers
allHeaders["Mime-Version"] = "1.0";
allHeaders["Content-Type"] = "text/plain";
allHeaders["X-Priority"] = "3 (Normal)";
allHeaders["X-Mailer"] = "Zarafa 7.2.1-51970";
allHeaders["X-Original-Mailer"] = "Zarafa 7.2.1-51970";
allHeaders["X-Original-To"] = "";
allHeaders["Message-Id"] = "<zarafa." + Guid.NewGuid() + "@demo.zarafa.demo>";
// Add specified fields
allHeaders["Subject"] = Subject ?? "Subject";
allHeaders["From"] = From ?? "sender@zarafa.demo";
allHeaders["To"] = To ?? "recipient@zarafa.demo";
allHeaders["Date"] = (Date ?? DateTime.Now).ToString("r");
// Add any custom headers
if (_headers != null)
{
foreach (var entry in _headers)
allHeaders[entry.Key] = entry.Value;
}
StringBuilder s = new StringBuilder();
foreach(var entry in allHeaders)
{
s.Append(entry.Key).Append(": ").Append(entry.Value).AppendLine();
}
s.AppendLine().Append(Body ?? "Message body").AppendLine();
return s.ToString();
}
}
}

View File

@ -1,112 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using Acacia;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Renci.SshNet;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
namespace AcaciaTest.Framework
{
public class MailServer : IDisposable
{
private readonly SshClient ssh;
#region Construction / destruction
public MailServer()
{
ssh = new SshClient(Config.MAIL_SERVER, Config.MAIL_SERVER_USER, Config.MAIL_SERVER_PASS);
ssh.Connect();
}
public void Dispose()
{
if (ssh != null)
{
ssh.Disconnect();
ssh.Dispose();
}
}
public string ServerURL
{
get { return ssh.ConnectionInfo.Host; }
}
#endregion
#region Account management
private int _nextAllocationId = 2;
/// <summary>
/// Allocates a mail account. The allocated account is cleared, unless specified otherwise
/// </summary>
/// <returns></returns>
public MailAccount AllocateAccount(bool clear = true)
{
string accountName = Config.MAIL_ACCOUNT_PREFIX + _nextAllocationId;
++_nextAllocationId;
MailAccount account = new MailAccount(this, accountName);
if (clear)
account.Clear();
return account;
}
#endregion
#region Helpers
/// <summary>
/// Executes the command on the mail server.
/// If the command returns an error, an assert failure is raised.
/// </summary>
/// <param name="command">The command.</param>
/// <param name="stdin">The input for the command, or null if no input is to be specified</param>
/// <returns>The command's output</returns>
internal string ExecuteCommand(string command, string stdin = null)
{
if (stdin != null)
{
const string EOF_SEP = "____E_O_F____";
command = command + "<<" + EOF_SEP + "\n" + stdin + "\n" + EOF_SEP + "\n";
}
SshCommand cmd = ssh.CreateCommand(command);
string reply = cmd.Execute();
Logger.Instance.Trace(this, "SSH: {0} -> {1}", command, reply);
Assert.AreEqual(0, cmd.ExitStatus);
return reply;
}
internal KopanoPython Python()
{
return new KopanoPython(this);
}
#endregion
}
}

View File

@ -1,34 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AcaciaTest.Framework
{
class OutlookConstants
{
internal static readonly string[] PATH_RIBBON = { "MsoDockTop", "Ribbon", "Ribbon", "", "", "Ribbon" };
internal static readonly string[] PATH_RIBBON_BUTTONS = { "Ribbon Tabs" };
internal static readonly string[] PATH_RIBBON_CONTENT = { "Lower Ribbon" };
}
}

View File

@ -1,77 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using Microsoft.Test.Input;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Automation;
namespace AcaciaTest.Framework
{
public class OutlookRibbon
{
private readonly OutlookTester outlook;
private readonly AutomationElement element;
private readonly AutomationElement tabs;
private readonly AutomationElement contentMain;
public AutomationElement Content
{
get;
private set;
}
public OutlookRibbon(OutlookTester outlook, AutomationElement element)
{
Assert.IsNotNull(outlook);
this.outlook = outlook;
Assert.IsNotNull(element);
Assert.AreEqual("Ribbon", element.Current.Name);
this.element = element;
this.tabs = element.DescendantByName(OutlookConstants.PATH_RIBBON_BUTTONS);
Assert.IsNotNull(this.tabs);
this.contentMain = element.DescendantByName(OutlookConstants.PATH_RIBBON_CONTENT);
Assert.IsNotNull(this.contentMain);
}
public bool SelectTab(string name)
{
// Find the tab
var tabItem = tabs.DescendantByName(name);
if (tabItem == null)
return false;
// Click it
tabItem.MouseClick();
// Make sure the content is shown
this.Content = Util.WaitFor(() => this.contentMain.DescendantByName(name), 1000);
Assert.IsNotNull(Content);
return true;
}
}
}

View File

@ -1,166 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Automation;
namespace AcaciaTest.Framework
{
/// <summary>
/// Helper class to run tests using Outlook. Starts outlook and sets up the UI Automation Framework for it.
/// </summary>
public class OutlookTester : IDisposable
{
#region State
private System.Diagnostics.Process outlookProcess;
private AutomationElement mainWindow;
#endregion
public string Profile
{
get;
set;
}
#region Construction / destruction
public OutlookTester()
{
Profile = Config.OUTLOOK_DEFAULT_PROFILE;
}
public string OutlookExe
{
get
{
return Config.OUTLOOK_PATHS.FirstOrDefault((possiblePath) => new FileInfo(possiblePath).Exists);
}
}
private static readonly Regex RE_VERSION = new Regex(@"\\Office(\d{2})\\");
public string OutlookVersion
{
get
{
string exe = OutlookExe;
if (exe == null)
return null;
Match match = RE_VERSION.Match(exe);
return match.Groups[1].Value;
}
}
public void Open()
{
try
{
// Find the executable
Assert.IsNotNull(OutlookExe);
// Start Outlook
var processStartInfo = new System.Diagnostics.ProcessStartInfo(OutlookExe, "/profile " + Profile);
outlookProcess = System.Diagnostics.Process.Start(processStartInfo);
outlookProcess.WaitForInputIdle();
// Wait for the main window to become visible
mainWindow = Util.WaitFor(
() =>
{
// Find the process' main window and make sure it has the correct class.
// The splash screen is the main window first.
// rctrl_renwnd32 is the main window's classname, has been for decades, so should be safe
var win = AutomationElement.RootElement.FindFirst(TreeScope.Children,
new PropertyCondition(AutomationElement.ProcessIdProperty, outlookProcess.Id));
if (win != null && win.Current.ClassName == "rctrl_renwnd32")
return win;
return null;
}, Config.OUTLOOK_START_TIMEOUT);
// Make sure we found the window, otherwise abort
Assert.IsNotNull(mainWindow, "Unable to find Outlook main window");
}
finally
{
// An exception in the constructor means Dispose will not be invoked, kill the process now
if (mainWindow == null)
{
outlookProcess.Kill();
outlookProcess = null;
}
}
}
public void Close()
{
if (outlookProcess != null)
{
// Close the main window and wait for clean shutdown
outlookProcess.CloseMainWindow();
if (!outlookProcess.WaitForExit(Config.OUTLOOK_STOP_TIMEOUT))
{
// Force close if not responding
outlookProcess.Kill();
}
// Clean up resources
outlookProcess.Dispose();
outlookProcess = null;
}
}
public void Dispose()
{
Close();
}
#endregion
#region Ribbon
public OutlookRibbon Ribbon
{
get
{
return new OutlookRibbon(this, mainWindow.DescendantByName(OutlookConstants.PATH_RIBBON));
}
}
#endregion
#region Helpers
public void WaitForInputIdle()
{
outlookProcess.WaitForInputIdle();
}
#endregion
}
}

View File

@ -1,90 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AcaciaTest.Framework
{
[TestClass]
public class TestBase
{
#region Test components
private MailServer _server;
private OutlookTester _outlook;
/// <summary>
/// Provides access to the mail server, creating it if required.
/// </summary>
public MailServer Server
{
get
{
if (_server == null)
_server = new MailServer();
return _server;
}
}
/// <summary>
/// Provides access to Outlook. If the component has not been created yet, it will be. It will not
/// be started automatically.
/// </summary>
public OutlookTester Outlook
{
get
{
if (_outlook == null)
_outlook = new OutlookTester();
return _outlook;
}
}
#endregion
#region Setup / Teardown
[TestInitialize()]
public void Initialize()
{
}
[TestCleanup()]
public void Cleanup()
{
if (_outlook != null)
{
_outlook.Dispose();
_outlook = null;
}
if (_server != null)
{
_server.Dispose();
_server = null;
}
}
#endregion
}
}

View File

@ -1,56 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace AcaciaTest.Framework
{
public static class Util
{
/// <summary>
/// Waits for the function to return a value, by polling.
/// </summary>
/// <param name="func">The function. If this returns a value, wait is finished and the value is returned.
/// If null is returned, another attempt will be made, unless the timeout has been reached</param>
/// <param name="timeout">The timeout, in milliseconds.</param>
/// <returns>The functions return value, or null if the timeout elapsed</returns>
public static Type WaitFor<Type>(Func<Type> func, long timeout)
{
System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
stopWatch.Start();
var result = default(Type);
while (stopWatch.ElapsedMilliseconds < timeout)
{
result = func();
if (result != null)
break;
// Sleep and try again
Thread.Sleep(100);
}
return result;
}
}
}

View File

@ -1,124 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A1AA144C-ABCE-462D-ADB4-6EC25AC062B7}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AcaciaTest</RootNamespace>
<AssemblyName>OutlookIntegrationTests</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Build\Test\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>
</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Build\Test\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>
</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="Renci.SshNet, Version=2013.4.7.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\SSH.NET.2013.4.7\lib\net40\Renci.SshNet.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="TestApiCore, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.TestApi.0.6.0.0\lib\net40\TestApiCore.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="TestApiWpf, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.TestApi.0.6.0.0\lib\net40\TestApiWpf.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="UIAutomationClient" />
<Reference Include="UIAutomationTypes" />
<Reference Include="WindowsBase" />
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
</ItemGroup>
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="Config.cs" />
<Compile Include="Framework\AutomationExtensions.cs" />
<Compile Include="Framework\MailAccount.cs" />
<Compile Include="Framework\MailMessage.cs" />
<Compile Include="Framework\MailServer.cs" />
<Compile Include="Framework\OutlookConstants.cs" />
<Compile Include="Framework\OutlookRibbon.cs" />
<Compile Include="Framework\OutlookTester.cs" />
<Compile Include="Framework\TestBase.cs" />
<Compile Include="Framework\Util.cs" />
<Compile Include="Framework\KopanoPython.cs" />
<Compile Include="Tests\ReplyFlagsTest.cs" />
<Compile Include="Tests\RibbonTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\AcaciaZPushPlugin\AcaciaZPushPlugin.csproj">
<Project>{1a7427a5-f814-4b07-98b2-c67d758b65d6}</Project>
<Name>AcaciaZPushPlugin</Name>
</ProjectReference>
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
</ItemGroup>
</When>
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OutlookIntegrationTests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OutlookIntegrationTests")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("a1aa144c-abce-462d-adb4-6ec25ac062b7")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,50 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using AcaciaTest.Framework;
using System.Threading;
namespace AcaciaTest.Tests
{
[TestClass]
public class ReplyFlagsTest : TestBase
{
[TestMethod]
public void ReplyFlags()
{
using (MailAccount account = Server.AllocateAccount())
{
// Deliver a message with a reply status
DateTime yesterday = DateTime.Now.AddDays(-1);
DateTime twoDaysAgo = DateTime.Now.AddDays(-2);
// TODO: this header is out of date
account.DeliverMessage(new MailMessage()
{
Date = twoDaysAgo,
Headers = { { "X-Zarafa-Messagestatus", "reply=" + yesterday.ToString("r") } }
}, false);
// Open outlook
//Outlook.Open();
}
}
}
}

View File

@ -1,46 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using AcaciaTest.Framework;
using System.Threading;
namespace AcaciaTest.Tests
{
[TestClass]
public class RibbonTest : TestBase
{
[TestMethod]
public void RibbonVisible()
{
Outlook.Open();
var ribbon = Outlook.Ribbon;
// Select the tab that should have the plugin
Assert.IsTrue(ribbon.SelectTab(Config.OUTLOOK_RIBBON_TAB_NAME));
// Make sure the group is there
var group = ribbon.Content.DescendantByName(Config.OUTLOOK_RIBBON_GROUP_NAME);
Assert.IsNotNull(group);
Assert.IsFalse(group.Current.IsOffscreen);
Assert.IsTrue(group.Current.IsEnabled);
}
}
}

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.TestApi" version="0.6.0.0" targetFramework="net452" />
<package id="SSH.NET" version="2013.4.7" targetFramework="net452" />
</packages>

View File

@ -1,33 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Acacia.Stubs;
namespace AcaciaTest.Mocks
{
public class AddressBook : Folder, IAddressBook
{
public IEnumerable<ContactItem> Contacts { get { return Items.Cast<ContactItem>(); } }
}
}

View File

@ -1,50 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Acacia.Stubs;
namespace AcaciaTest.Mocks
{
public class AppointmentItem : Item, IAppointmentItem
{
#region IAppointmentItem implementation
public DateTime Start
{
get { return BuiltinProperty<DateTime>("Start"); }
set { BuiltinProperty<DateTime>("Start", value); }
}
public DateTime End
{
get { return BuiltinProperty<DateTime>("End"); }
set { BuiltinProperty<DateTime>("End", value); }
}
public string Location
{
get { return BuiltinProperty<string>("Location"); }
set { BuiltinProperty<string>("Location", value); }
}
#endregion
}
}

View File

@ -1,140 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Acacia.Stubs;
using System.Runtime.CompilerServices;
namespace AcaciaTest.Mocks
{
abstract public class Base : IBase
{
public bool MustRelease { get; set; }
#region Builtin properties
private Dictionary<string, object> _builtins = new Dictionary<string, object>();
protected PropType BuiltinProperty<PropType>(string name)
{
if (!_builtins.ContainsKey(name))
{
_builtins.Add(name, DefaultValues.Get<PropType>());
}
return (PropType)_builtins[name];
}
protected void BuiltinProperty<Type>(string name, Type value)
{
_builtins[name] = value;
IsDirty = true;
}
public object GetBuiltinPropertyValue(string name)
{
object value;
_builtins.TryGetValue(name, out value);
return value;
}
public bool AttrHidden
{
get { return BuiltinProperty<bool>("AttrHidden"); }
set { BuiltinProperty<bool>("AttrHidden", value); }
}
#endregion
private bool _isDirty;
public bool IsDirty
{
get { return _isDirty; }
set
{
_isDirty = value;
_builtins["LastModificationTime"] = DateTime.Now;
}
}
public DateTime LastModificationTime
{
get { return BuiltinProperty<DateTime>("LastModificationTime"); }
}
virtual public IFolder Parent
{
get;
set;
}
virtual public string ParentEntryId
{
get { return Parent?.EntryId; }
}
public string EntryId { get { return RuntimeHelpers.GetHashCode(this).ToString("X8"); } }
public IStore Store
{
get
{
return Mocks.Store.INSTANCE;
}
}
public string StoreId
{
get
{
return Store.StoreID;
}
}
public string StoreDisplayName
{
get
{
return Store.DisplayName;
}
}
public void Dispose()
{
// TODO: record?
}
abstract public void Delete();
public dynamic GetProperty(string property)
{
throw new NotImplementedException();
}
public void SetProperties(string[] properties, object[] values)
{
throw new NotImplementedException();
}
public void SetProperty(string property, object value)
{
throw new NotImplementedException();
}
}
}

View File

@ -1,192 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Acacia.Stubs;
namespace AcaciaTest.Mocks
{
public class ContactItem : Item, IContactItem
{
private readonly AddressBook _addressBook;
private readonly int _id;
internal ContactItem(AddressBook addressBook, int id)
{
this._addressBook = addressBook;
this._id = id;
}
override public IFolder Parent
{
get { return _addressBook; }
}
#region IContactItem
public string CustomerID
{
get { return BuiltinProperty<string>("CustomerID"); }
set { BuiltinProperty<string>("CustomerID", value); }
}
public string FullName
{
get { return BuiltinProperty<string>("FullName"); }
set { BuiltinProperty<string>("FullName", value); }
}
public string FirstName
{
get { return BuiltinProperty<string>("FirstName"); }
set { BuiltinProperty<string>("FirstName", value); }
}
public string LastName
{
get { return BuiltinProperty<string>("LastName"); }
set { BuiltinProperty<string>("LastName", value); }
}
public string Initials
{
get { return BuiltinProperty<string>("Initials"); }
set { BuiltinProperty<string>("Initials", value); }
}
public string Title
{
get { return BuiltinProperty<string>("Title"); }
set { BuiltinProperty<string>("Title", value); }
}
public string Email1Address
{
get { return BuiltinProperty<string>("Email1Address"); }
set { BuiltinProperty<string>("Email1Address", value); }
}
public string Email1AddressType
{
get { return BuiltinProperty<string>("Email1AddressType"); }
set { BuiltinProperty<string>("Email1AddressType", value); }
}
public string CompanyName
{
get { return BuiltinProperty<string>("CompanyName"); }
set { BuiltinProperty<string>("CompanyName", value); }
}
public string JobTitle
{
get { return BuiltinProperty<string>("JobTitle"); }
set { BuiltinProperty<string>("JobTitle", value); }
}
public string OfficeLocation
{
get { return BuiltinProperty<string>("OfficeLocation"); }
set { BuiltinProperty<string>("OfficeLocation", value); }
}
public string BusinessTelephoneNumber
{
get { return BuiltinProperty<string>("BusinessTelephoneNumber"); }
set { BuiltinProperty<string>("BusinessTelephoneNumber", value); }
}
public string MobileTelephoneNumber
{
get { return BuiltinProperty<string>("MobileTelephoneNumber"); }
set { BuiltinProperty<string>("MobileTelephoneNumber", value); }
}
public string HomeTelephoneNumber
{
get { return BuiltinProperty<string>("HomeTelephoneNumber"); }
set { BuiltinProperty<string>("HomeTelephoneNumber", value); }
}
public string PagerNumber
{
get { return BuiltinProperty<string>("PagerNumber"); }
set { BuiltinProperty<string>("PagerNumber", value); }
}
public string BusinessFaxNumber
{
get { return BuiltinProperty<string>("BusinessFaxNumber"); }
set { BuiltinProperty<string>("BusinessFaxNumber", value); }
}
public string OrganizationalIDNumber
{
get { return BuiltinProperty<string>("OrganizationalIDNumber"); }
set { BuiltinProperty<string>("OrganizationalIDNumber", value); }
}
public string BusinessAddress
{
get { return BuiltinProperty<string>("BusinessAddress"); }
set { BuiltinProperty<string>("BusinessAddress", value); }
}
public string BusinessAddressCity
{
get { return BuiltinProperty<string>("BusinessAddressCity"); }
set { BuiltinProperty<string>("BusinessAddressCity", value); }
}
public string BusinessAddressPostalCode
{
get { return BuiltinProperty<string>("BusinessAddressPostalCode"); }
set { BuiltinProperty<string>("BusinessAddressPostalCode", value); }
}
public string BusinessAddressPostOfficeBox
{
get { return BuiltinProperty<string>("BusinessAddressPostOfficeBox"); }
set { BuiltinProperty<string>("BusinessAddressPostOfficeBox", value); }
}
public string BusinessAddressState
{
get { return BuiltinProperty<string>("BusinessAddressState"); }
set { BuiltinProperty<string>("BusinessAddressState", value); }
}
public string Language
{
get { return BuiltinProperty<string>("Language"); }
set { BuiltinProperty<string>("Language", value); }
}
public void SetPicture(string path)
{
// TODO
}
#endregion
}
}

View File

@ -1,49 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AcaciaTest.Mocks
{
class DefaultValues
{
internal static PropType Get<PropType>()
{
return (PropType)GetImpl<PropType>();
}
private static object GetImpl<PropType>()
{
if (typeof(PropType) == typeof(string))
return "";
else if (typeof(PropType) == typeof(DateTime))
return new DateTime(0); // TODO
else if (typeof(PropType) == typeof(int))
return (int)0;
else if (typeof(PropType).IsEnum)
return typeof(PropType).GetEnumValues().GetValue(0);
else
throw new NotImplementedException(); // TODO
}
}
}

View File

@ -1,321 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Acacia.Stubs;
using Acacia.ZPush;
namespace AcaciaTest.Mocks
{
public class Folder : Base, IFolder
{
private readonly List<IItem> _items = new List<IItem>();
public void Clear()
{
_items.Clear();
IsDirty = true;
}
override public void Delete()
{
throw new NotImplementedException();
}
public void Add(IItem item)
{
_items.Add(item);
((Item)item).Parent = this;
}
public bool IsAtDepth(int depth)
{
IFolder current = this;
for (int i = 0; i < depth; ++i)
{
IFolder parent = current.Parent;
if (parent == null)
return false;
current = parent;
}
return current == null;
}
public ItemType ItemType
{
get
{
throw new NotImplementedException(); // TODO
}
}
public SyncId SyncId
{
get
{
throw new NotImplementedException(); // TODO
}
}
public IEnumerable<IItem> Items
{
get{ return _items; }
}
public IItem GetItemById(string entryId)
{
return _items.Find((item) => item.EntryId == entryId);
}
public int Count { get { return _items.Count; } }
public IEnumerable<IItem> ItemsSorted(string field, bool descending)
{
List<IItem> copy = new List<IItem>(_items);
copy.Sort((x, y) =>
{
int sign = descending ? -1 : 1;
Item xi = (Item)x;
Item yi = (Item)y;
object valueX = xi.GetBuiltinPropertyValue(field);
object valueY = yi.GetBuiltinPropertyValue(field);
if (valueX == null || valueY == null)
{
return (valueX == null && valueY == null) ? 0 : (valueX == null ? -sign : sign);
}
return sign * ((IComparable)valueX).CompareTo(valueY);
}
);
return copy;
}
public string Name
{
get;
set;
}
public string Description
{
get;
set;
}
public string DefaultMessageClass
{
get;
set;
}
public bool ShowAsOutlookAB
{
get;
set;
}
virtual public void Delete(IItem child)
{
_items.Remove(child);
}
#region Item creation
public ItemType Create<ItemType>()
where ItemType : IItem
{
ItemType item = MockFactory.Create<ItemType>(this, Count);
Add(item);
IsDirty = true;
return item;
}
#endregion
#region Searching
private class SearchField
:
ISearchField
{
public string Name { get; set; }
public bool IsUserField { get; set; }
public SearchOperation Operation { get; set; }
public dynamic Parameter { get; set; }
public SearchField(string name, bool isUserField)
{
this.Name = name;
this.IsUserField = isUserField;
}
public void SetOperation(SearchOperation operation, object param)
{
this.Operation = operation;
this.Parameter = param;
}
internal bool Matches(Item item)
{
dynamic value;
if (IsUserField)
{
if (!item.GetUserPropertyRaw(Name, out value))
return false;
}
else
{
value = ((Base)item).GetBuiltinPropertyValue(Name);
}
switch(Operation)
{
case SearchOperation.Equal:
return value == Parameter;
case SearchOperation.NotEqual:
return value != Parameter;
case SearchOperation.SmallerEqual:
return value <= Parameter;
case SearchOperation.Smaller:
return value < Parameter;
case SearchOperation.GreaterEqual:
return value >= Parameter;
case SearchOperation.Greater:
return value > Parameter;
}
return false;
}
}
private class FolderSearch<Type>
:
ISearch<Type>
where Type : IItem
{
private readonly Folder _folder;
private readonly List<SearchField> _fields = new List<SearchField>();
public FolderSearch(Folder folder)
{
this._folder = folder;
}
public ISearchField AddField(string name, bool isUserField = false)
{
SearchField field = new SearchField(name, isUserField);
_fields.Add(field);
return field;
}
public IEnumerable<Type> Search(int maxResults)
{
return DoSearch(maxResults);
}
public Type SearchOne()
{
List<Type> results = DoSearch();
if (results.Count > 0)
return results[0];
return default(Type);
}
private List<Type> DoSearch(int maxResults = int.MaxValue)
{
// TODO: handle maxResults
List<Type> results = new List<Type>();
foreach(IItem item in _folder.Items)
{
// TODO: check type?
bool match = true;
foreach(SearchField field in _fields)
{
if (!field.Matches((Item)item))
{
match = false;
break;
}
}
if (match)
results.Add((Type)item);
}
return results;
}
public ISearchOperator AddOperator(SearchOperator oper)
{
throw new NotImplementedException();
}
}
public ISearch<ItemType> Search<ItemType>()
where ItemType: IItem
{
return new FolderSearch<ItemType>(this);
}
public FolderType CreateFolder<FolderType>(string name) where FolderType : IFolder
{
throw new NotImplementedException();
}
public FolderType GetSubFolder<FolderType>(string name) where FolderType : IFolder
{
throw new NotImplementedException();
}
public IEnumerable<FolderType> GetSubFolders<FolderType>() where FolderType : IFolder
{
throw new NotImplementedException();
}
#endregion
#region Index item
private readonly Dictionary<string, StorageItem> _storageItems = new Dictionary<string, StorageItem>();
public IStorageItem GetStorageItem(string name)
{
StorageItem item;
if (!_storageItems.TryGetValue(name, out item))
{
item = new StorageItem();
_storageItems.Add(name, item);
}
return item;
}
#endregion
public event IFolder_BeforeItemMove BeforeItemMove
{
add { }
remove { }
}
}
}

View File

@ -1,97 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Acacia.Stubs;
namespace AcaciaTest.Mocks
{
public class Item : Base, IItem
{
#region Builtin properties
public string[] AttrCategories
{
get { return BuiltinProperty<string[]>("AttrCategories"); }
set { BuiltinProperty<string[]>("AttrCategories", value); }
}
public string Body
{
get { return BuiltinProperty<string>("Body"); }
set { BuiltinProperty<string>("Body", value); }
}
public string Subject
{
get { return BuiltinProperty<string>("Subject"); }
set { BuiltinProperty<string>("Subject", value); }
}
#endregion
#region User properties
private readonly Dictionary<string, object> _userProperties = new Dictionary<string, object>();
public IUserProperty<PropType> GetUserProperty<PropType>(string name, bool create = false)
{
if (!_userProperties.ContainsKey(name))
{
if (!create)
return null;
_userProperties.Add(name, new UserProperty<PropType>());
}
return (IUserProperty<PropType>)_userProperties[name];
}
public bool GetUserPropertyRaw(string name, out object value)
{
if (!_userProperties.ContainsKey(name))
{
value = null;
return false;
}
value = ((UserPropertyBase)_userProperties[name]).RawValue;
return true;
}
#endregion
override public void Delete()
{
// TODO: mark deleted?
if (Parent is Folder)
((Folder) Parent).Delete(this);
}
public int SaveCount { get; set; }
public object Tag { get; set; }
virtual public void Save()
{
IsDirty = false;
++SaveCount;
}
}
}

View File

@ -1,41 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using Acacia;
using Acacia.Stubs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AcaciaTest.Mocks
{
static class MockFactory
{
public static ItemType Create<ItemType>(Folder parent, int id)
where ItemType : IItem
{
if (typeof(ItemType) == typeof(IContactItem))
return (ItemType)(IItem)new ContactItem((AddressBook)parent, id);
Logger.Instance.Debug(typeof(MockFactory), "CREATE: " + typeof(ItemType));
throw new NotImplementedException(); // TODO
}
}
}

View File

@ -1,32 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Acacia.Stubs;
namespace AcaciaTest.Mocks
{
class StorageItem : Item, IStorageItem
{
}
}

View File

@ -1,68 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using Acacia.Stubs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AcaciaTest.Mocks
{
public class Store : IStore
{
public static readonly Store INSTANCE = new Store();
public string DisplayName
{
get
{
return "<TESTSTORE>";
}
}
public string StoreID
{
get
{
return "<TESTSTOREID>";
}
}
public void Dispose()
{
}
public IFolder GetDefaultFolder(object folder)
{
throw new NotImplementedException();
}
public IItem GetItemFromID(string id)
{
throw new NotImplementedException();
}
public IFolder GetRootFolder()
{
throw new NotImplementedException();
}
}
}

View File

@ -1,50 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Acacia.Stubs;
namespace AcaciaTest.Mocks
{
internal interface UserPropertyBase
{
object RawValue { get; }
}
internal class UserProperty<PropType> : IUserProperty<PropType>, UserPropertyBase
{
internal UserProperty()
{
Value = DefaultValues.Get<PropType>();
}
public PropType Value
{
get;
set;
}
public object RawValue { get { return Value; } }
}
}

View File

@ -1,45 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Acacia.Stubs;
namespace AcaciaTest.Mocks
{
public class ZPushItem : AppointmentItem, IZPushItem
{
public ZPushItem()
{
}
/// <summary>
/// Convenience constructor
/// </summary>
public ZPushItem(string subject, string body)
{
this.Subject = subject;
this.Body = body;
}
}
}

View File

@ -1,127 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1862C3CA-3347-4180-B076-D018BAA70F40}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AcaciaTest</RootNamespace>
<AssemblyName>PluginUnitTests</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Build\Test\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Build\Test\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Renci.SshNet, Version=2013.4.7.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SSH.NET.2013.4.7\lib\net40\Renci.SshNet.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="TestApiCore, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TestApi.0.6.0.0\lib\net40\TestApiCore.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="TestApiWpf, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TestApi.0.6.0.0\lib\net40\TestApiWpf.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="UIAutomationClient" />
<Reference Include="UIAutomationTypes" />
<Reference Include="WindowsBase" />
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework">
<Private>False</Private>
</Reference>
</ItemGroup>
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="Mocks\AddressBook.cs" />
<Compile Include="Mocks\AppointmentItem.cs" />
<Compile Include="Mocks\Base.cs" />
<Compile Include="Mocks\ContactItem.cs" />
<Compile Include="Mocks\DefaultValues.cs" />
<Compile Include="Mocks\Folder.cs" />
<Compile Include="Mocks\Item.cs" />
<Compile Include="Mocks\MockFactory.cs" />
<Compile Include="Mocks\StorageItem.cs" />
<Compile Include="Mocks\Store.cs" />
<Compile Include="Mocks\UserProperty.cs" />
<Compile Include="Mocks\ZPushItem.cs" />
<Compile Include="Tests\GAB\GABTest.cs" />
<Compile Include="Tests\GAB\TestChunks.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Tests\ReplyFlagsTest.cs" />
<Compile Include="Tests\PasswordEncryptionTest.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\AcaciaZPushPlugin\AcaciaZPushPlugin.csproj">
<Project>{1a7427a5-f814-4b07-98b2-c67d758b65d6}</Project>
<Name>AcaciaZPushPlugin</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
</ItemGroup>
</When>
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("PluginUnitTests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PluginUnitTests")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1862c3ca-3347-4180-b076-d018baa70f40")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,248 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Acacia.Features.GAB;
using AcaciaTest.Mocks;
using System.Threading;
using Acacia;
using Acacia.Utils;
namespace AcaciaTest.Tests.GAB
{
[TestClass]
public class GABTest
{
private readonly AddressBook gab;
private readonly GABHandler handler;
private Folder chunks;
public GABTest()
{
DebugOptions.ReturnDefaults = true;
gab = new AddressBook();
chunks = new Folder();
handler = new GABHandler(new FeatureGAB(), (f) => gab, null);
handler.AddAccount(null, chunks);
Tasks.Executor = new TasksSynchronous();
}
internal static string MakeChunkSubject(int sequence, int chunk)
{
return string.Format("account-{0}/{1}", sequence, chunk);
}
[TestMethod]
public void MultipleChunks()
{
TestChunks chunks = new TestChunks(10);
chunks.GenerateChunks(this.chunks, 2);
handler.Process(null);
Assert.AreEqual(10, gab.Count);
HashSet<int> seen = new HashSet<int>();
foreach(ContactItem item in gab.Items)
{
int id = int.Parse(item.CustomerID.Substring(4));
seen.Add(id);
Assert.AreEqual(string.Format("{0} 0", id), item.FullName);
Assert.AreEqual(1, item.SaveCount);
// Set a tag to ensure it is not replaced.
item.Tag = "ABC";
}
Assert.AreEqual(10, seen.Count);
// Touch a contact in the first chunk
chunks.TouchContact(1);
// Regenerate the chunks
chunks.GenerateChunks(this.chunks, 2);
handler.Process(null);
seen.Clear();
foreach (ContactItem item in gab.Items)
{
int id = int.Parse(item.CustomerID.Substring(4));
seen.Add(id);
Assert.AreEqual(string.Format("{0} {1}", id, id == 1 ? 1 : 0), item.FullName);
if (id >= 5)
{
// Make sure items in the second chunk aren't touched.
Assert.AreEqual("ABC", item.Tag);
Assert.AreEqual(1, item.SaveCount);
}
else
{
// Items in the first chunk should have been replaced.
Assert.IsNull(item.Tag);
Assert.AreEqual(1, item.SaveCount);
}
}
Assert.AreEqual(10, seen.Count);
}
[TestMethod]
public void CheckCurrentSequence()
{
// The resolution of the timer is less than 10ms, hence the sleeps
chunks.Add(new ZPushItem(MakeChunkSubject(1, 0), "{'user1': {} }")); Thread.Sleep(10);
chunks.Add(new ZPushItem(MakeChunkSubject(4, 0), "{'user4': {} }")); Thread.Sleep(10);
chunks.Add(new ZPushItem(MakeChunkSubject(5, 0), "{'user5': {} }")); Thread.Sleep(10);
chunks.Add(new ZPushItem(MakeChunkSubject(2, 0), "{'user2': {} }"));
handler.DetermineSequence();
Assert.AreEqual(2, handler.CurrentSequence);
handler.Process(null);
Assert.AreEqual(2, handler.CurrentSequence);
Assert.AreEqual(false, ((StorageItem)gab.GetStorageItem(Constants.ZPUSH_GAB_INDEX)).IsDirty);
}
/// <summary>
/// Tests creating a GAB from an empty starting point with access to the full chunks.
/// </summary>
[TestMethod]
public void FullLoadOnce()
{
ZPushItem chunk = new ZPushItem();
chunk.Subject = MakeChunkSubject(1, 0);
chunk.Body = "{'user1': {\"displayName\": \"Version 0\", \"type\": \"contact\"} }";
chunk.Location = "Version 0";
chunk.Start = DateTime.Now;
chunks.Add(chunk);
// Process the chunk
handler.Process(null);
// Make sure we have a single contact
Assert.AreEqual(1, gab.Count);
Assert.AreEqual(true, gab.IsDirty);
// Make sure it is correct
ContactItem item = gab.Contacts.First();
Assert.AreEqual(false, item.IsDirty);
Assert.AreEqual("user1", item.CustomerID);
Assert.AreEqual("Version 0", item.FullName);
// Make sure it has the correct ids
Assert.AreEqual(1, item.GetUserProperty<int>(GABHandler.PROP_SEQUENCE).Value);
Assert.AreEqual(0, item.GetUserProperty<int>(GABHandler.PROP_CHUNK).Value);
}
/// <summary>
/// Tests processing a modified message correctly updates the contacts
/// </summary>
[TestMethod]
public void FullLoadModify()
{
FullLoadOnce();
ZPushItem chunk = (ZPushItem)chunks.Items.First();
chunk.Body = "{'user1': {\"displayName\": \"Version 1\", \"type\": \"contact\"} }";
chunk.Start = DateTime.Now;
chunk.Location = "Version 1";
gab.IsDirty = false;
handler.Process(chunk);
// Make sure we have a single contact
Assert.AreEqual(1, gab.Count);
Assert.AreEqual(true, gab.IsDirty);
// Make sure it is correct
ContactItem item = gab.Contacts.First();
Assert.AreEqual(false, item.IsDirty);
Assert.AreEqual("user1", item.CustomerID);
Assert.AreEqual("Version 1", item.FullName);
// Make sure it has the correct ids
Assert.AreEqual(1, item.GetUserProperty<int>(GABHandler.PROP_SEQUENCE).Value);
Assert.AreEqual(0, item.GetUserProperty<int>(GABHandler.PROP_CHUNK).Value);
}
/// <summary>
/// Tests processing already processed messages does nothing
/// </summary>
[TestMethod]
public void FullLoadMultiProcess()
{
FullLoadOnce();
// Make sure processing the messages again does nothing
gab.IsDirty = false;
handler.Process(null);
Assert.AreEqual(false, gab.IsDirty);
Assert.AreEqual(false, gab.Contacts.First().IsDirty);
}
/// <summary>
/// Tests that all item values are propagated properly.
/// </summary>
[TestMethod]
public void ItemProperties()
{
ZPushItem chunk0 = new ZPushItem();
chunk0.Subject = MakeChunkSubject(1, 0);
chunk0.Body =
@"{""test1"":{""account"":""test1"",""displayName"":""Test One"",""givenName"":""Test"",""surname"":""One""," +
@"""smtpAddress"":""onetest@example.com"",""title"":""Dr"",""companyName"":""Business"",""officeLocation"":""The moon""," +
@"""businessTelephoneNumber"":""+ 1 408 555 2320"",""mobileTelephoneNumber"":""7"",""homeTelephoneNumber"":""8""," +
@"""beeperTelephoneNumber"":""9"",""primaryFaxNumber"":""+ 1 408 555 7472"",""organizationalIdNumber"":""23""," +
@"""postalAddress"":""Multiline
Address"",""businessAddressCity"":""Santa Clara"",""businessAddressPostalCode"":""1234AB""," +
@"""businessAddressPostOfficeBox"":""56"",""businessAddressStateOrProvince"":""Iowa"",""initials"":""1""," +
@"""language"":""Lang"",""thumbnailPhoto"":null, ""type"": ""contact""}}";
handler.CurrentSequence = 1;
handler.Process(chunk0);
// Make sure we have a single contact
Assert.AreEqual(1, gab.Count);
// Make sure it is correct
ContactItem item = gab.Contacts.First();
Assert.AreEqual(false, item.IsDirty);
Assert.AreEqual("test1", item.CustomerID);
Assert.AreEqual("Test One", item.FullName);
Assert.AreEqual("Test", item.FirstName);
Assert.AreEqual("One", item.LastName);
Assert.AreEqual("1", item.Initials);
Assert.AreEqual("Dr", item.JobTitle);
Assert.AreEqual("Lang", item.Language);
Assert.AreEqual("onetest@example.com", item.Email1Address);
Assert.AreEqual("SMTP", item.Email1AddressType);
Assert.AreEqual("Business", item.CompanyName);
Assert.AreEqual("The moon", item.OfficeLocation);
Assert.AreEqual("+ 1 408 555 2320", item.BusinessTelephoneNumber);
Assert.AreEqual("7", item.MobileTelephoneNumber);
Assert.AreEqual("8", item.HomeTelephoneNumber);
Assert.AreEqual("9", item.PagerNumber);
Assert.AreEqual("+ 1 408 555 7472", item.BusinessFaxNumber);
Assert.AreEqual("23", item.OrganizationalIDNumber);
Assert.AreEqual("Multiline\r\nAddress", item.BusinessAddress);
Assert.AreEqual("Santa Clara", item.BusinessAddressCity);
Assert.AreEqual("1234AB", item.BusinessAddressPostalCode);
Assert.AreEqual("56", item.BusinessAddressPostOfficeBox);
Assert.AreEqual("Iowa", item.BusinessAddressState);
}
}
}

View File

@ -1,119 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Acacia.Stubs;
using AcaciaTest.Mocks;
using Acacia;
namespace AcaciaTest.Tests.GAB
{
class TestChunks
{
private class ContactInfo
{
public int id;
public int version;
public string ToJSON()
{
return string.Format(" \"user{0}\":{{\"account\": \"user{0}\", \"displayName\": \"{0} {1}\", \"type\": \"contact\"}}", id, version);
}
}
private readonly List<ContactInfo> contacts = new List<ContactInfo>();
private int lastSequence = -1;
private int lastContactVersion = -1;
public TestChunks(int numberOfContacts)
{
for (int i = 0; i < numberOfContacts; ++i)
{
contacts.Add(new ContactInfo()
{
id = i,
version = 0
});
}
}
public void TouchContact(int index)
{
++contacts[index].version;
}
public void GenerateChunks(Folder folder, int numberOfChunks)
{
if (numberOfChunks != lastSequence)
folder.Clear();
int chunksPerContact = (int)Math.Ceiling(contacts.Count / (double)numberOfChunks);
int chunksRemaining = contacts.Count;
int contactVersion = -1;
for (int i = 0; i < numberOfChunks; ++i)
{
int thisChunkCount = Math.Min(chunksRemaining, chunksPerContact);
int chunkContactVersion = -1;
// Create the body
string body = "{\n";
for (int j = 0; j < thisChunkCount; ++j)
{
ContactInfo contact = contacts[contacts.Count - chunksRemaining];
body += contact.ToJSON();
chunkContactVersion = Math.Max(chunkContactVersion, contact.version);
--chunksRemaining;
if (j < thisChunkCount - 1)
body += ",\n";
else
body += "\n";
}
body += "}\n";
string subject = GABTest.MakeChunkSubject(numberOfChunks, i);
if (chunkContactVersion <= lastContactVersion)
{
continue;
}
contactVersion = Math.Max(contactVersion, chunkContactVersion);
// See if the message exists
ISearch<ZPushItem> search = folder.Search<ZPushItem>();
search.AddField("Subject").SetOperation(SearchOperation.Equal, subject);
ZPushItem item = search.SearchOne();
if (item == null)
{
item = new ZPushItem(subject, body);
folder.Add(item);
}
item.Body = body;
item.Location = "Version:" + chunkContactVersion;
item.Save();
}
lastSequence = numberOfChunks;
lastContactVersion = contactVersion;
}
}
}

View File

@ -1,54 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Acacia;
using Acacia.Utils;
using System.Security;
namespace AcaciaTest.Tests
{
[TestClass]
public class PasswordEncryptionTest
{
[TestMethod]
public void Encrypt()
{
// As the encryption depends on the machine, we cannot test the actual encryption,
// just check some metadata
byte[] cipher = PasswordEncryption.Encrypt("demo1");
Assert.AreEqual(255, cipher.Length);
Assert.AreEqual(2, cipher[0]);
}
[TestMethod]
public void RoundTrip()
{
// Test a few different lengths, including some block boundaries at 8, 16 and empty string
string sin = "";
for (int i = 0; i <= 16; ++i)
{
sin += i;
SecureString sout = PasswordEncryption.Decrypt(PasswordEncryption.Encrypt(sin));
Assert.AreEqual(sin, sout.ConvertToUnsecureString());
}
}
}
}

View File

@ -1,34 +0,0 @@
/// Project : Kopano OL Extension
///
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
/// as published by the Free Software Foundation.
///
/// 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/>.
///
/// Consult LICENSE file for details
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Threading;
namespace AcaciaTest.Tests
{
[TestClass]
public class ReplyFlagsTest
{
[TestMethod]
public void ReplyFlags()
{
}
}
}

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.TestApi" version="0.6.0.0" targetFramework="net452" />
<package id="SSH.NET" version="2013.4.7" targetFramework="net452" />
</packages>