-
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
12 changed files
with
325 additions
and
39 deletions.
There are no files selected for viewing
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,36 @@ | ||
using System; | ||
|
||
using GSendShared; | ||
using GSendShared.Abstractions; | ||
|
||
namespace GSendTests.Mocks | ||
{ | ||
internal class MockGSendContext : IGSendContext | ||
{ | ||
public MockGSendContext() | ||
{ | ||
} | ||
|
||
public MockGSendContext(IServiceProvider serviceProvider) | ||
: this() | ||
{ | ||
ServiceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); | ||
} | ||
|
||
public IServiceProvider ServiceProvider { get; set; } | ||
|
||
public bool IsClosing => throw new NotImplementedException(); | ||
|
||
public IGSendSettings Settings => throw new NotImplementedException(); | ||
|
||
public void CloseContext() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void ShowMachine(IMachine machine) | ||
{ | ||
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
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
75 changes: 75 additions & 0 deletions
75
src/GCATests/Plugins/HelpMenuTests/BugsAndIdeasMenuTests.cs
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,75 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
using GSendControls.Plugins.InternalPlugins.HelpMenu; | ||
|
||
using GSendShared.Plugins; | ||
|
||
using GSendTests.Mocks; | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace GSendTests.Plugins.HelpMenuTests | ||
{ | ||
[TestClass] | ||
[ExcludeFromCodeCoverage] | ||
public sealed class BugsAndIdeasMenuTests | ||
{ | ||
[TestMethod] | ||
public void Construct_BugsAndIdeasMenuItem_Success() | ||
{ | ||
MockPluginMenu parentMenu = new MockPluginMenu("test", MenuType.MenuItem, null); | ||
BugsAndIdeasMenu sut = new(parentMenu, new MockRunProgram()); | ||
Assert.IsNotNull(sut); | ||
Assert.IsNull(sut.MenuImage); | ||
Assert.AreEqual(MenuType.MenuItem, sut.MenuType); | ||
Assert.IsNotNull(sut.ParentMenu); | ||
Assert.AreSame(parentMenu, sut.ParentMenu); | ||
Assert.AreEqual("Bugs and Ideas", sut.Text); | ||
Assert.AreEqual(2, 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 BugsAndIdeasMenu(null, new MockRunProgram()); | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(ArgumentNullException))] | ||
public void Construct_InvalidParam_RunProgramNull_Throws_ArgumentNullException() | ||
{ | ||
new BugsAndIdeasMenu(new MockPluginMenu("test", MenuType.MenuItem, null), null); | ||
} | ||
|
||
[TestMethod] | ||
public void UpdateHost_DoesNotCrash_Success() | ||
{ | ||
HelpMenuItem sut = new(new MockPluginMenu("test", MenuType.MenuItem, null), new MockRunProgram()); | ||
Assert.IsNotNull(sut); | ||
sut.UpdateHost<BugsAndIdeasMenu>(null); | ||
} | ||
|
||
[TestMethod] | ||
public void Clicked_RunsHomePageUsingShellExecute_Success() | ||
{ | ||
MockRunProgram mockRunProgram = new(); | ||
MockPluginMenu parentMenu = new MockPluginMenu("test", MenuType.MenuItem, null); | ||
BugsAndIdeasMenu sut = new(parentMenu, mockRunProgram); | ||
sut.Clicked(); | ||
Assert.AreEqual("https://github.com/k3ldar/GSendPro/issues", mockRunProgram.ProgramName); | ||
Assert.IsNull(mockRunProgram.Parameters); | ||
Assert.IsTrue(mockRunProgram.UseShellExecute); | ||
Assert.IsFalse(mockRunProgram.WaitForFinish); | ||
Assert.AreEqual(500, mockRunProgram.TimeoutMilliseconds); | ||
} | ||
} | ||
} |
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,79 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using GSendControls.Plugins.InternalPlugins.HelpMenu; | ||
|
||
using GSendShared.Plugins; | ||
|
||
using GSendTests.Mocks; | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace GSendTests.Plugins.HelpMenuTests | ||
{ | ||
[TestClass] | ||
[ExcludeFromCodeCoverage] | ||
public sealed class HelpMenuItemTests | ||
{ | ||
[TestMethod] | ||
public void Construct_HelpMenuItem_Success() | ||
{ | ||
MockPluginMenu parentMenu = new MockPluginMenu("test", MenuType.MenuItem, null); | ||
HelpMenuItem sut = new(parentMenu, new MockRunProgram()); | ||
Assert.IsNotNull(sut); | ||
Assert.IsNull(sut.MenuImage); | ||
Assert.AreEqual(MenuType.MenuItem, sut.MenuType); | ||
Assert.IsNotNull(sut.ParentMenu); | ||
Assert.AreSame(parentMenu, sut.ParentMenu); | ||
Assert.AreEqual("Help", sut.Text); | ||
Assert.AreEqual(0, 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 HelpMenuItem(null, new MockRunProgram()); | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(ArgumentNullException))] | ||
public void Construct_InvalidParam_RunProgramNull_Throws_ArgumentNullException() | ||
{ | ||
new HelpMenuItem(new MockPluginMenu("test", MenuType.MenuItem, null), null); | ||
} | ||
|
||
[TestMethod] | ||
public void UpdateHost_DoesNotCrash_Success() | ||
{ | ||
HelpMenuItem sut = new(new MockPluginMenu("test", MenuType.MenuItem, null), new MockRunProgram()); | ||
Assert.IsNotNull(sut); | ||
sut.UpdateHost<HelpMenuItem>(null); | ||
} | ||
|
||
[TestMethod] | ||
public void Clicked_RunsHomePageUsingShellExecute_Success() | ||
{ | ||
MockRunProgram mockRunProgram = new(); | ||
MockPluginMenu parentMenu = new MockPluginMenu("test", MenuType.MenuItem, null); | ||
HelpMenuItem sut = new(parentMenu, mockRunProgram); | ||
sut.Clicked(); | ||
Assert.AreEqual("https://www.gsend.pro/help", mockRunProgram.ProgramName); | ||
Assert.IsNull(mockRunProgram.Parameters); | ||
Assert.IsTrue(mockRunProgram.UseShellExecute); | ||
Assert.IsFalse(mockRunProgram.WaitForFinish); | ||
Assert.AreEqual(500, mockRunProgram.TimeoutMilliseconds); | ||
} | ||
} | ||
} |
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,76 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
using GSendControls.Plugins.InternalPlugins.HelpMenu; | ||
using GSendControls.Plugins.InternalPlugins.SearchMenu; | ||
|
||
using GSendShared.Plugins; | ||
|
||
using GSendTests.Mocks; | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace GSendTests.Plugins.HelpMenuTests | ||
{ | ||
[TestClass] | ||
[ExcludeFromCodeCoverage] | ||
public sealed class HomePageMenuTests | ||
{ | ||
[TestMethod] | ||
public void Construct_HomePageMenuItem_Success() | ||
{ | ||
MockPluginMenu parentMenu = new MockPluginMenu("test", MenuType.MenuItem, null); | ||
HomePageMenu sut = new(parentMenu, new MockRunProgram()); | ||
Assert.IsNotNull(sut); | ||
Assert.IsNull(sut.MenuImage); | ||
Assert.AreEqual(MenuType.MenuItem, sut.MenuType); | ||
Assert.IsNotNull(sut.ParentMenu); | ||
Assert.AreSame(parentMenu, sut.ParentMenu); | ||
Assert.AreEqual("Home Page", sut.Text); | ||
Assert.AreEqual(4, 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 HomePageMenu(null, new MockRunProgram()); | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(ArgumentNullException))] | ||
public void Construct_InvalidParam_RunProgramNull_Throws_ArgumentNullException() | ||
{ | ||
new HomePageMenu(new MockPluginMenu("test", MenuType.MenuItem, null), null); | ||
} | ||
|
||
[TestMethod] | ||
public void UpdateHost_DoesNotCrash_Success() | ||
{ | ||
HomePageMenu sut = new(new MockPluginMenu("test", MenuType.MenuItem, null), new MockRunProgram()); | ||
Assert.IsNotNull(sut); | ||
sut.UpdateHost<FindMenuItem>(null); | ||
} | ||
|
||
[TestMethod] | ||
public void Clicked_RunsHomePageUsingShellExecute_Success() | ||
{ | ||
MockRunProgram mockRunProgram = new(); | ||
MockPluginMenu parentMenu = new MockPluginMenu("test", MenuType.MenuItem, null); | ||
HomePageMenu sut = new(parentMenu, mockRunProgram); | ||
sut.Clicked(); | ||
Assert.AreEqual("https://www.gsend.pro/", mockRunProgram.ProgramName); | ||
Assert.IsNull(mockRunProgram.Parameters); | ||
Assert.IsTrue(mockRunProgram.UseShellExecute); | ||
Assert.IsFalse(mockRunProgram.WaitForFinish); | ||
Assert.AreEqual(500, mockRunProgram.TimeoutMilliseconds); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.