public void Equals_OtherHasSameContributionCountAndHashButDifferentContent_ReturnsFalse() { using (ShimsContext.Create()) { FingerprintContribution fc1 = new FingerprintContribution("Name", _specialNameValue1); FingerprintContribution fc2 = new FingerprintContribution("Name", _specialNameValue2); Assert.AreEqual(fc1.GetHashCode(), fc2.GetHashCode()); A11yElement element1 = new ShimA11yElement { NameGet = () => _specialNameValue1 }; A11yElement element2 = new ShimA11yElement { NameGet = () => _specialNameValue2 }; IFingerprint fingerprint1 = new ScanResultFingerprint(element1, DefaultRule, DefaultScanStatus); IFingerprint fingerprint2 = new ScanResultFingerprint(element2, DefaultRule, DefaultScanStatus); Assert.AreEqual(fingerprint1.GetHashCode(), fingerprint2.GetHashCode()); // Ensure that these differ only in specific content Assert.AreEqual(0, fingerprint1.CompareTo(fingerprint2)); Assert.AreEqual(0, fingerprint2.CompareTo(fingerprint1)); Assert.IsFalse(fingerprint1.Equals(fingerprint2)); Assert.IsFalse(fingerprint2.Equals(fingerprint1)); } }
public void Equals_OtherIsDifferentImplementation_ReturnsFalse() { IFingerprint fingerprint = new ScanResultFingerprint(new A11yElement(), DefaultRule, DefaultScanStatus); IFingerprint other = new Mock <IFingerprint>().Object; Assert.IsFalse(fingerprint.Equals(other)); }
public void Equals_OtherIsDifferentImplementation_ReturnsFalse() { using (ShimsContext.Create()) { IFingerprint fingerprint = new ScanResultFingerprint(new A11yElement(), DefaultRule, DefaultScanStatus); StubIFingerprint other = new StubIFingerprint(); Assert.IsFalse(fingerprint.Equals(other)); } }
public void Equals_OtherHasSameNumberOfContributionsButDifferentHash_ReturnsFalse() { IA11yElement element1 = BuildTestElement(name: "a"); IA11yElement element2 = BuildTestElement(name: "A"); IFingerprint fingerprint1 = new ScanResultFingerprint(element1, DefaultRule, DefaultScanStatus); IFingerprint fingerprint2 = new ScanResultFingerprint(element2, DefaultRule, DefaultScanStatus); Assert.AreEqual(fingerprint1.Contributions.Count(), fingerprint2.Contributions.Count()); Assert.IsFalse(fingerprint1.Equals(fingerprint2)); Assert.IsFalse(fingerprint2.Equals(fingerprint1)); }
public void Equals_OtherIsEquivalent_ReturnsTrue() { const string automationId = "AutomationId"; const int controlTypeId = 50021; IA11yElement element1 = BuildTestElement(automationId: automationId, controlTypeId: controlTypeId); IA11yElement element2 = BuildTestElement(automationId: automationId, controlTypeId: controlTypeId); IFingerprint fingerprint1 = new ScanResultFingerprint(element1, DefaultRule, DefaultScanStatus); IFingerprint fingerprint2 = new ScanResultFingerprint(element2, DefaultRule, DefaultScanStatus); Assert.IsTrue(fingerprint1.Equals(fingerprint2)); Assert.IsTrue(fingerprint2.Equals(fingerprint1)); }
public void Equals_OtherHasDifferentNumberOfContributions_ReturnsFalse() { const string name = "MyTest"; IA11yElement moreContributionsElement = BuildTestElement(name: name, automationId: "myId"); IA11yElement fewerContributionsElement = BuildTestElement(name: name); IFingerprint fingerprint1 = new ScanResultFingerprint(moreContributionsElement, DefaultRule, DefaultScanStatus); IFingerprint fingerprint2 = new ScanResultFingerprint(fewerContributionsElement, DefaultRule, DefaultScanStatus); Assert.AreNotEqual(fingerprint1.Contributions.Count(), fingerprint2.Contributions.Count()); Assert.IsFalse(fingerprint1.Equals(fingerprint2)); Assert.IsFalse(fingerprint2.Equals(fingerprint1)); }
public void Equals_OtherHasSameNumberOfContributionsButDifferentHash_ReturnsFalse() { using (ShimsContext.Create()) { A11yElement element1 = new ShimA11yElement { NameGet = () => "a" }; A11yElement element2 = new ShimA11yElement { NameGet = () => "A" }; IFingerprint fingerprint1 = new ScanResultFingerprint(element1, DefaultRule, DefaultScanStatus); IFingerprint fingerprint2 = new ScanResultFingerprint(element2, DefaultRule, DefaultScanStatus); Assert.AreEqual(fingerprint1.Contributions.Count(), fingerprint2.Contributions.Count()); Assert.IsFalse(fingerprint1.Equals(fingerprint2)); Assert.IsFalse(fingerprint2.Equals(fingerprint1)); } }
public void Equals_OtherIsEquivalent_ReturnsTrue() { using (ShimsContext.Create()) { ShimA11yElement element1 = new ShimA11yElement { AutomationIdGet = () => "AutomationId", ControlTypeIdGet = () => 50021, }; ShimA11yElement element2 = new ShimA11yElement { AutomationIdGet = () => "AutomationId", ControlTypeIdGet = () => 50021, }; IFingerprint fingerprint1 = new ScanResultFingerprint(element1, DefaultRule, DefaultScanStatus); IFingerprint fingerprint2 = new ScanResultFingerprint(element2, DefaultRule, DefaultScanStatus); Assert.IsTrue(fingerprint1.Equals(fingerprint2)); Assert.IsTrue(fingerprint2.Equals(fingerprint1)); } }
public void Equals_OtherHasDifferentNumberOfContributions_ReturnsFalse() { using (ShimsContext.Create()) { ShimA11yElement moreContributionsElement = new ShimA11yElement { NameGet = () => "MyTest", AutomationIdGet = () => "AutomationId", }; ShimA11yElement fewerContributionsElement = new ShimA11yElement { NameGet = () => "MyTest", }; IFingerprint fingerprint1 = new ScanResultFingerprint(moreContributionsElement, DefaultRule, DefaultScanStatus); IFingerprint fingerprint2 = new ScanResultFingerprint(fewerContributionsElement, DefaultRule, DefaultScanStatus); Assert.AreNotEqual(fingerprint1.Contributions.Count(), fingerprint2.Contributions.Count()); Assert.IsFalse(fingerprint1.Equals(fingerprint2)); Assert.IsFalse(fingerprint2.Equals(fingerprint1)); } }
public void Equals_OtherIsNull_ReturnsFalse() { IFingerprint fingerprint = new ScanResultFingerprint(new A11yElement(), DefaultRule, DefaultScanStatus); Assert.IsFalse(fingerprint.Equals(null)); }