示例#1
0
        public IEnumerator Tile_Surrounding_Agent_Are_Correctly_Given()
        {
            var trainingInstanceController = GetTrainingInstance(2);

            yield return(new WaitUntil(() => trainingInstanceController.TestSetUpComplete));

            SpyAgent agentScript = trainingInstanceController.Spy.GetComponent <SpyAgent>();

            var middleTile = trainingInstanceController.TileDict[TileType.FreeTiles]
                             .First(tile => tile.Coords == (5, 5));


            agentScript.transform.position = middleTile.Position;

            var surroundingTilesPositions =
                agentScript.GetNearestTilePositions(9, trainingInstanceController.TileDict[TileType.FreeTiles]);

            var surroundingTilePositionTuples = new List <(float, float)>();

            for (var i = 0; i < surroundingTilesPositions.Count - 1; i++)
            {
                surroundingTilePositionTuples.Add((surroundingTilesPositions[i], surroundingTilesPositions[i + 1]));
            }

            var positionsAroundCenter = GetPositionsAroundCenter(trainingInstanceController, 5, 2);

            Assert.True(surroundingTilePositionTuples.Any(x => x == positionsAroundCenter[0]));
            Assert.True(surroundingTilePositionTuples.Any(x => x == positionsAroundCenter[1]));
            Assert.True(surroundingTilePositionTuples.Any(x => x == positionsAroundCenter[2]));
            Assert.True(surroundingTilePositionTuples.Any(x => x == positionsAroundCenter[3]));
            Assert.True(surroundingTilePositionTuples.Any(x => x == positionsAroundCenter[4]));
            Assert.True(surroundingTilePositionTuples.Any(x => x == positionsAroundCenter[5]));
            Assert.True(surroundingTilePositionTuples.Any(x => x == positionsAroundCenter[6]));
            Assert.True(surroundingTilePositionTuples.Any(x => x == positionsAroundCenter[7]));
        }
示例#2
0
        public void DisposeAgents_FromKernel()
        {
            // Arrange
            var spyAgent = new SpyAgent();
            var kernel   = new Kernel(new[] { spyAgent }, StubConfig.Default);

            // Act
            kernel.Dispose();

            // Assert
            Assert.True(spyAgent.IsDisposed);
        }
示例#3
0
        public async Task FailToStartAgents_IfConfigIsntInitializedYet()
        {
            // Arrange
            var spyAgent = new SpyAgent();
            var config   = Mock.Of <IConfig>();

            Assert.False(config.IsInitialized);

            var kernel = new Kernel(new[] { spyAgent }, config);

            // Act
            await kernel.StartAsync(CancellationToken.None);

            // Assert
            Assert.False(spyAgent.HasStarted);
        }
示例#4
0
        public async Task StartAgents_FromKernel()
        {
            // Arrange
            var spyAgent           = new SpyAgent();
            var kernel             = new Kernel(new[] { spyAgent }, StubConfig.Default);
            var cancellationSource = new CancellationTokenSource();

            // Act
            await kernel.StartAsync(cancellationSource.Token);

            // Assert
            Assert.True(spyAgent.HasStarted);

            // TearDown
            cancellationSource.Cancel();
        }