Пример #1
0
    public void InitializeGrid()
    {
        groupPattern = Substitute.For <IGroupPattern>();
        rotationMock = new List <Coord[]>()
        {
            new Coord[] {
                new Coord(0, 0),
                new Coord(0, -1),
                new Coord(1, 0),
                new Coord(-1, 0),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(-1, 0),
                new Coord(0, -1),
                new Coord(0, 1),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(0, 1),
                new Coord(-1, 0),
                new Coord(1, 0),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(1, 0),
                new Coord(0, 1),
                new Coord(0, -1),
            },
        };
        groupPattern.Patterns.Returns(rotationMock);

        groupPatternList = new List <IGroupPattern>();
        groupPatternList.Add(groupPattern);

        groupFactory = new GroupFactory(blockFactory, groupPatternList);

        gridFactory = new GridFactory(setting, groupFactory);

        // create grid
        grid = gridFactory.Create();
        grid.NewGame();

        blockPattern  = Substitute.For <IBlockPattern>();
        blockTypeMock = new BlockType[]
        {
            BlockType.One,
            BlockType.Six,
            BlockType.Three,
            BlockType.Five,
        };
        blockPattern.Types.Returns(blockTypeMock);

        group = groupFactory.Create(setting, blockPattern, groupPattern);
    }
Пример #2
0
    public void InitializeGrid()
    {
        groupPattern = Substitute.For<IGroupPattern>();
        rotationMock = new List<Coord[]>() {
            new Coord[] {
                new Coord(0, 0),
                new Coord(0, -1),
                new Coord(1, 0),
                new Coord(-1, 0),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(-1, 0),
                new Coord(0, -1),
                new Coord(0, 1),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(0, 1),
                new Coord(-1, 0),
                new Coord(1, 0),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(1, 0),
                new Coord(0, 1),
                new Coord(0, -1),
            },
        };
        groupPattern.Patterns.Returns(rotationMock);

        groupPatternList = new List<IGroupPattern>();
        groupPatternList.Add(groupPattern);

        groupFactory = new GroupFactory(blockFactory, groupPatternList);

        gridFactory = new GridFactory(setting, groupFactory);

        // create grid
        grid = gridFactory.Create();
        grid.NewGame();

        blockPattern = Substitute.For<IBlockPattern>();
        blockTypeMock = new BlockType[]
        {
            BlockType.One,
            BlockType.Six,
            BlockType.Three,
            BlockType.Five,
        };
        blockPattern.Types.Returns(blockTypeMock);

        group = groupFactory.Create(setting, blockPattern, groupPattern);
    }
Пример #3
0
    public IGroup Create(ISetting setting, IBlockPattern blockPattern, IGroupPattern groupPattern)
    {
        IGroup group = new Group(setting);

        for (int i = 0; i < groupPattern.Patterns[0].Length; i++)
        {
            IBlock block = _blockFactory.Create(setting, blockPattern.Types[i], groupPattern.Patterns[0][i]);
            group.AddBlock(block);
        }

        group.SetPattern(groupPattern.Patterns);

        return(group);
    }
Пример #4
0
    public void ShouldCreateGroupFromGroupPattern()
    {
        IGroup group = groupFactory.Create(setting, blockPattern, groupPattern);

        group.SetLocation(new Coord(0, 0));
        foreach (Coord coord in locationMock[0])
        {
            group.ChildrenLocation.Contains(coord);
        }

        int[]         numbers         = new int[] { 3, 1, 5 };
        IBlockPattern blockPatternTwo = BlockPattern.CreateFromNumbers(numbers);
        IGroup        groupTwo        = groupFactory.Create(setting, blockPatternTwo, groupPattern);

        for (int i = 0; i < numbers.Length; i++)
        {
            Assert.AreEqual((BlockType)numbers[i] - 1, groupTwo.Children[i].BlockType);
        }
    }
Пример #5
0
    public void Init()
    {
        blockPattern  = Substitute.For <IBlockPattern>();
        blockTypeMock = new BlockType[]
        {
            BlockType.Two,
            BlockType.Four,
            BlockType.Seven,
        };
        blockPattern.Types.Returns(blockTypeMock);

        groupPattern = Substitute.For <IGroupPattern>();
        locationMock = new List <Coord[]>()
        {
            new Coord[] {
                new Coord(0, 0),
                new Coord(0, 1),
                new Coord(1, 0),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(1, 0),
                new Coord(0, -1),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(0, -1),
                new Coord(-1, 0),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(-1, 0),
                new Coord(0, 1),
            },
        };
        groupPattern.Patterns.Returns(locationMock);
    }
Пример #6
0
    public void Init()
    {
        blockPattern = Substitute.For<IBlockPattern>();
        blockTypeMock = new BlockType[]
        {
            BlockType.Two,
            BlockType.Four,
            BlockType.Seven,
        };
        blockPattern.Types.Returns(blockTypeMock);

        groupPattern = Substitute.For<IGroupPattern>();
        locationMock = new List<Coord[]>() {
            new Coord[] {
                new Coord(0, 0),
                new Coord(0, 1),
                new Coord(1, 0),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(1, 0),
                new Coord(0, -1),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(0, -1),
                new Coord(-1, 0),
            },
            new Coord[] {
                new Coord(0, 0),
                new Coord(-1, 0),
                new Coord(0, 1),
            },
        };
        groupPattern.Patterns.Returns(locationMock);
    }
Пример #7
0
 public IGroup Create(ISetting setting, IBlockPattern blockPattern, IGroupPattern groupPattern)
 {
     throw new System.NotImplementedException();
 }
Пример #8
0
 public IGroup Create(ISetting setting, IBlockPattern blockPattern, IGroupPattern groupPattern)
 {
     throw new System.NotImplementedException();
 }
Пример #9
0
    public bool AddGroupToTheGrid(IBlockPattern blockPattern, IGroupPattern groupPattern)
    {
        IGroup group = _groupFactory.Create(_setting, blockPattern, groupPattern);

        return(_grid.AddGroup(group));
    }
Пример #10
0
 public bool AddGroupToTheGrid(IBlockPattern blockPattern, IGroupPattern groupPattern)
 {
     IGroup group = _groupFactory.Create(_setting, blockPattern, groupPattern);
     return _grid.AddGroup(group);
 }