public void ShouldCallSetBackgroundColorOnlyOnceWithNestedCallsToOnAndOff()
        {
            // GIVEN
            var domContainer = new Mock<DomContainer>().Object;
            var nativeElementMock = new Mock<INativeElement>();
            var element = new Element(domContainer, nativeElementMock.Object);

            Settings.HighLightColor = "myTestColor";
            var highLight = new HighlightAction(element);

            nativeElementMock.Expect(nativeElement => nativeElement.IsElementReferenceStillValid()).Returns(true);
            nativeElementMock.Expect(nativeElement => nativeElement.GetStyleAttributeValue("backgroundColor")).Returns("initialColor").AtMostOnce();
            nativeElementMock.Expect(nativeElement => nativeElement.SetStyleAttributeValue("backgroundColor", "myTestColor")).AtMostOnce();
            nativeElementMock.Expect(nativeElement => nativeElement.SetStyleAttributeValue("backgroundColor", "initialColor")).AtMostOnce();

            // WHEN
            highLight.On();
            highLight.On();
            highLight.On();
            highLight.Off();
            highLight.Off();
            highLight.Off();

            // THEN
            nativeElementMock.VerifyAll();
        }
Exemplo n.º 2
0
        public void ShouldSetBackgroundColor()
        {
            // GIVEN
            var domContainer = new Mock<DomContainer>().Object;
            var nativeElementMock = new Mock<INativeElement>();
            nativeElementMock.Expect(x => x.IsElementReferenceStillValid()).Returns(true);
            var element = new Element(domContainer, nativeElementMock.Object);

            Settings.HighLightColor = "myTestColor";
            var highLightAction = new HighlightAction(element);

            // WHEN
            highLightAction.On();

            // THEN
            nativeElementMock.Verify(nativeElement => nativeElement.SetStyleAttributeValue("backgroundColor", "myTestColor"));
        }
        public void ShouldIgnoreStackEmptyExceptionWhenColorStackIsEmpty()
        {
            // GIVEN
            var domContainer = new Mock<DomContainer>().Object;
            var nativeElementMock = new Mock<INativeElement>();
            nativeElementMock.Expect(x => x.IsElementReferenceStillValid()).Returns(true);
            var element = new Element(domContainer, nativeElementMock.Object);

            Settings.HighLightColor = "myTestColor";
            var highLight = new HighlightAction(element);
            nativeElementMock.Expect(nativeElement => nativeElement.GetStyleAttributeValue("backgroundColor")).Returns("initialColor");

            highLight.On();
            highLight.Off();

            // WHEN
            highLight.Off();

            // THEN no exception
        }