Exemple #1
0
        public void MakeNewFieldWhenReadNewSize()
        {
            var fieldBuilder  = new FieldBuilder();
            var fileReader    = new TestFileReader(new[] { "33", ".*.", ".**", "...", "22", ".*", "..", "00" });
            var valueArray    = fileReader.ReadFile();
            var createdFields = fieldBuilder.ReadAllFields(valueArray);

            Assert.Equal(2, createdFields.Count);
        }
Exemple #2
0
        public void StopSettingRowsWhenZeroRead()
        {
            var fieldBuilder = new FieldBuilder();
            var fileReader   = new TestFileReader(new[] { "00" });
            var valueArray   = fileReader.ReadFile();
            var createdField = fieldBuilder.ReadField(valueArray, 0);

            Assert.Null(createdField);
        }
Exemple #3
0
        public void SetRowsOfField()
        {
            var fieldBuilder = new FieldBuilder();
            var fileReader   = new TestFileReader(new[] { "22", ".*", "**" });
            var valueArray   = fileReader.ReadFile();
            var createdField = fieldBuilder.ReadField(valueArray, 0);

            Assert.Equal(new List <CellType>()
            {
                CellType.Empty, CellType.Mine
            }, createdField.GetRow(0));
            Assert.Equal(new List <CellType>()
            {
                CellType.Mine, CellType.Mine
            }, createdField.GetRow(1));
        }
Exemple #4
0
        public void SetFieldFromReadFile()
        {
            var fieldBuilder = new FieldBuilder();
            var fileReader   = new TestFileReader();
            var valueArray   = fileReader.ReadFile("/Users/cindy.cai/RiderProjects/MinesweeperKata/input.txt");
            var createdField = fieldBuilder.ReadField(valueArray, 0);

            Assert.Equal(new List <CellType>()
            {
                CellType.Empty, CellType.Empty
            }, createdField.GetRow(0));
            Assert.Equal(new List <CellType>()
            {
                CellType.Empty, CellType.Mine
            }, createdField.GetRow(1));
        }
Exemple #5
0
        public void ReadAllFieldsShouldReturnManyFields()
        {
            var fieldBuilder  = new FieldBuilder();
            var fileReader    = new TestFileReader(new[] { "33", ".*.", ".**", "...", "22", ".*", "..", "00" });
            var valueArray    = fileReader.ReadFile();
            var createdFields = fieldBuilder.ReadAllFields(valueArray);

            Assert.Equal(new List <CellType>()
            {
                CellType.Empty, CellType.Mine, CellType.Empty
            },
                         createdFields[0].GetRow(0));
            Assert.Equal(new List <CellType>()
            {
                CellType.Empty, CellType.Mine
            }, createdFields[1].GetRow(0));
        }