Ejemplo n.º 1
0
        public void Converts_to_OrState_with_each_part_negationed()
        {
            var state1 = SingleColorState.Create("Left", "Blue");
            var state2 = SingleColorState.Create("Front", "Red");
            var stete3 = SingleColorState.Create("Right", "Green");

            var andState     = new AndState(ImmutableArray.Create <IState>(state1, state2, stete3));
            var negatedState = Assert.IsType <OrState>(andState.Negate());

            Assert.Collection(
                negatedState.States,
                state => Assert.Equal("!Left Blue", state.ToString()),
                state => Assert.Equal("!Front Red", state.ToString()),
                state => Assert.Equal("!Right Green", state.ToString()));
        }
Ejemplo n.º 2
0
        public void False_if_all_parts_are_true()
        {
            var trueState1 = A.Fake <IState>();

            A.CallTo(() => trueState1.Matches(A <Puzzle> .Ignored)).Returns(true);
            var trueState2 = A.Fake <IState>();

            A.CallTo(() => trueState2.Matches(A <Puzzle> .Ignored)).Returns(true);
            var trueState3 = A.Fake <IState>();

            A.CallTo(() => trueState3.Matches(A <Puzzle> .Ignored)).Returns(true);

            var andState = new AndState(ImmutableArray.Create(trueState1, trueState2, trueState3));

            Assert.False(andState.Negate().Matches(null));
        }
Ejemplo n.º 3
0
        public void True_if_any_part_is_false(bool value1, bool value2, bool value3)
        {
            var state1 = A.Fake <IState>();

            A.CallTo(() => state1.Matches(A <Puzzle> .Ignored)).Returns(value1);
            A.CallTo(() => state1.Negate()).ReturnsLazily(() => NegateFakeState(state1));
            var state2 = A.Fake <IState>();

            A.CallTo(() => state2.Matches(A <Puzzle> .Ignored)).Returns(value2);
            A.CallTo(() => state2.Negate()).ReturnsLazily(() => NegateFakeState(state2));
            var state3 = A.Fake <IState>();

            A.CallTo(() => state3.Matches(A <Puzzle> .Ignored)).Returns(value3);
            A.CallTo(() => state3.Negate()).ReturnsLazily(() => NegateFakeState(state3));

            var andState = new AndState(ImmutableArray.Create(state1, state2, state3));

            Assert.True(andState.Negate().Matches(null));
        }