"""Unit test for mass3d.py"""

from mass3d import *
import unittest

class TestMass3D(unittest.TestCase):
    def setUp(self):
        self.mass3d = Mass3D()

    def test_default(self):
        """Tests that default values for member variables are set."""
        self.assertEqual(self.mass3d.id, "mass")
        self.assertEqual(self.mass3d.fixed, False)
        self.assertEqual(self.mass3d.position, (0, 0, 0))
        self.assertEqual(self.mass3d.mass, 0)
        self.assertEqual(self.mass3d.frequency, 0)
        self.assertEqual(self.mass3d.size, 0)

    def test_creation(self):
        """Tests that msd creation messages are sent correctly."""
        self.mass3d.id = "testMass"
        self.mass3d.fixed = False
        self.mass3d.mass = 20
        self.mass3d.position = (1, 1, 1)
        self.assertEqual(self.mass3d.get_msd_setup_message(),
                            "mass testMass 1 20 1 1 1")
        
        self.mass3d.id ="notherName"
        self.mass3d.fixed = True
        self.assertEqual(self.mass3d.get_msd_setup_message(),
                            "mass notherName 0 20 1 1 1")
    
    def test_creation_negative(self):
        """Tests that creation messages with negative numbers are ok."""
        self.mass3d.id = "thirdName"
        self.mass3d.fixed = False
        self.mass3d.mass = 150
        self.mass3d.position = (-50, 10, -100)
        self.assertEqual(self.mass3d.get_msd_setup_message(),
                            "mass thirdName 1 150 -50 10 -100")
                            
    def test_creation_some_defaults(self):
        """Tests that creation messages when some defaults are changed."""
        self.mass3d.fixed = True
        self.mass3d.position = (-50, 10, -100)
        self.assertEqual(self.mass3d.get_msd_setup_message(),
                            "mass mass 0 0 -50 10 -100")
        
    
if __name__ == '__main__':
    unittest.main()