-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
1,125 additions
and
71 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using GSendControls.Abstractions; | ||
|
||
using GSendShared; | ||
using GSendShared.Plugins; | ||
|
||
namespace GSendTests.Mocks | ||
{ | ||
internal class MockEditorPluginHost : IEditorPluginHost | ||
{ | ||
public MockEditorPluginHost() | ||
{ | ||
Editor = new MockITextEditor(); | ||
} | ||
|
||
public bool IsDirty => throw new NotImplementedException(); | ||
|
||
public bool IsSubprogram => throw new NotImplementedException(); | ||
|
||
public string FileName => throw new NotImplementedException(); | ||
|
||
public ITextEditor Editor { get; set; } | ||
|
||
public PluginHosts Host => throw new NotImplementedException(); | ||
|
||
public int MaximumMenuIndex => throw new NotImplementedException(); | ||
|
||
public IGSendContext GSendContext => throw new NotImplementedException(); | ||
|
||
public void AddMenu(IPluginMenu pluginMenu) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void AddMessage(InformationType informationType, string message) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void AddPlugin(IGSendPluginModule pluginModule) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void AddToolbar(IPluginToolbarButton toolbarButton) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public IPluginMenu GetMenu(MenuParent menuParent) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Drawing; | ||
using System.Security.Policy; | ||
using System.Windows.Forms; | ||
|
||
using GSendControls.Abstractions; | ||
|
||
namespace GSendTests.Mocks | ||
{ | ||
internal class MockITextEditor : ITextEditor | ||
{ | ||
public string Text { get; set; } = String.Empty; | ||
|
||
public int LineCount { get; set; } = 23; | ||
|
||
public bool ShowGotoDialogCalled { get; private set; } | ||
|
||
public bool ShowFindDialogCalled { get; private set; } | ||
|
||
public bool ShowReplaceDialogCalled { get; private set; } | ||
|
||
public IWin32Window Parent => throw new NotImplementedException(); | ||
|
||
public Rectangle ParentRectangle => throw new NotImplementedException(); | ||
|
||
public int SelectionStart => throw new NotImplementedException(); | ||
|
||
public int SelectionLength => throw new NotImplementedException(); | ||
|
||
public Rectangle Position => throw new NotImplementedException(); | ||
|
||
public Control ParentControl => throw new NotImplementedException(); | ||
|
||
public Point ParentDesktopLocation => throw new NotImplementedException(); | ||
|
||
public void ShowFindDialog() | ||
{ | ||
ShowFindDialogCalled = true; | ||
} | ||
|
||
public void ShowGoToDialog() | ||
{ | ||
ShowGotoDialogCalled = true; | ||
} | ||
|
||
public void ShowReplaceDialog() | ||
{ | ||
ShowReplaceDialogCalled = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
using GSendControls.Abstractions; | ||
using GSendControls.Plugins.InternalPlugins.SearchMenu; | ||
|
||
using GSendShared.Plugins; | ||
|
||
using GSendTests.Mocks; | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
using Moq; | ||
|
||
namespace GSendTests.Plugins.SearchMenu | ||
{ | ||
[TestClass] | ||
[ExcludeFromCodeCoverage] | ||
public class FindMenuItemTests | ||
{ | ||
[TestMethod] | ||
public void Construct_FindMenuItem_Success() | ||
{ | ||
MockPluginMenu parentMenu = new MockPluginMenu("test", MenuType.MenuItem, null); | ||
FindMenuItem sut = new(parentMenu, new MockITextEditor()); | ||
Assert.IsNotNull(sut); | ||
Assert.IsNull(sut.MenuImage); | ||
Assert.AreEqual(MenuType.MenuItem, sut.MenuType); | ||
Assert.IsNotNull(sut.ParentMenu); | ||
Assert.AreSame(parentMenu, sut.ParentMenu); | ||
Assert.AreEqual("Find", sut.Text); | ||
Assert.AreEqual(0, sut.Index); | ||
Assert.IsFalse(sut.ReceiveClientMessages); | ||
Assert.IsTrue(sut.GetShortcut([], out string grpName, out string shrtCutName)); | ||
Assert.AreEqual("Search Menu", grpName); | ||
Assert.AreEqual("Find", shrtCutName); | ||
Assert.IsFalse(sut.IsChecked()); | ||
Assert.IsFalse(sut.IsEnabled()); | ||
Assert.IsTrue(sut.IsVisible()); | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(ArgumentNullException))] | ||
public void Construct_InvalidParam_ParentNull_Throws_ArgumentNullException() | ||
{ | ||
new FindMenuItem(null, new Mock<ITextEditor>().Object); | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(ArgumentNullException))] | ||
public void Construct_InvalidParam_TextEditorNull_Throws_ArgumentNullException() | ||
{ | ||
new FindMenuItem(new MockPluginMenu("test", MenuType.MenuItem, null), null); | ||
} | ||
|
||
[TestMethod] | ||
public void UpdateHost_DoesNotCrash_Success() | ||
{ | ||
FindMenuItem sut = new(new MockPluginMenu("test", MenuType.MenuItem, null), new MockITextEditor()); | ||
Assert.IsNotNull(sut); | ||
sut.UpdateHost<FindMenuItem>(null); | ||
} | ||
|
||
[TestMethod] | ||
public void IsEnabled_HasText_ReturnsTrue() | ||
{ | ||
MockITextEditor mockITextEditor = new(); | ||
mockITextEditor.Text = "Some Text"; | ||
MockPluginMenu parentMenu = new MockPluginMenu("test", MenuType.MenuItem, null); | ||
FindMenuItem sut = new(parentMenu, mockITextEditor); | ||
Assert.IsTrue(sut.IsEnabled()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
using GSendControls.Abstractions; | ||
using GSendControls.Plugins.InternalPlugins.SearchMenu; | ||
|
||
using GSendShared.Plugins; | ||
|
||
using GSendTests.Mocks; | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
using Moq; | ||
|
||
namespace GSendTests.Plugins.SearchMenu | ||
{ | ||
[TestClass] | ||
[ExcludeFromCodeCoverage] | ||
public class GotoMenuItemTests | ||
{ | ||
[TestMethod] | ||
public void Construct_GotoMenuItem_Success() | ||
{ | ||
MockPluginMenu parentMenu = new MockPluginMenu("test", MenuType.MenuItem, null); | ||
GotoMenuItem sut = new(parentMenu, new MockITextEditor()); | ||
Assert.IsNotNull(sut); | ||
Assert.IsNull(sut.MenuImage); | ||
Assert.AreEqual(MenuType.MenuItem, sut.MenuType); | ||
Assert.IsNotNull(sut.ParentMenu); | ||
Assert.AreSame(parentMenu, sut.ParentMenu); | ||
Assert.AreEqual("Goto", sut.Text); | ||
Assert.AreEqual(20, sut.Index); | ||
Assert.IsFalse(sut.ReceiveClientMessages); | ||
Assert.IsFalse(sut.GetShortcut([], out string grpName, out string shrtCutName)); | ||
Assert.IsNull(grpName); | ||
Assert.IsNull(shrtCutName); | ||
Assert.IsFalse(sut.IsChecked()); | ||
Assert.IsTrue(sut.IsEnabled()); | ||
Assert.IsTrue(sut.IsVisible()); | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(ArgumentNullException))] | ||
public void Construct_InvalidParam_ParentNull_Throws_ArgumentNullException() | ||
{ | ||
new GotoMenuItem(null, new Mock<ITextEditor>().Object); | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(ArgumentNullException))] | ||
public void Construct_InvalidParam_TextEditorNull_Throws_ArgumentNullException() | ||
{ | ||
new GotoMenuItem(new MockPluginMenu("test", MenuType.MenuItem, null), null); | ||
} | ||
|
||
[TestMethod] | ||
public void UpdateHost_DoesNotCrash_Success() | ||
{ | ||
GotoMenuItem sut = new(new MockPluginMenu("test", MenuType.MenuItem, null), new MockITextEditor()); | ||
Assert.IsNotNull(sut); | ||
sut.UpdateHost<GotoMenuItem>(null); | ||
} | ||
|
||
[TestMethod] | ||
public void IsEnabled_HasText_ReturnsTrue() | ||
{ | ||
MockITextEditor mockITextEditor = new(); | ||
mockITextEditor.Text = "Some Text"; | ||
MockPluginMenu parentMenu = new MockPluginMenu("test", MenuType.MenuItem, null); | ||
GotoMenuItem sut = new(parentMenu, mockITextEditor); | ||
Assert.IsTrue(sut.IsEnabled()); | ||
} | ||
|
||
[TestMethod] | ||
public void IsEnabled_HasNoText_ReturnsFalse() | ||
{ | ||
MockITextEditor mockITextEditor = new(); | ||
mockITextEditor.Text = "Some Text"; | ||
mockITextEditor.LineCount = 0; | ||
MockPluginMenu parentMenu = new MockPluginMenu("test", MenuType.MenuItem, null); | ||
GotoMenuItem sut = new(parentMenu, mockITextEditor); | ||
Assert.IsFalse(sut.IsEnabled()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
using GSendControls.Abstractions; | ||
using GSendControls.Plugins.InternalPlugins.SearchMenu; | ||
|
||
using GSendShared.Plugins; | ||
|
||
using GSendTests.Mocks; | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
using Moq; | ||
|
||
namespace GSendTests.Plugins.SearchMenu | ||
{ | ||
[TestClass] | ||
[ExcludeFromCodeCoverage] | ||
public class ReplaceMenuItemTests | ||
{ | ||
[TestMethod] | ||
public void Construct_ReplaceMenuItem_Success() | ||
{ | ||
MockPluginMenu parentMenu = new MockPluginMenu("test", MenuType.MenuItem, null); | ||
ReplaceMenuItem sut = new(parentMenu, new MockITextEditor()); | ||
Assert.IsNotNull(sut); | ||
Assert.IsNull(sut.MenuImage); | ||
Assert.AreEqual(MenuType.MenuItem, sut.MenuType); | ||
Assert.IsNotNull(sut.ParentMenu); | ||
Assert.AreSame(parentMenu, sut.ParentMenu); | ||
Assert.AreEqual("Replace", sut.Text); | ||
Assert.AreEqual(1, sut.Index); | ||
Assert.IsFalse(sut.ReceiveClientMessages); | ||
Assert.IsTrue(sut.GetShortcut([], out string grpName, out string shrtCutName)); | ||
Assert.AreEqual("Search Menu", grpName); | ||
Assert.AreEqual("Replace", shrtCutName); | ||
Assert.IsFalse(sut.IsChecked()); | ||
Assert.IsFalse(sut.IsEnabled()); | ||
Assert.IsTrue(sut.IsVisible()); | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(ArgumentNullException))] | ||
public void Construct_InvalidParam_ParentNull_Throws_ArgumentNullException() | ||
{ | ||
new ReplaceMenuItem(null, new Mock<ITextEditor>().Object); | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(ArgumentNullException))] | ||
public void Construct_InvalidParam_TextEditorNull_Throws_ArgumentNullException() | ||
{ | ||
new ReplaceMenuItem(new MockPluginMenu("test", MenuType.MenuItem, null), null); | ||
} | ||
|
||
[TestMethod] | ||
public void UpdateHost_DoesNotCrash_Success() | ||
{ | ||
ReplaceMenuItem sut = new(new MockPluginMenu("test", MenuType.MenuItem, null), new MockITextEditor()); | ||
Assert.IsNotNull(sut); | ||
sut.UpdateHost<ReplaceMenuItem>(null); | ||
} | ||
|
||
[TestMethod] | ||
public void IsEnabled_HasText_ReturnsTrue() | ||
{ | ||
MockITextEditor mockITextEditor = new(); | ||
mockITextEditor.Text = "Some Text"; | ||
MockPluginMenu parentMenu = new MockPluginMenu("test", MenuType.MenuItem, null); | ||
ReplaceMenuItem sut = new(parentMenu, mockITextEditor); | ||
Assert.IsTrue(sut.IsEnabled()); | ||
} | ||
} | ||
} |
Oops, something went wrong.