Skip to content

Commit

Permalink
Merge branch 'release/3.0.3rc5'
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-brooke committed Apr 26, 2017
2 parents 4ab6852 + 8e56081 commit 72541f5
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 19 deletions.
58 changes: 58 additions & 0 deletions SuiteCRMAddIn/BusinessLogic/EmailCategoriesCollection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Outlook integration for SuiteCRM.
* @package Outlook integration for SuiteCRM
* @copyright SalesAgility Ltd http://www.salesagility.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU LESSER GENERAL PUBLIC LICENCE 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 General Public License for more details.
*
* You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENCE
* along with this program; if not, see http://www.gnu.org/licenses
* or write to the Free Software Foundation,Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301 USA
*
* @author SalesAgility <[email protected]>
*/
namespace SuiteCRMAddIn.BusinessLogic
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

/// <summary>
/// A list of the email categories known to the connected CRM instance, if that
/// CRM instance supports the email categories feature. If it does not, the
/// IsImplemented property will be false.
/// </summary>
public class EmailCategoriesCollection : List<string>
{
/// <summary>
/// True if my connected CRM instance implementes email categories.
/// </summary>
private bool isImplemented = true;

/// <summary>
/// True if my connected CRM instance implementes email categories.
/// </summary>
public bool IsImplemented
{
get
{
return this.isImplemented && this.Count > 0;
}
internal set
{
this.isImplemented = value;
}
}
}
}
11 changes: 9 additions & 2 deletions SuiteCRMAddIn/Daemon/FetchEmailCategoriesAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
namespace SuiteCRMAddIn.Daemon
{
using BusinessLogic;
using SuiteCRMClient;
using SuiteCRMClient.RESTObjects;
using System.Collections.Generic;
Expand All @@ -39,13 +40,13 @@ public class FetchEmailCategoriesAction : AbstractDaemonAction
/// <summary>
/// The list of items I shall modify.
/// </summary>
private readonly List<string> items;
private readonly EmailCategoriesCollection items;

/// <summary>
/// Construct a new instance of the FetchEmailCategoriesAction class.
/// </summary>
/// <param name="listToModify">The list of items I shall modify</param>
public FetchEmailCategoriesAction(List<string> listToModify) : base(5)
public FetchEmailCategoriesAction(EmailCategoriesCollection listToModify) : base(5)
{
this.items = listToModify;
}
Expand All @@ -60,9 +61,15 @@ public override void Perform()

if (field != null)
{
items.IsImplemented = true;
items.Clear();
items.AddRange(field.Options.Keys.OrderBy(x => x));
}
else
{
/* the CRM instance does not have the category_id field in its emails module */
items.IsImplemented = false;
}
}
}
}
8 changes: 7 additions & 1 deletion SuiteCRMAddIn/Dialogs/ArchiveDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,16 @@ private void frmArchive_Load(object sender, EventArgs e)
private void PopulateUIComponents()
{
this.txtSearch.Text = ConstructSearchText(Globals.ThisAddIn.SelectedEmails);
if (this.settings.EmailCategories != null)
if (this.settings.EmailCategories != null && this.settings.EmailCategories.IsImplemented)
{
this.categoryInput.DataSource = this.settings.EmailCategories;
}
else
{
this.categoryInput.Enabled = false;
this.categoryInput.Visible = false;
this.categoryLabel.Visible = false;
}

if (Globals.ThisAddIn.Settings.ShowCustomModules)
{
Expand Down
1 change: 1 addition & 0 deletions SuiteCRMAddIn/SuiteCRMAddIn.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
<DependentUpon>AddressBook.cs</DependentUpon>
</Compile>
<Compile Include="BusinessLogic\CRMPermissionsCache.cs" />
<Compile Include="BusinessLogic\EmailCategoriesCollection.cs" />
<Compile Include="Daemon\AbstractDaemonAction.cs" />
<Compile Include="BusinessLogic\AppointmentSyncState.cs" />
<Compile Include="BusinessLogic\AppointmentSyncing.cs" />
Expand Down
4 changes: 2 additions & 2 deletions SuiteCRMAddIn/clsSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,11 @@ public int RestTimeout
/// Categories for emails. These are actually provided by CRM and not edited by the user, but are cached here.
/// </summary>
[UserScopedSetting, DebuggerNonUserCode]
public List<string> EmailCategories
public EmailCategoriesCollection EmailCategories
{
get
{
return (List<string>)this["EmailCategories"];
return (EmailCategoriesCollection)this["EmailCategories"];
}
set
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SuiteCRMAddIn.BusinessLogic;
using SuiteCRMAddIn.Tests;
using SuiteCRMAddInTests.Properties;

[TestClass()]
public class LicenceValidationHelperTests : WithLoggerTests
{
[TestMethod()]
public void ValidateTest()
public void LicenceValidationHelperValidateTest()
{
Assert.IsTrue( new LicenceValidationHelper( this.Log,
"b8794235718652747b82fd713deac078", "e10a9aff077e983deca51e5d3688636c").Validate(),
Settings.Default.LicencePublicKey, Settings.Default.LicenceCustomerKey).Validate(),
"Key pair valid, should validate");
Assert.IsFalse(new LicenceValidationHelper(this.Log,
"b8794235718652747b82fd713deac078", "froboz").Validate(),
Settings.Default.LicencePublicKey, "invalid").Validate(),
"Customer licence key invalid, should not validate");
Assert.IsFalse(new LicenceValidationHelper(this.Log,
"froboz", "e10a9aff077e983deca51e5d3688636c").Validate(),
"invalid", Settings.Default.LicenceCustomerKey).Validate(),
"Public key invalid, should not validate");
}
}
Expand Down
6 changes: 3 additions & 3 deletions SuiteCRMAddInTests/BusinessLogic/SyncDirectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace SuiteCRMAddIn.BusinessLogic.Tests
public class SyncDirectionTests
{
[TestMethod()]
public void ToStringTest()
public void SyncDirectionToStringTest()
{
Assert.AreEqual("None", SyncDirection.ToString(SyncDirection.Direction.Neither));
Assert.AreEqual("From CRM to Outlook", SyncDirection.ToString(SyncDirection.Direction.Export));
Expand All @@ -37,7 +37,7 @@ public void ToStringTest()
}

[TestMethod()]
public void AllowOutboundTest()
public void SyncDirectionAllowOutboundTest()
{
Assert.IsTrue(SyncDirection.AllowOutbound(SyncDirection.Direction.BiDirectional), "Bidirectional includes both");
Assert.IsTrue(SyncDirection.AllowOutbound(SyncDirection.Direction.Import), "Explicitly outbound");
Expand All @@ -46,7 +46,7 @@ public void AllowOutboundTest()
}

[TestMethod()]
public void AllowInboundTest()
public void SyncDirectionAllowInboundTest()
{
Assert.IsTrue(SyncDirection.AllowInbound(SyncDirection.Direction.BiDirectional), "Bidirectional includes both");
Assert.IsTrue(SyncDirection.AllowInbound(SyncDirection.Direction.Export), "Explicitly inbound");
Expand Down
5 changes: 3 additions & 2 deletions SuiteCRMAddInTests/Daemon/FetchEmailCategoriesActionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/
namespace SuiteCRMAddIn.Daemon.Tests
{
using BusinessLogic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SuiteCRMAddIn.Daemon;
using SuiteCRMAddIn.Tests;
Expand All @@ -45,7 +46,7 @@ public class FetchEmailCategoriesActionTests : AbstractWithCrmConnectionTest
/// <summary>
/// The list of categories which performing my action should modify.
/// </summary>
private readonly List<string> categories = new List<string>();
private readonly EmailCategoriesCollection categories = new EmailCategoriesCollection();

/// <summary>
/// Specialisation: I need an action.
Expand All @@ -61,7 +62,7 @@ public override void Initialize()
/// After performing my action, there should be some categories.
/// </summary>
[TestMethod()]
public void PerformTest()
public void FetchEmailCategoriesActionPerformTest()
{
Assert.AreEqual(0, categories.Count);
this.action.Perform();
Expand Down
9 changes: 5 additions & 4 deletions SuiteCRMAddInTests/LDAPAuthenticationHelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
{
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SuiteCRMAddInTests;
using SuiteCRMAddInTests.Properties;
using SuiteCRMClient;
using System;

[TestClass()]
public class LDAPAuthenticationHelperTests : WithRestServiceTests
{
string validUser = "";
string validPass = "";
string validKey = "";
string validUser = Settings.Default.LDAPValidUser;
string validPass = Settings.Default.LDAPValidPass;
string validKey = Settings.Default.LDAPKey;

[TestMethod()]
public void LDAPAuthenticationHelperTest()
Expand All @@ -28,7 +29,7 @@ public void LDAPAuthenticationHelperTest()
}

[TestMethod()]
public void AuthenticateTest()
public void LDAPAuthenticationHelperAuthenticateTest()
{
Assert.IsFalse(
String.IsNullOrWhiteSpace(
Expand Down
48 changes: 48 additions & 0 deletions SuiteCRMAddInTests/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions SuiteCRMAddInTests/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,17 @@
<Setting Name="LogLevel" Type="SuiteCRMClient.Logging.LogEntryType" Scope="User">
<Value Profile="(Default)">Debug</Value>
</Setting>
<Setting Name="LDAPValidUser" Type="System.String" Scope="User">
<Value Profile="(Default)">TestUser</Value>
</Setting>
<Setting Name="LDAPValidPass" Type="System.String" Scope="User">
<Value Profile="(Default)">test</Value>
</Setting>
<Setting Name="LicencePublicKey" Type="System.String" Scope="User">
<Value Profile="(Default)">b8794235718652747b82fd713deac078</Value>
</Setting>
<Setting Name="LicenceCustomerKey" Type="System.String" Scope="User">
<Value Profile="(Default)">e10a9aff077e983deca51e5d3688636c</Value>
</Setting>
</Settings>
</SettingsFile>
3 changes: 2 additions & 1 deletion SuiteCRMAddInTests/WithRestServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/
namespace SuiteCRMAddInTests
{
using Properties;
using SuiteCRMAddIn.Tests;
using SuiteCRMClient;

Expand All @@ -37,7 +38,7 @@ public abstract class WithRestServiceTests : WithLoggerTests

public WithRestServiceTests()
{
this.service = new RestService("http://demo.suitecrm.com/suitecrm77/", this.Log);
this.service = new RestService(Settings.Default.host, this.Log);
}
}
}
12 changes: 12 additions & 0 deletions SuiteCRMAddInTests/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@
<setting name="LogLevel" serializeAs="String">
<value>Debug</value>
</setting>
<setting name="LDAPValidUser" serializeAs="String">
<value>TestUser</value>
</setting>
<setting name="LDAPValidPass" serializeAs="String">
<value>test</value>
</setting>
<setting name="LicencePublicKey" serializeAs="String">
<value>b8794235718652747b82fd713deac078</value>
</setting>
<setting name="LicenceCustomerKey" serializeAs="String">
<value>e10a9aff077e983deca51e5d3688636c</value>
</setting>
</SuiteCRMAddInTests.Properties.Settings>
</userSettings>
</configuration>

0 comments on commit 72541f5

Please sign in to comment.