Example #1
0
        public void Can_parse_named_states(string xmlText)
        {
            var solver = Solver.Empty
                         .WithState("LeftCenter", SingleColorState.Create("Left", "Blue"))
                         .WithState("LeftDown", EdgeState.Create("LeftDown", "Blue", "White"));
            var andState = Assert.IsType <AndState>(
                StateParser.Parse(null, null, new XElement("State", xmlText), solver).State);

            Assert.Collection(
                andState.States,
                state => Assert.Equal(Location.Left, ((SingleColorState)state).Location),
                state => Assert.Equal(Location.LeftDown, ((EdgeState)state).Location));
        }
Example #2
0
        public void Can_parse_named_states_in_Or_elements(string state1, string state2)
        {
            var solver = Solver.Empty
                         .WithState("LeftCenter", SingleColorState.Create("Left", "Blue"))
                         .WithState("LeftDown", EdgeState.Create("LeftDown", "Blue", "White"));
            var xml =
                new XElement(
                    "State",
                    new XElement(
                        "Or",
                        new XElement("State", state1),
                        new XElement("State", state2)));
            var orState = Assert.IsType <OrState>(
                StateParser.Parse(null, null, xml, solver).State);

            Assert.Collection(
                orState.States,
                state => Assert.Equal(Location.Left, ((SingleColorState)state).Location),
                state => Assert.Equal(Location.LeftDown, ((EdgeState)state).Location));
        }
        public void EdgeOrFlipped_returns_false_if_either_color_is_incorrect(string color1, string color2)
        {
            var state = EdgeState.Create("LeftFront*", color1, color2);

            Assert.False(state.Matches(Puzzle.Solved));
        }
        public void True_if_both_colors_are_correct()
        {
            var state = EdgeState.Create("LeftFront", "Blue", "Red");

            Assert.True(state.Matches(Puzzle.Solved));
        }
        public void EdgeOrFlipped_returns_true_if_both_colors_are_correct(string color1, string color2)
        {
            var state = EdgeState.Create("LeftFront*", color1, color2);

            Assert.True(state.Matches(Puzzle.Solved));
        }