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));
            }
        }
Esempio n. 2
0
        public void CompareTo_OtherIsDifferentImplemention_ThrowsInvalidOperationException()
        {
            IFingerprint fingerprint = new ScanResultFingerprint(BuildTestElement(), DefaultRule, DefaultScanStatus);

            IFingerprint other = new Mock <IFingerprint>().Object;

            fingerprint.CompareTo(other);
        }
Esempio n. 3
0
        public void CompareTo_OneElementHasMoreContributions_SortByContributionCount()
        {
            IA11yElement moreContributionsElement  = BuildTestElement(name: "ElementWith2Contributions", automationId: "blah");
            IA11yElement fewerContributionsElement = BuildTestElement(name: "ElementWith1Contribution");

            IFingerprint higherFingerprint = new ScanResultFingerprint(moreContributionsElement, DefaultRule, DefaultScanStatus);
            IFingerprint lowerFingerprint  = new ScanResultFingerprint(fewerContributionsElement, DefaultRule, DefaultScanStatus);

            Assert.AreEqual(-1, lowerFingerprint.CompareTo(higherFingerprint));
            Assert.AreEqual(1, higherFingerprint.CompareTo(lowerFingerprint));
        }
        public void CompareTo_OtherIsDifferentImplemention_ThrowsInvalidOperationException()
        {
            using (ShimsContext.Create())
            {
                IFingerprint fingerprint = new ScanResultFingerprint(new A11yElement(), DefaultRule, DefaultScanStatus);

                StubIFingerprint other = new StubIFingerprint();

                fingerprint.CompareTo(other);
            }
        }
Esempio n. 5
0
        public void CompareTo_OtherIsNull_ThrowsArgumentNullException()
        {
            IFingerprint fingerprint = new ScanResultFingerprint(new A11yElement(), DefaultRule, DefaultScanStatus);

            try
            {
                fingerprint.CompareTo(null);
            }
            catch (ArgumentNullException e)
            {
                Assert.AreEqual("other", e.ParamName);
                throw;
            }
        }
        public void CompareTo_OneElementHasMoreContributions_SortByContributionCount()
        {
            using (ShimsContext.Create())
            {
                ShimA11yElement moreContributionsElement = new ShimA11yElement
                {
                    NameGet         = () => "ElementWithTwoContributions",
                    AutomationIdGet = () => "AutomationId",
                };
                ShimA11yElement fewerContributionsElement = new ShimA11yElement
                {
                    NameGet = () => "ElemetWithOneContribution",
                };

                IFingerprint higherFingerprint = new ScanResultFingerprint(moreContributionsElement, DefaultRule, DefaultScanStatus);
                IFingerprint lowerFingerprint  = new ScanResultFingerprint(fewerContributionsElement, DefaultRule, DefaultScanStatus);

                Assert.AreEqual(-1, lowerFingerprint.CompareTo(higherFingerprint));
                Assert.AreEqual(1, higherFingerprint.CompareTo(lowerFingerprint));
            }
        }