public void HashCodesShouldBeEqual()
        {
            IControllableBean beanOne = new ControllableBean();
            IControllableBean beanTwo = new ControllableBean();

            Assert.AreEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "Two newly constructed beans should have " +
                "the same hash code before any setters are invoked");

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

            beanOne.ContentContainer = mockContainerElementOne.Object;
            beanTwo.ContentContainer = mockContainerElementOne.Object;

            Assert.AreEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "Two beans should have the same hash code " +
                "if they have the same container element reference and same default JavaScript click workaround value");

            Mock<IClickControlBean> mockClickControlBean = new Mock<IClickControlBean>();
            beanOne.AddClickControl("name", mockClickControlBean.Object);
            beanTwo.AddClickControl("name", mockClickControlBean.Object);

            Assert.AreEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "Two beans should have the same hash code " +
                "if they have the same container element reference and same click control bean instance mapped to " +
                "the same name");

            beanOne = new ControllableBean();
            beanTwo = new ControllableBean();

            beanOne.ContentContainer = mockContainerElementOne.Object;
            beanTwo.ContentContainer = mockContainerElementOne.Object;

            IClickControlBean clickControlBeanOne = new ClickControlBean();
            IClickControlBean clickControlBeanTwo = new ClickControlBean();

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

            clickControlBeanOne.ContentContainer = mockContainerElementTwo.Object;
            clickControlBeanTwo.ContentContainer = mockContainerElementTwo.Object;
            clickControlBeanOne.ClickWithJavascript = true;
            clickControlBeanTwo.ClickWithJavascript = true;

            beanOne.AddClickControl("name", clickControlBeanOne);
            beanTwo.AddClickControl("name", clickControlBeanTwo);

            Assert.AreEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "Two beans should have the same hash code " +
                "if they have the same container element reference and different click control bean instance mapped " +
                "to the same name which have the same content container reference and the same non-default "+
                "Javascript click workaround value");

            beanOne = new ControllableBean();
            beanTwo = new ControllableBean();

            beanOne.AddClickControl("name", clickControlBeanOne);
            beanTwo.AddClickControl("name", clickControlBeanTwo);

            Assert.AreEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "Two beans should have the same hash code " +
                "if they have null container element references and different click control bean instances mapped to " +
                "the same name, but which have the same content container reference and the same non-default " +
                "Javascript click workaround value");

            beanOne = new ControllableBean();
            beanTwo = new ControllableBean();

            beanOne.AddClickControl("name", mockClickControlBean.Object);
            beanTwo.AddClickControl("name", mockClickControlBean.Object);

            Assert.AreEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "Two beans should have the same hash code " +
                "if they have null container element references and same click control bean instance mapped to the " +
                "same name");

            beanOne = new ControllableBean();
            beanTwo = new ControllableBean();

            beanOne.ContentContainer = mockContainerElementOne.Object;
            beanTwo.ContentContainer = mockContainerElementOne.Object;

            Mock<IHoverControlBean> mockHoverControlBean = new Mock<IHoverControlBean>();
            beanOne.AddHoverControl("name", mockHoverControlBean.Object);
            beanTwo.AddHoverControl("name", mockHoverControlBean.Object);

            Assert.AreEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "Two beans should have the same hash code " +
                "if they have the same container element reference and same hover control bean instance mapped to " +
                "the same name");

            beanOne = new ControllableBean();
            beanTwo = new ControllableBean();

            beanOne.ContentContainer = mockContainerElementOne.Object;
            beanTwo.ContentContainer = mockContainerElementOne.Object;

            IHoverControlBean hoverControlBeanOne = new HoverControlBean();
            IHoverControlBean hoverControlBeanTwo = new HoverControlBean();

            hoverControlBeanOne.ContentContainer = mockContainerElementTwo.Object;
            hoverControlBeanTwo.ContentContainer = mockContainerElementTwo.Object;
            hoverControlBeanOne.ClickInsteadOfHover = true;
            hoverControlBeanTwo.ClickInsteadOfHover = true;

            beanOne.AddHoverControl("name", hoverControlBeanOne);
            beanTwo.AddHoverControl("name", hoverControlBeanTwo);

            Assert.AreEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "Two beans should have the same hash code " +
                "if they have the same container element reference and different hover control bean instances mapped " +
                "to the same name which have the same content container reference and the same non-default click " +
                "instead of hover workaround value");

            beanOne = new ControllableBean();
            beanTwo = new ControllableBean();

            beanOne.AddHoverControl("name", mockHoverControlBean.Object);
            beanTwo.AddHoverControl("name", mockHoverControlBean.Object);

            Assert.AreEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "Two beans should have the same hash code " +
                "if they have null container element references and same hover control bean instance mapped to the " +
                "same name");

            beanOne = new ControllableBean();
            beanTwo = new ControllableBean();

            beanOne.ContentContainer = mockContainerElementOne.Object;
            beanTwo.ContentContainer = mockContainerElementOne.Object;

            Mock<IHoverAndClickControlBean> mockHoverAndClickControlBean = new Mock<IHoverAndClickControlBean>();
            beanOne.AddHoverAndClickControl("name", mockHoverAndClickControlBean.Object);
            beanTwo.AddHoverAndClickControl("name", mockHoverAndClickControlBean.Object);

            Assert.AreEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "Two beans should have the same hash code " +
                "if they have the same container element reference and same hover and click control bean instance " +
                "mapped to the same name");

            beanOne = new ControllableBean();
            beanTwo = new ControllableBean();

            beanOne.ContentContainer = mockContainerElementOne.Object;
            beanTwo.ContentContainer = mockContainerElementOne.Object;

            IHoverAndClickControlBean hoverAndClickControlBeanOne = new HoverAndClickControlBean();
            IHoverAndClickControlBean hoverAndClickControlBeanTwo = new HoverAndClickControlBean();

            hoverAndClickControlBeanOne.ContentContainer = mockContainerElementTwo.Object;
            hoverAndClickControlBeanTwo.ContentContainer = mockContainerElementTwo.Object;
            hoverAndClickControlBeanOne.ClickWithJavascript = true;
            hoverAndClickControlBeanTwo.ClickWithJavascript = true;

            beanOne.AddHoverAndClickControl("name", hoverAndClickControlBeanOne);
            beanTwo.AddHoverAndClickControl("name", hoverAndClickControlBeanTwo);

            Assert.AreEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "Two beans should have the same hash code " +
                "if they have the same container element reference and different hover and click control bean " +
                "instance mapped to the same name which have the same content container reference and the same " +
                "non-default Javascript click instead of hover workaround value");

            beanOne = new ControllableBean();
            beanTwo = new ControllableBean();

            beanOne.AddHoverAndClickControl("name", mockHoverAndClickControlBean.Object);
            beanTwo.AddHoverAndClickControl("name", mockHoverAndClickControlBean.Object);

            Assert.AreEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "Two beans should have the same hash code " +
                "if they have null container element references and same hover and click control bean instance " +
                "mapped to the same name");
        }
        public void ShouldCallBaseForHashCode()
        {
            IControllableBean bean = new ControllableBean();
            IControllableBean beanToCompare = new ControllableBean();

            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>();

            IControllableBean beanOne = new ControllableBean();
            IControllableBean beanTwo = new ControllableBean();

            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;

            beanOne = new ControllableBean();
            beanTwo = new ControllableBean();

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

            IClickControlBean clickControlBeanOne = new ClickControlBean();
            IClickControlBean clickControlBeanTwo = new ClickControlBean();

            clickControlBeanOne.ContentContainer = mockElementTwo.Object;
            clickControlBeanTwo.ContentContainer = mockElementTwo.Object;
            clickControlBeanOne.ClickWithJavascript = true;

            beanOne.AddClickControl("name", clickControlBeanOne);
            beanTwo.AddClickControl("name", clickControlBeanTwo);

            Assert.AreNotEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "Two beans should have difference hash " +
                "codes if they have the same container element reference and different click control bean instance " +
                "mapped to the same name which have the same content container reference but different Javascript " +
                "click workaround values");

            beanOne = new ControllableBean();
            beanTwo = new ControllableBean();

            beanOne.AddClickControl("clickControlOne", clickControlBeanOne);
            beanTwo.AddClickControl("clickControlTwo", clickControlBeanOne);

            Assert.AreNotEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "Beans with the same click control " +
                "bean instance mapped to different names should have different hash codes");

            beanOne = new ControllableBean();
            beanTwo = new ControllableBean();

            IHoverControlBean hoverControlBeanOne = new HoverControlBean();
            IHoverControlBean hoverControlBeanTwo = new HoverControlBean();

            hoverControlBeanOne.ContentContainer = mockElementTwo.Object;
            hoverControlBeanTwo.ContentContainer = mockElementTwo.Object;
            hoverControlBeanOne.HoverWithJavascript = true;

            beanOne.AddHoverControl("hoverControl", hoverControlBeanOne);
            beanTwo.AddHoverControl("hoverControl", hoverControlBeanTwo);

            Assert.AreNotEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "Two beans should have different hash " +
                "codes  if they have the same container element reference and different hover control bean instance " +
                "mapped to the same name which have the same content container reference but different Javascript " +
                "hover workaround values");

            beanOne = new ControllableBean();
            beanTwo = new ControllableBean();

            beanOne.AddHoverControl("hoverControlOne", hoverControlBeanOne);
            beanTwo.AddHoverControl("hoverControlTwo", hoverControlBeanOne);

            Assert.AreNotEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "Beans with the same hover control bean " +
                "instance mapped to different names should have different hash codes");

            beanOne = new ControllableBean();
            beanTwo = new ControllableBean();

            IHoverAndClickControlBean hoverAndClickControlBeanOne = new HoverAndClickControlBean();
            IHoverAndClickControlBean hoverAndClickControlBeanTwo = new HoverAndClickControlBean();

            hoverAndClickControlBeanOne.ContentContainer = mockElementTwo.Object;
            hoverAndClickControlBeanTwo.ContentContainer = mockElementTwo.Object;
            hoverAndClickControlBeanOne.HoverWithJavascript = true;

            beanOne.AddHoverAndClickControl("hoverAndClickControl", hoverAndClickControlBeanOne);
            beanTwo.AddHoverAndClickControl("hoverAndClickControl", hoverAndClickControlBeanTwo);

            Assert.AreNotEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "Two beans should have different hash " +
                "codes if they have the same container element reference and different hover and click control bean " +
                "instance mapped to the same name which have the same content container reference but different " +
                "Javascript hover workaround values");

            beanOne = new ControllableBean();
            beanTwo = new ControllableBean();

            beanOne.AddHoverAndClickControl("hoverAndClickControlOne", hoverAndClickControlBeanOne);
            beanTwo.AddHoverAndClickControl("hoverAndClickControlTwo", hoverAndClickControlBeanOne);

            Assert.AreNotEqual(beanOne.GetHashCode(), beanTwo.GetHashCode(), "Beans with the same hover and click " +
                "control bean instance mapped to different names should have different hash codes");
        }