Пример #1
0
    def test_get_next_down(self):

        # Initialize parameters
        up_percentage = 0
        down_percentage = 100
        no_change_percentage = 0

        # Create particle fall settings
        particle_fall_settings = particleframework.ParticleFallSettings(
            up_percentage,
            down_percentage,
            no_change_percentage
        )

        # Verify the next direction
        next_fall = particle_fall_settings.get_next()
        self.assertEqual(next_fall, particleframework.Fall.DOWN)
Пример #2
0
    def test_sum_too_small(self):

        # Initialize parameters
        up_percentage = 10
        down_percentage = 20
        no_change_percentage = 10

        # Create particle fall settings
        try:
            particle_fall_settings = particleframework.ParticleFallSettings(
                up_percentage,
                down_percentage,
                no_change_percentage
            )
            self.fail()
        except Exception as e:
            self.assertIsNotNone(e)
Пример #3
0
    def test_fall(self):

        # Create particle fall settings to force downward wind
        particle_fall_settings = particleframework.ParticleFallSettings(
            0, 100, 0)

        # Initialize building height
        building_height = 10

        # Create test particle
        particle = ParticleTestCase.create_particle(
            particle_fall_settings=particle_fall_settings,
            building_height=building_height)

        # Move the particle
        particle.fall()

        # Verify particle movement
        self.assertEqual(particle._height, building_height - 1)
Пример #4
0
    def test_init(self):

        # Initialize parameters
        up_percentage = 10
        down_percentage = 20
        no_change_percentage = 70

        # Create particle fall settings
        particle_fall_settings = particleframework.ParticleFallSettings(
            up_percentage,
            down_percentage,
            no_change_percentage
        )

        # Verify the particle fall settings
        self.assertIsNotNone(particle_fall_settings)
        self.assertEqual(particle_fall_settings.up_percentage, up_percentage)
        self.assertEqual(particle_fall_settings.down_percentage, down_percentage)
        self.assertEqual(particle_fall_settings.no_change_percentage, no_change_percentage)
Пример #5
0
    def test_fall_on_ground(self):

        # Create particle fall settings to force downward wind
        particle_fall_settings = particleframework.ParticleFallSettings(
            0, 100, 0)

        # Initialize building height
        building_height = 0

        # Create test particle
        particle = ParticleTestCase.create_particle(
            particle_fall_settings=particle_fall_settings,
            building_height=building_height)

        self.assertFalse(particle.can_fall())

        # Attempt to move the particle
        particle.fall()

        # Verify no particle movement
        self.assertEqual(particle._height, building_height)
Пример #6
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Particle unit tests

@author: Anthony Jarrett
"""

import unittest

from python.src.simulation import particleframework

# Initialize test parameters
TEST_PARTICLE_FALL_SETTINGS = particleframework.ParticleFallSettings()
TEST_WIND_SETTINGS = particleframework.WindSettings()
TEST_POSITION = particleframework.Position(1, 2)
TEST_BUILDING_HEIGHT = 12


class ParticleTestCase(unittest.TestCase):
    def test_init(self):

        # Create test particle
        particle = ParticleTestCase.create_particle()

        # Verify particle state
        self.assertIsNotNone(particle)
        self.assertTrue(
            particle._particle_fall_settings.equals(
                TEST_PARTICLE_FALL_SETTINGS))
        self.assertTrue(particle._wind_settings.equals(TEST_WIND_SETTINGS))