View Javadoc
1   /*
2    * Copyright © 2016 Greg Chabala
3    *
4    * This file is part of brick-control-lab.
5    *
6    * brick-control-lab is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU Lesser General Public License as
8    * published by the Free Software Foundation, either version 3 of the
9    * License, or (at your option) any later version.
10   *
11   * brick-control-lab is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU Lesser General Public License for more details.
15   *
16   * You should have received a copy of the GNU Lesser General Public License
17   * along with brick-control-lab.  If not, see http://www.gnu.org/licenses/.
18   */
19  package org.chabala.brick.controllab;
20  
21  import org.junit.Test;
22  
23  import java.util.HashSet;
24  import java.util.Set;
25  
26  import static org.hamcrest.Matchers.arrayWithSize;
27  import static org.hamcrest.Matchers.hasSize;
28  import static org.junit.Assert.*;
29  
30  /**
31   * Testing {@link Direction}.
32   */
33  public class DirectionTest {
34  
35      @Test
36      public void testThereAreThreeDirections() throws Exception {
37          assertThat(Direction.values(), arrayWithSize(3));
38      }
39  
40      @Test
41      public void testEveryDirectionHasAUniqueCode() throws Exception {
42          Set<Byte> codes = new HashSet<>();
43          for (Direction d : Direction.values()) {
44              codes.add(d.getCode());
45          }
46          assertThat(codes, hasSize(Direction.values().length));
47      }
48  }