"""Unit test for linkedcircle.py"""

from linkedcircle import LinkedCircle
import unittest

class TestLinkedCircle(unittest.TestCase):

    def test_create_structure(self):
        """Test creation of basic linked circle"""
    
        c = LinkedCircle()
        c.diameter = 4
        c.mass_count = 12
        c.mass = 20
        c.link_rigidity = 4
        c.link_damping = 2

        c.create_linked_circle()
        
        """expected_messages = ["mass fixed-mass 0 20 2.0 0 0", 
            "mass fixed-mass 0 20 1.73205080757 1.0 0",
            "mass fixed-mass 0 20 1.0 1.73205080757 0",
            "mass fixed-mass 0 20 0 2.0 0",
            "mass fixed-mass 0 20 -1.0 1.73205080757 0",
            "mass fixed-mass 0 20 -1.73205080757 1.0 0",
            "mass fixed-mass 0 20 -2.0 0 0",
            "mass fixed-mass 0 20 -1.73205080757 -1.0 0",
            "mass fixed-mass 0 20 -1.0 -1.73205080757 0",
            "mass fixed-mass 0 20 0 -2.0 0",
            "mass fixed-mass 0 20 1.0 -1.73205080757 0",
            "mass fixed-mass 0 20 1.73205080757 -1.0 0",
            "mass floating-mass 1 20 2.0 0 0",
            "mass floating-mass 1 20 1.73205080757 1.0 0",
            "mass floating-mass 1 20 1.0 1.73205080757 0",
            "mass floating-mass 1 20 0 2.0 0",
            "mass floating-mass 1 20 -1.0 1.73205080757 0",
            "mass floating-mass 1 20 -1.73205080757 1.0 0",
            "mass floating-mass 1 20 -2.0 0 0",
            "mass floating-mass 1 20 -1.73205080757 -1.0 0",
            "mass floating-mass 1 20 -1.0 -1.73205080757 0",
            "mass floating-mass 1 20 0 -2.0 0",
            "mass floating-mass 1 20 1.0 -1.73205080757 0",
            "mass floating-mass 1 20 1.73205080757 -1.0 0"]
            """
            
        expected_messages = ['mass fixed-mass 0 20 0 2.0 0', 'mass fixed-mass 0 20 1.0 1.73205080757 0', 'mass fixed-mass 0 20 1.73205080757 1.0 0', 'mass fixed-mass 0 20 2.0 0 0', 'mass fixed-mass 0 20 1.73205080757 -1.0 0', 'mass fixed-mass 0 20 1.0 -1.73205080757 0', 'mass fixed-mass 0 20 0 -2.0 0', 'mass fixed-mass 0 20 -1.0 -1.73205080757 0', 'mass fixed-mass 0 20 -1.73205080757 -1.0 0', 'mass fixed-mass 0 20 -2.0 0 0', 'mass fixed-mass 0 20 -1.73205080757 1.0 0', 'mass fixed-mass 0 20 -1.0 1.73205080757 0', 'mass floating-mass 1 20 0 2.0 0', 'mass floating-mass 1 20 1.0 1.73205080757 0', 'mass floating-mass 1 20 1.73205080757 1.0 0', 'mass floating-mass 1 20 2.0 0 0', 'mass floating-mass 1 20 1.73205080757 -1.0 0', 'mass floating-mass 1 20 1.0 -1.73205080757 0', 'mass floating-mass 1 20 0 -2.0 0', 'mass floating-mass 1 20 -1.0 -1.73205080757 0', 'mass floating-mass 1 20 -1.73205080757 -1.0 0', 'mass floating-mass 1 20 -2.0 0 0', 'mass floating-mass 1 20 -1.73205080757 1.0 0', 'mass floating-mass 1 20 -1.0 1.73205080757 0']
            
        self.assertEqual(c.get_mass_setup_messages(), expected_messages)
        
        expected_messages = ["link link 0 12 4 2",
            "link link 12 13 4 2",
            "link link 1 13 4 2",
            "link link 13 14 4 2",
            "link link 2 14 4 2",
            "link link 14 15 4 2",
            "link link 3 15 4 2",
            "link link 15 16 4 2",
            "link link 4 16 4 2",
            "link link 16 17 4 2",
            "link link 5 17 4 2",
            "link link 17 18 4 2",
            "link link 6 18 4 2",
            "link link 18 19 4 2",
            "link link 7 19 4 2",
            "link link 19 20 4 2",
            "link link 8 20 4 2",
            "link link 20 21 4 2",
            "link link 9 21 4 2",
            "link link 21 22 4 2",
            "link link 10 22 4 2",
            "link link 22 23 4 2",
            "link link 11 23 4 2",
            "link link 23 12 4 2",
            "link collision-link floating-mass floating-mass 0.05 0"]
            
        self.assertEqual(c.get_link_setup_messages(), expected_messages)

if __name__ == "__main__":
    unittest.main()
