Skip to content

Commit

Permalink
Add/Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zubairhamed committed Apr 24, 2016
1 parent 6100aa1 commit 66eee19
Showing 1 changed file with 34 additions and 38 deletions.
72 changes: 34 additions & 38 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
func TestParseInfoModel(t *testing.T) {
m := ParseFile("./testresources/TI_SensorTag_CC2650.infomodel")

assert.NotNil(t, m)

assert.Equal(t, "examples.informationmodels.sensors", m.Namespace)
assert.Equal(t, "1.0.0", m.Version)
assert.Equal(t, "TI SensorTag CC2650", m.Displayname)
Expand All @@ -19,49 +21,27 @@ func TestParseInfoModel(t *testing.T) {
assert.Equal(t, "examples.functionblockmodels.sensors.HumiditySensor ; 1.0.0", m.Using[2])
assert.Equal(t, "examples.functionblockmodels.sensors.PressureSensor ; 1.0.0", m.Using[3])

// assert.Equal(t, "TI_SensorTag_CC2650", m.InfoModel.name)
// assert.Equal(t, 4, len(m.InfoModel.functionBlocks))

//accelerometer
//m.InfoModel.functionBlocks[0].name
//
//Accelerometer
//m.InfoModel.functionBlocks[0].fbType
//
//Function block representing the accelerometer of the device.
//m.InfoModel.functionBlocks[0].description
//
//temperaturesensor
//m.InfoModel.functionBlocks[0].name
//
//TemperatureSensor
//m.InfoModel.functionBlocks[0].fbType
//
//Function block representing the temperature sensor of the device.
//m.InfoModel.functionBlocks[0].description
//
//humiditysensor
//m.InfoModel.functionBlocks[0].name
//
//HumiditySensor
//m.InfoModel.functionBlocks[0].fbType
//
//Function block representing the humidity sensor of the device.
//m.InfoModel.functionBlocks[0].description
//
//pressuresensor
//m.InfoModel.functionBlocks[0].name
//
//PressureSensor
//m.InfoModel.functionBlocks[0].fbType
//
//Function block representing the pressure sensor of the device.
//m.InfoModel.functionBlocks[0].description
assert.Equal(t, "TI_SensorTag_CC2650", m.InfoModel.Name)
assert.Equal(t, 4, len(m.InfoModel.FunctionBlocks))
assert.Equal(t, "accelerometer", m.InfoModel.FunctionBlocks[0].Name)
assert.Equal(t, "Accelerometer", m.InfoModel.FunctionBlocks[0].DataType)
assert.Equal(t, "Function block representing the accelerometer of the device.", m.InfoModel.FunctionBlocks[0].Description)
assert.Equal(t, "temperaturesensor", m.InfoModel.FunctionBlocks[1].Name)
assert.Equal(t, "TemperatureSensor", m.InfoModel.FunctionBlocks[1].DataType)
assert.Equal(t, "Function block representing the temperature sensor of the device.", m.InfoModel.FunctionBlocks[1].Description)
assert.Equal(t, "humiditysensor", m.InfoModel.FunctionBlocks[2].Name)
assert.Equal(t, "HumiditySensor", m.InfoModel.FunctionBlocks[2].DataType)
assert.Equal(t, "Function block representing the humidity sensor of the device.", m.InfoModel.FunctionBlocks[2].Description)
assert.Equal(t, "pressuresensor", m.InfoModel.FunctionBlocks[3].Name)
assert.Equal(t, "PressureSensor", m.InfoModel.FunctionBlocks[3].DataType)
assert.Equal(t, "Function block representing the pressure sensor of the device.", m.InfoModel.FunctionBlocks[3].Description)
}

func TestParseFunctionBlock(t *testing.T) {
m := ParseFile("./testresources/Battery.fbmodel")

assert.NotNil(t, m)

assert.Equal(t, "examples.functionblockmodels.metering", m.Namespace)
assert.Equal(t, "1.0.0", m.Version)
assert.Equal(t, "Battery", m.Displayname)
Expand Down Expand Up @@ -92,5 +72,21 @@ func TestParseFunctionBlock(t *testing.T) {
}

func TestParseDataType(t *testing.T) {
m := ParseFile("./testresources/DoorState.type")

assert.NotNil(t, m)

assert.Equal(t, "examples.datatypes.state", m.Namespace)
assert.Equal(t, "1.0.0", m.Version)
assert.Equal(t, "Enum for describing the state of a door.", m.Description)

assert.Equal(t, "DoorState", m.DataType.Name)
assert.Equal(t, "open", m.DataType.Fields[0].Name)
assert.Equal(t, "The door is open.", m.DataType.Fields[0].Description)

assert.Equal(t, "closed", m.DataType.Fields[1].Name)
assert.Equal(t, "The door is closed.", m.DataType.Fields[1].Description)

assert.Equal(t, "undefined", m.DataType.Fields[2].Name)
assert.Equal(t, "The status is not known.", m.DataType.Fields[2].Description)
}

0 comments on commit 66eee19

Please sign in to comment.