"""Unit test for link3d.py"""

from link3d import *
import unittest

class TestLink3D(unittest.TestCase):
    def setUp(self):
         self.link3d = Link3D()

    def test_default(self):
        """Tests that default values for member variables are set."""
        self.assertEqual(self.link3d.id, "link")
        self.assertEqual(self.link3d.mass1_id, "0")
        self.assertEqual(self.link3d.mass2_id, "0")
        self.assertEqual(self.link3d.rigidity, 0)
        self.assertEqual(self.link3d.damping, 0)
        self.assertEqual(self.link3d.distance_exponent, 1)
        self.assertEqual(self.link3d.min_length, 0)
        self.assertEqual(self.link3d.max_length, 0)
       
    def test_default_creation(self):
        """Tests that msd creation messages are sent correctly
        for default state."""
        self.assertEqual(self.link3d.get_msd_setup_message(),
            "link link 0 0 0 0")
    def test_non_default_creation(self):
        """Tests that creation messages are ok for non default state."""
        self.link3d.id = "someLinkName"
        self.link3d.mass1_id = 22
        self.link3d.mass2_id = 33
        self.link3d.rigidity = 4
        self.link3d.damping = 2
        self.assertEqual(self.link3d.get_msd_setup_message(),
            "link someLinkName 22 33 4 2")
            
    def test_complex_non_default_creation(self):
        """Tests that creation messages are ok for non default state."""
        self.link3d.id = "someLinkName"
        self.link3d.mass1_id = 22
        self.link3d.mass2_id = 33
        self.link3d.rigidity = 4
        self.link3d.damping = 2
        self.link3d.distance_exponent = 3
        self.assertEqual(self.link3d.get_msd_setup_message(),
            "link someLinkName 22 33 4 2 3")

        self.link3d.min_length = 100
        self.assertEqual(self.link3d.get_msd_setup_message(),
            "link someLinkName 22 33 4 2 3 100")
        self.link3d.max_length = 200
        self.assertEqual(self.link3d.get_msd_setup_message(),
            "link someLinkName 22 33 4 2 3 100 200")
            
    def test_more_complex_non_default_creation(self):
        """Tests that setting parameters later in creation arguments does not
        screw up earlier ones"""
        self.link3d.id = "someLinkName"
        self.link3d.mass1_id = 22
        self.link3d.mass2_id = 33
        self.link3d.rigidity = 4
        self.link3d.damping = 2
        self.link3d.max_length = 3
        
        self.assertEqual(self.link3d.get_msd_setup_message(),
            "link someLinkName 22 33 4 2 1 0 3")
            
    def test_non_numerical_creation(self):
        """Tests that setting parameters later in creation arguments does not
        screw up earlier ones"""
        self.link3d.id = "someLinkName"
        self.link3d.mass1_id = "someMass"
        self.link3d.mass2_id = "someOtherMass"
        self.link3d.rigidity = 4
        self.link3d.damping = 2
        self.link3d.max_length = 3
        
        self.assertEqual(self.link3d.get_msd_setup_message(),
            "link someLinkName someMass someOtherMass 4 2 1 0 3")
        

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