From 9eb55f732e52092fb84dce0a20a2d184b04143df Mon Sep 17 00:00:00 2001 From: Frederik Carlier <frederik.carlier@quamotion.mobi> Date: Sun, 15 May 2016 21:33:07 +0200 Subject: [PATCH] Command: Don't compare the Handlers property when checking whether two commands are equal - this property is currentl ignored. --- .../ProtocolGenerator.Tests/CommandTests.cs | 24 +++++++------------ .../DeploymentItems.cs | 1 + ...omeDevTools.ProtocolGenerator.Tests.csproj | 1 + source/ProtocolGenerator/Command.cs | 7 +++--- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/source/ProtocolGenerator.Tests/CommandTests.cs b/source/ProtocolGenerator.Tests/CommandTests.cs index 0397cee..c3c2fd6 100644 --- a/source/ProtocolGenerator.Tests/CommandTests.cs +++ b/source/ProtocolGenerator.Tests/CommandTests.cs @@ -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)); } } } diff --git a/source/ProtocolGenerator.Tests/DeploymentItems.cs b/source/ProtocolGenerator.Tests/DeploymentItems.cs index cbd0d89..7b97f4c 100644 --- a/source/ProtocolGenerator.Tests/DeploymentItems.cs +++ b/source/ProtocolGenerator.Tests/DeploymentItems.cs @@ -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"; } } diff --git a/source/ProtocolGenerator.Tests/MasterDevs.ChromeDevTools.ProtocolGenerator.Tests.csproj b/source/ProtocolGenerator.Tests/MasterDevs.ChromeDevTools.ProtocolGenerator.Tests.csproj index 8bd5913..338b3d7 100644 --- a/source/ProtocolGenerator.Tests/MasterDevs.ChromeDevTools.ProtocolGenerator.Tests.csproj +++ b/source/ProtocolGenerator.Tests/MasterDevs.ChromeDevTools.ProtocolGenerator.Tests.csproj @@ -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"> diff --git a/source/ProtocolGenerator/Command.cs b/source/ProtocolGenerator/Command.cs index abeabf6..1bc90d0 100644 --- a/source/ProtocolGenerator/Command.cs +++ b/source/ProtocolGenerator/Command.cs @@ -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; } -- GitLab