Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate keepass plugin conventions (#113)
- Loading branch information
1 parent
5a1f88d
commit a9fc816
Showing
1 changed file
with
73 additions
and
0 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,73 @@ | ||
using FluentAssertions; | ||
using KeePass.Plugins; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System.Reflection; | ||
|
||
namespace KeeTrayTOTP.Tests | ||
{ | ||
/// <summary> | ||
/// Validate Keepass Plugin Conventions | ||
/// https://keepass.info/help/v2_dev/plg_index.html | ||
/// </summary> | ||
[TestClass] | ||
public class KeepassPluginConventionsTests | ||
{ | ||
/// <summary> | ||
/// Product name: Must be set to "KeePass Plugin" (without the quotes). | ||
/// </summary> | ||
[TestMethod] | ||
public void AssemblyProduct_ShouldBeEqualToKeePassPlugin() | ||
{ | ||
// Arrange | ||
var pluginAssembly = typeof(KeeTrayTOTPExt).Assembly; | ||
|
||
// Act | ||
var assemblyProduct = pluginAssembly.GetCustomAttribute<AssemblyProductAttribute>(); | ||
|
||
// Assert | ||
assemblyProduct.Should().NotBeNull(); | ||
assemblyProduct.Product.Should().Be("KeePass Plugin"); | ||
} | ||
|
||
/// <summary> | ||
/// The namespace must be named like the DLL file without extension. | ||
/// </summary> | ||
[TestMethod] | ||
public void AssemblyNamespace_ShouldBeEqualToAssemblyName() | ||
{ | ||
// Arrange | ||
var pluginType = typeof(KeeTrayTOTPExt); | ||
var pluginAssembly = typeof(KeeTrayTOTPExt).Assembly; | ||
|
||
// Assert | ||
pluginType.Namespace.Should().Be(pluginAssembly.GetName().Name); | ||
} | ||
|
||
/// <summary> | ||
/// The plugin class must be named like the namespace plus "Ext". | ||
/// </summary> | ||
[TestMethod] | ||
public void PluginClass_ShouldBeEqualToNamespacePlusExt() | ||
{ | ||
// Arrange | ||
var pluginType = typeof(KeeTrayTOTPExt); | ||
|
||
// Assert | ||
pluginType.Name.Should().Be($"{pluginType.Namespace}Ext"); | ||
} | ||
|
||
|
||
/// <summary> | ||
/// The plugin class must derive from the Plugin class | ||
/// </summary> | ||
[TestMethod] | ||
public void PluginClass_ShouldDeriveFromIPlugin() | ||
{ | ||
// Arrange | ||
var pluginType = typeof(KeeTrayTOTPExt); | ||
|
||
// Assert | ||
pluginType.Should().BeDerivedFrom<Plugin>(); | ||
} | ||
} | ||
} |