Example #1
0
        public void Match_WhenFirstValueIsNotContext_ThrowsInvalidOperationException(ContextControlStringMatcher unit)
        {
            unit.Context = "foo";

            var fixture = new Fixture();

            fixture.Customizations.Add(new InlineConstructorParams <ControlString>(0, 3, new Queue <string>(new[] { "bar" })));

            var controlString = fixture.Create <ControlString>();

            Should.Throw <ArgumentException>(() => unit.Match(controlString));
        }
Example #2
0
        public void Matches_WhenFirstValueIsNotContext_ReturnsFalse(ContextControlStringMatcher unit)
        {
            unit.Context = "foo";

            var fixture = new Fixture();

            fixture.Customizations.Add(new InlineConstructorParams <ControlString>(0, 3, new Queue <string>(new[] { "bar" })));

            var controlString = fixture.Create <ControlString>();

            unit.Matches(controlString).ShouldBeFalse();
        }
Example #3
0
        public void Matches_WhenFirstValueIsContextAndSubMatcherDoesNotMatch_ReturnsFalse([Frozen] IControlStringMatcher submatcher, ContextControlStringMatcher unit)
        {
            Mock.Get(submatcher).Setup(x => x.Matches(It.IsAny <ControlString>())).Returns(false);

            unit.Context = "foo";

            var fixture = new Fixture();

            fixture.Customizations.Add(new InlineConstructorParams <ControlString>(0, 3, new Queue <string>(new[] { unit.Context })));

            var controlString = fixture.Create <ControlString>();

            unit.Matches(controlString).ShouldBeFalse();
        }
Example #4
0
 public void Match_WhenControlStringIsNull_ThrowsArgumentNullException(ContextControlStringMatcher unit)
 {
     Should.Throw <ArgumentNullException>(() => unit.Match(null));
 }
Example #5
0
        public void Match_WhenFirstValueIsContext_ExecutesSecondControlStringMatcher([Frozen] IControlStringMatcher submatcher, ContextControlStringMatcher unit)
        {
            Mock.Get(submatcher).Setup(x => x.Matches(It.IsAny <ControlString>())).Returns(true);

            unit.Context = "foo";

            var expected = "bar";

            var fixture = new Fixture();

            fixture.Customizations.Add(new InlineConstructorParams <ControlString>(0, 3, new Queue <string>(new[] { unit.Context, expected })));

            var controlString = fixture.Create <ControlString>();

            unit.Match(controlString);

            Mock.Get(unit.Matcher).Verify(x => x.Match(It.Is <ControlString>(y => y.Values.Peek() == expected)));
        }