Skip to content
This repository has been archived by the owner on Mar 24, 2018. It is now read-only.

Commit

Permalink
Technical debt for universe package
Browse files Browse the repository at this point in the history
- added unit tests
  • Loading branch information
dertseha committed Nov 1, 2014
1 parent 403fc69 commit 7d2859a
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions universe/SolarSystemExtension_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package universe

import (
"math/rand"
"time"

check "gopkg.in/check.v1"
)

type SolarSystemExtensionTestSuite struct {
id Id
constellationId Id
regionId Id
galaxyId GalaxyId
location Location
security TrueSecurity

system SolarSystem
extension *SolarSystemExtension
}

var _ = check.Suite(&SolarSystemExtensionTestSuite{})

func (suite *SolarSystemExtensionTestSuite) SetUpTest(c *check.C) {
random := rand.New(rand.NewSource(time.Now().UnixNano()))

suite.id = Id(random.Int63())
suite.constellationId = Id(random.Int63())
suite.regionId = Id(random.Int63())
suite.galaxyId = GalaxyId(random.Int63())
suite.location = NewSpecificLocation(random.Float64(), random.Float64(), random.Float64())
suite.security = TrueSecurity((random.Intn(201) - 100) / 100.0)

suite.system = newSolarSystem(suite.id, suite.constellationId, suite.regionId, suite.galaxyId, suite.location, suite.security)
suite.extension = &SolarSystemExtension{newSolarSystemExtensionData(suite.system)}
}
func (suite *SolarSystemExtensionTestSuite) TestIdReturnsSolarSystemId(c *check.C) {
c.Assert(suite.extension.Id(), check.Equals, suite.id)
}

func (suite *SolarSystemExtensionTestSuite) TestGalaxyIdReturnsGalaxyId(c *check.C) {
c.Assert(suite.extension.GalaxyId(), check.Equals, suite.galaxyId)
}

func (suite *SolarSystemExtensionTestSuite) TestLocationReturnsLocation(c *check.C) {
c.Assert(suite.extension.Location(), check.Equals, suite.location)
}

func (suite *SolarSystemExtensionTestSuite) TestSecurityReturnsSecurity(c *check.C) {
c.Assert(suite.extension.Security(), check.Equals, suite.security)
}

0 comments on commit 7d2859a

Please sign in to comment.