示例#1
0
        public void AddToEmptySpace()
        {
            // Given
            var space = new HexSpace <Item>();

            // When
            var payload = new Item();
            var h       = space.Add(payload);

            // Then
            space.Contains(h).Should().BeTrue();
            space.GetPayload(h).Should().Be(payload);
            space.Count.Should().Be(1);
        }
示例#2
0
        public void NearestHexes_from_center()
        {
            // Given
            var space = new HexSpace <Item>();

            var payloads = Enumerable.Range(0, 7).Select(i => new Item());
            var hexes    = new List <Hex>();

            foreach (var payload in payloads)
            {
                space.Add(payload);
            }

            // When
            var nearestHexes = space.GetNearestHexes(new Hex(0, 0));

            // Then
            nearestHexes.Should().NotBeEmpty();
            nearestHexes.Should().HaveCount(6);
        }
示例#3
0
        public void FillUpFirstTwoRings()
        {
            // Given
            var space = new HexSpace <Item>();

            // When
            var payloads = Enumerable.Range(0, 7).Select(i => new Item());
            var hexes    = new List <Hex>();

            foreach (var payload in payloads)
            {
                space.Add(payload);
            }

            // Then
            space.Count.Should().Be(payloads.Count());
            hexes.ForEach(h =>
            {
                var p = space.GetPayload(h);
                payloads.Should().Contain(p);
            });
        }