Skip to content
Snippets Groups Projects
Commit 9eb55f73 authored by Frederik Carlier's avatar Frederik Carlier
Browse files

Command: Don't compare the Handlers property when checking whether two...

Command: Don't compare the Handlers property when checking whether two commands are equal - this property is currentl ignored.
parent 7f9889ae
No related branches found
No related tags found
No related merge requests found
......@@ -11,31 +11,25 @@ namespace MasterDevs.ChromeDevTools.ProtocolGenerator.Tests
public class CommandTests
{
[TestMethod]
[DeploymentItem(DeploymentItems.Inspector10)]
[DeploymentItem(DeploymentItems.Inspector11)]
[DeploymentItem(DeploymentItems.Protocol)]
public void EqualsTest()
{
var inspector10 = ProtocolProcessor.LoadProtocol(DeploymentItems.Inspector10, "inspector-1.0");
var inspector11 = ProtocolProcessor.LoadProtocol(DeploymentItems.Inspector11, "inspector-1.1");
var protocol = ProtocolProcessor.LoadProtocol(DeploymentItems.Protocol, "protocol");
ProtocolProcessor.ResolveTypeReferences(inspector10);
ProtocolProcessor.ResolveTypeReferences(inspector11);
ProtocolProcessor.ResolveTypeReferences(protocol);
var searchInResource10 = inspector10.GetDomain("Page").GetCommand("searchInResource");
var searchInResourceTip = protocol.GetDomain("Page").GetCommand("searchInResource");
var stopScreencast10 = inspector11.GetDomain("Page").GetCommand("stopScreencast");
var stopScreencastTip = protocol.GetDomain("Page").GetCommand("stopScreencast");
// Quick fact check: both methods have the same string equivalent,
// ([] result) searchInResource(string frameId, string url, string query, boolean caseSensitive, boolean isRegex)
Assert.AreEqual<string>(searchInResource10.ToString(), searchInResourceTip.ToString());
// void stopScreencast()
Assert.AreEqual<string>(stopScreencast10.ToString(), stopScreencastTip.ToString());
// The result is a type, check whether the type has the same properties
var result10 = searchInResource10.Returns.Single();
var resultTip = searchInResourceTip.Returns.Single();
Assert.IsTrue(result10.Equals(resultTip));
Assert.IsTrue(searchInResource10.Equals(searchInResourceTip));
Assert.IsTrue(searchInResourceTip.Equals(searchInResource10));
Assert.IsTrue(stopScreencast10.Equals(stopScreencastTip));
Assert.IsTrue(stopScreencastTip.Equals(stopScreencast10));
}
}
}
......@@ -9,6 +9,7 @@ namespace MasterDevs.ChromeDevTools.ProtocolGenerator.Tests
class DeploymentItems
{
public const string Inspector10 = "Inspector-1.0.json";
public const string Inspector11 = "Inspector-1.1.json";
public const string Protocol = "protocol.json";
}
}
......@@ -54,6 +54,7 @@
<Compile Include="DeploymentItems.cs" />
<Compile Include="ProtocolProcessorTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TypeTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ProtocolGenerator\MasterDevs.ChromeDevTools.ProtocolGenerator.csproj">
......
......@@ -27,6 +27,9 @@ namespace MasterDevs.ChromeDevTools.ProtocolGenerator
set;
}
/// <remarks>
/// This property is currently ignored.
/// </remarks>
public Collection<string> Handlers
{
get;
......@@ -63,7 +66,6 @@ namespace MasterDevs.ChromeDevTools.ProtocolGenerator
bool equals = base.Equals(obj);
equals &= this.Returns.SequenceEqual(other.Returns);
equals &= Property.Equals(this.Error, other.Error);
equals &= this.Handlers.CollectionEqual(other.Handlers);
equals &= this.Parameters.SequenceEqual(other.Parameters);
return equals;
}
......@@ -79,8 +81,7 @@ namespace MasterDevs.ChromeDevTools.ProtocolGenerator
{
hash = hash * 23 + this.Error.GetHashCode();
}
hash = hash * 23 + this.Handlers.GetCollectionHashCode();
hash = hash * 23 + this.Parameters.GetCollectionHashCode();
return hash;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment