public void ShouldThrowExceptionForOneParamAddHoverControlWithWhitespaceName()
 {
     IControllableBean bean = new ControllableBean();
     bean.AddHoverControl("   ");
 }
 public void ShouldThrowExceptionForOneParamAddHoverControlWithNameMatchingExistingHoverControlMapping()
 {
     IControllableBean bean = new ControllableBean();
     bean.AddHoverControl("name");
     bean.AddHoverControl("name");
 }
 public void ShouldThrowExceptionForOneParamAddHoverControlWithNullName()
 {
     IControllableBean bean = new ControllableBean();
     bean.AddHoverControl(null);
 }
        public void ShouldNotBeEqual()
        {
            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, beanTwo, "Beans with different container element references should not be " +
                "equal");

            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, beanTwo, "Two beans should not be equal 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, beanTwo, "Beans with the same click control bean instance mapped to " +
                "different names should not be equal");

            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, beanTwo, "Two beans should not be equal 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, beanTwo, "Beans with the same hover control bean instance mapped to " +
                "different names should not be equal");

            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, beanTwo, "Two beans should not be equal 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, beanTwo, "Beans with the same hover and click control bean instance mapped " +
                "to different names should not be equal");
        }
 public void ShouldThrowExceptionForAddingPollingTimeoutToHoverControl()
 {
     IControllableBean bean = new ControllableBean();
     bean.AddHoverControl("name");
     bean.SetControlPollingTimeout("name", 50);
 }
        public void ShouldBeEqual()
        {
            IControllableBean beanOne = new ControllableBean();
            IControllableBean beanTwo = new ControllableBean();

            Assert.AreEqual(beanOne, beanTwo, "Two newly constructed beans should be equal before any setters are " +
                "invoked");

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

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

            Assert.AreEqual(beanOne, beanTwo, "Two beans should be equal 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, beanTwo, "Two beans should be equal 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, beanTwo, "Two beans should be equal 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, beanTwo, "Two beans should be equal 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, beanTwo, "Two beans should be equal 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, beanTwo, "Two beans should be equal 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, beanTwo, "Two beans should be equal 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, beanTwo, "Two beans should be equal 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, beanTwo, "Two beans should be equal 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, beanTwo, "Two beans should be equal 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, beanTwo, "Two beans should be equal if they have null container element " +
                "references and same hover and click control bean instance mapped to the same name");
        }
        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");
        }
 public void ShouldThrowExceptionForTwoParamHoverControlWithNullBean()
 {
     IControllableBean bean = new ControllableBean();
     bean.AddHoverControl("name", (IHoverControlBean)null);
 }
 public void ShouldThrowExceptionForTwoParamAddHoverControlWithEmptyName()
 {
     IControllableBean bean = new ControllableBean();
     bean.AddHoverControl("", new HoverControlBean());
 }
 public void ShouldThrowExceptionForSettingClickWithJavascriptForHoverControl()
 {
     IControllableBean bean = new ControllableBean();
     bean.AddHoverControl("name");
     bean.SetClickControlWithJavascript("name", true);
 }