Exemplo n.º 1
0
        public async Task CanSaveWorldSnapshot()
        {
            var world = RandomWorld(4);

            var fileWorldStateSaver = new FileWorldStateSaver(_filePathBuilder);
            await fileWorldStateSaver.SaveAsync(world, SimulationId);
        }
Exemplo n.º 2
0
        public async Task Create_particles_triangular_random_benchmark_world_init_state()
        {
            var simulationId = "particles_triangular_random_init_state";

            DeleteSimulationSnapshotsFile(simulationId);

            const string filePath             = "Importers/particles_triangular_random.tsv";
            const string dataSeparator        = "\t";
            var          particlesCsvImporter = new ParticlesImporter();
            var          particles            = particlesCsvImporter.Import(filePath, dataSeparator);

            var rigidWalls = new[]
            {
                new RigidWall(new Vector2(-200, -200), new Vector2(250, -200)), //top
                new RigidWall(new Vector2(250, -200), new Vector2(200, 200)),   //right
                new RigidWall(new Vector2(200, 200), new Vector2(-200, 200)),   //bottom
                new RigidWall(new Vector2(-200, 200), new Vector2(-200, -200)), //left
            };
            var world = new World(particles, rigidWalls, 0);

            await _fileWorldStateSaver.SaveAsync(world, simulationId);
        }
Exemplo n.º 3
0
        public async Task CanLoadWorldSnapshot()
        {
            // arrange
            var world = RandomWorld(4);
            var fileWorldStateSaver = new FileWorldStateSaver(_filePathBuilder);
            await fileWorldStateSaver.SaveAsync(world, SimulationId);

            var fileWorldStateLoader = new FileWorldStateLoader(_filePathBuilder);

            // act
            var snapshot = fileWorldStateLoader.First(SimulationId);

            // assert
            var snapshotAsJson      = JsonConvert.SerializeObject(snapshot);
            var expectedWorldAsJson = JsonConvert.SerializeObject(world);

            snapshotAsJson.Should().Be(expectedWorldAsJson);
        }