public void HashCodesShouldBeEqual()
        {
            IMenuBean beanOne = new MenuBean();
            IMenuBean beanTwo = new MenuBean();

            Mock<IWebElement> mockElement = new Mock<IWebElement>();

            beanOne.ContentContainer = mockElement.Object;
            beanTwo.ContentContainer = mockElement.Object;

            Assert.AreEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "The hash codes for two beans should be " +
                "equal if they have the same container element reference and same default JavaScript click " +
                "workaround value");

            beanOne.ClickOptionWithJavascript = true;
            beanTwo.ClickOptionWithJavascript = true;

            Assert.AreEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "The hash codes for two beans should be " +
                "equal if they have the same container element reference and same non-default JavaScript click " +
                "workaround value");

            beanOne = new MenuBean();
            beanTwo = new MenuBean();

            beanOne.ClickOptionWithJavascript = true;
            beanTwo.ClickOptionWithJavascript = true;

            Assert.AreEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "The hash codes for two beans should be " +
                "equal if they have null container element references and same non-default JavaScript click " +
                "workaround value");

            beanOne.ContentContainer = mockElement.Object;
            beanTwo.ContentContainer = mockElement.Object;

            List<IWebElement> optionsListOne = new List<IWebElement>();
            List<IWebElement> optionsListTwo = new List<IWebElement>();
            Mock<IWebElement> mockOptionElement = new Mock<IWebElement>();

            beanOne.OptionElements = optionsListOne;
            beanTwo.OptionElements = optionsListOne;

            Assert.AreEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "The hash codes for two beans should be " +
                "equal if they have the same contrainer element references and the same empty option elements list " +
                "reference");

            optionsListOne.Add(mockOptionElement.Object);

            Assert.AreEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "The hash codes for two beans should be " +
                "equal if they have the same contrainer element references and the same non-empty option elements " +
                "list reference");

            optionsListTwo.Add(mockOptionElement.Object);
            beanTwo.OptionElements = optionsListTwo;

            Assert.AreEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "The hash codes for two beans should be " +
                "equal if they have the same contrainer element references and two non-empty option elements list " +
                "references containing the same object");

            optionsListOne = new List<IWebElement>();
            optionsListTwo = new List<IWebElement>();

            beanOne.OptionElements = optionsListOne;
            beanTwo.OptionElements = optionsListTwo;

            Assert.AreEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "The hash codes for two beans should be " +
                "equal if they have the same container element and two different empty option element list references");

            beanOne = new MenuBean();
            beanTwo = new MenuBean();

            beanOne.OptionElements = optionsListOne;
            beanTwo.OptionElements = optionsListTwo;

            Assert.AreEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "The hash codes for two beans should be " +
                "equal if they both have null container element references and two different empty option element " +
                "list references");

            beanTwo.OptionElements = optionsListOne;

            Assert.AreEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "The hash codes for two beans should be " +
                "equal if they both have null container element references and the same empty option elements list " +
                "reference");

            beanTwo.OptionElements = optionsListTwo;
            optionsListOne.Add(mockOptionElement.Object);
            optionsListTwo.Add(mockOptionElement.Object);

            Assert.AreEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "The hash codes for two beans should be " +
                "equal if they both have null container element references and two non-empty option elements list " +
                "references containing the same object");
        }
        public void ShouldCallBaseForHashCode()
        {
            IMenuBean bean = new MenuBean();
            IMenuBean beanToCompare = new MenuBean();

            Assert.AreEqual(bean.GetHashCode(), beanToCompare.GetHashCode(), "Hash codes for bean which have not had " +
                "setters called should be equal, but are not: " + bean.ToString() + ", " + beanToCompare.ToString());

            Mock<IWebElement> mockElement = new Mock<IWebElement>();

            bean.ContentContainer = mockElement.Object;
            Assert.AreNotEqual(bean.GetHashCode(), beanToCompare.GetHashCode(), "Hash codes for bean which have " +
                "different values for their container element fields should not be equal, but are: " +
                bean.ToString() + ", " + beanToCompare.ToString());

            beanToCompare.ContentContainer = mockElement.Object;
            Assert.AreEqual(bean.GetHashCode(), beanToCompare.GetHashCode(), "Hash codes for bean which have the " +
                "same container element should be equal, but are not: " + bean.ToString() + ", " +
                beanToCompare.ToString());
        }
        public void HashCodesShouldNotBeEqual()
        {
            Mock<IWebElement> mockElementOne = new Mock<IWebElement>();
            Mock<IWebElement> mockElementTwo = new Mock<IWebElement>();

            IMenuBean beanOne = new MenuBean();
            IMenuBean beanTwo = new MenuBean();

            beanOne.ContentContainer = mockElementOne.Object;
            beanTwo.ContentContainer = mockElementTwo.Object;

            Assert.AreNotEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "Beans with different container element " +
                "references should have different hash codes");

            beanTwo.ContentContainer = mockElementOne.Object;

            IList<IWebElement> optionsListOne = new List<IWebElement>();
            IList<IWebElement> optionsListTwo = new List<IWebElement>();
            Mock<IWebElement> mockOptionElementOne = new Mock<IWebElement>();
            Mock<IWebElement> mockOptionElementTwo = new Mock<IWebElement>();

            optionsListOne.Add(mockOptionElementOne.Object);
            optionsListTwo.Add(mockOptionElementTwo.Object);
            beanOne.OptionElements = optionsListOne;
            beanTwo.OptionElements = optionsListTwo;

            Assert.AreNotEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "Beans with different lists of option " +
                "elements should have different hash codes");

            beanTwo.OptionElements = optionsListOne;
            beanOne.ClickOptionWithJavascript = true;

            Assert.AreNotEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "Beans with different Javascript click " +
                "workaround values should have different hash codes");
        }