Beispiel #1
0
    /*
     * private async void RequestCellData()
     * {
     *  var streamingstuff = Client.GetWorldCells(WorldRequest);
     *  while (await streamingstuff.ResponseStream.MoveNext())
     *  {
     *      Cell cell = streamingstuff.ResponseStream.Current;
     *      // add to list of all cells
     *      WorldVisualizer.AddCell(cell);
     *  }
     *  WorldVisualizer.RedrawMesh();
     * }
     *
     * private void RequestNodeData()
     * {
     *
     * }
     */

    private double GetWorldResultQuantity(WorldGenerationResult result, string quantityName)
    {
        foreach (var quantity in result.World.Quantities)
        {
            if (quantity.Key.Name.Equals(quantityName))
            {
                return(quantity.Value);
            }
        }
        return(0.0);
    }
Beispiel #2
0
        public void RandomGeneration_CorrectInput_ReturnsGeneration(int rows, int columns) // method to test RandomGeneration()
        {
            // Arrange
            WorldGenerator worldGenerator = new WorldGenerator(); // create new object of worldGenerator
            WorldSize      worldSize      = new WorldSize
            {
                Rows    = rows,   // sets value for rows property in worldSize object
                Columns = columns // sets value for columns property in worldSize object
            };                    // create object of worldSize

            // Act
            WorldGenerationResult result = worldGenerator.RandomGeneration(worldSize); // execute method RandomGeneration() in worldGenerator object with worldSize parameter and save it to result

            // Assert
            var actualWorldSize           = result.Generation.WorldSize();
            var expectedLifeCells         = result.Generation.LifesCount();
            var expectedIsGenerationAlive = expectedLifeCells > 0;

            Assert.Equal(rows, actualWorldSize.Rows);
            Assert.Equal(columns, actualWorldSize.Columns);
            Assert.Equal(expectedLifeCells, result.AliveCells);
            Assert.Equal(expectedIsGenerationAlive, result.IsGenerationAlive);
        }