@@ -132,26 +132,28 @@ func TestSetmethods(t *testing.T) {
132132 Value : 23.7 ,
133133 }
134134
135- // Call the setMin_temp function
135+ //call and test min_temp
136136 asset .setMin_temp (MinTemp_inputSignal )
137- asset .setMax_temp (MaxTemp_inputSignal )
138- asset .setMin_price (MinPrice_inputSignal )
139- asset .setMax_price (MaxPrice_inputSignal )
140- asset .setDesired_temp (DesTemp_inputSignal )
141-
142- // check if the temprature has changed correctly
143137 if asset .Min_temp != 1.0 {
144138 t .Errorf ("expected Min_temp to be 1.0, got %f" , asset .Min_temp )
145139 }
140+ // call and test max_temp
141+ asset .setMax_temp (MaxTemp_inputSignal )
146142 if asset .Max_temp != 29.0 {
147143 t .Errorf ("expected Max_temp to be 25.0, got %f" , asset .Max_temp )
148144 }
145+ //call and test Min_price
146+ asset .setMin_price (MinPrice_inputSignal )
149147 if asset .Min_price != 2.0 {
150148 t .Errorf ("expected Min_Price to be 2.0, got %f" , asset .Min_price )
151149 }
150+ //call and test Max_price
151+ asset .setMax_price (MaxPrice_inputSignal )
152152 if asset .Max_price != 12.0 {
153153 t .Errorf ("expected Max_Price to be 12.0, got %f" , asset .Max_price )
154154 }
155+ // call and test Desired_temp
156+ asset .setDesired_temp (DesTemp_inputSignal )
155157 if asset .Desired_temp != 23.7 {
156158 t .Errorf ("expected Desierd temprature is to be 23.7, got %f" , asset .Desired_temp )
157159 }
@@ -161,16 +163,10 @@ func TestSetmethods(t *testing.T) {
161163func Test_GetMethods (t * testing.T ) {
162164
163165 uasset := initTemplate ().(* UnitAsset )
164- //call the fuctions
165- result := uasset .getMin_temp ()
166- result2 := uasset .getMax_temp ()
167- result3 := uasset .getMin_price ()
168- result4 := uasset .getMax_price ()
169- result5 := uasset .getDesired_temp ()
170- result6 := uasset .getSEK_price ()
171166
172167 ////MinTemp////
173168 // check if the value from the struct is the acctual value that the func is getting
169+ result := uasset .getMin_temp ()
174170 if result .Value != uasset .Min_temp {
175171 t .Errorf ("expected Value of the min_temp is to be %v, got %v" , uasset .Min_temp , result .Value )
176172 }
@@ -180,6 +176,7 @@ func Test_GetMethods(t *testing.T) {
180176
181177 }
182178 ////MaxTemp////
179+ result2 := uasset .getMax_temp ()
183180 if result2 .Value != uasset .Max_temp {
184181 t .Errorf ("expected Value of the Max_temp is to be %v, got %v" , uasset .Max_temp , result2 .Value )
185182 }
@@ -189,6 +186,7 @@ func Test_GetMethods(t *testing.T) {
189186 }
190187 ////MinPrice////
191188 // check if the value from the struct is the acctual value that the func is getting
189+ result3 := uasset .getMin_price ()
192190 if result3 .Value != uasset .Min_price {
193191 t .Errorf ("expected Value of the minPrice is to be %v, got %v" , uasset .Min_price , result3 .Value )
194192 }
@@ -199,6 +197,7 @@ func Test_GetMethods(t *testing.T) {
199197
200198 ////MaxPrice////
201199 // check if the value from the struct is the acctual value that the func is getting
200+ result4 := uasset .getMax_price ()
202201 if result4 .Value != uasset .Max_price {
203202 t .Errorf ("expected Value of the maxPrice is to be %v, got %v" , uasset .Max_price , result4 .Value )
204203 }
@@ -208,6 +207,7 @@ func Test_GetMethods(t *testing.T) {
208207 }
209208 ////DesierdTemp////
210209 // check if the value from the struct is the acctual value that the func is getting
210+ result5 := uasset .getDesired_temp ()
211211 if result5 .Value != uasset .Desired_temp {
212212 t .Errorf ("expected desired temprature is to be %v, got %v" , uasset .Desired_temp , result5 .Value )
213213 }
@@ -216,23 +216,28 @@ func Test_GetMethods(t *testing.T) {
216216 t .Errorf ("expected Unit to be 'Celsius', got %v" , result5 .Unit )
217217 }
218218 ////SEK_Price////
219+ result6 := uasset .getSEK_price ()
219220 if result6 .Value != uasset .SEK_price {
220221 t .Errorf ("expected electric price is to be %v, got %v" , uasset .SEK_price , result6 .Value )
221222 }
222223}
223224
224225func Test_initTemplet (t * testing.T ) {
225226 uasset := initTemplate ().(* UnitAsset )
226-
227- name := uasset .GetName ()
228- Services := uasset .GetServices ()
229- Cervices := uasset .GetCervices ()
230- Details := uasset .GetDetails ()
227+ /*
228+ name := uasset.GetName()
229+ Services := uasset.GetServices()
230+ Cervices := uasset.GetCervices()
231+ Details := uasset.GetDetails()
232+ */
231233
232234 //// unnecessary test, but good for practicing
235+
236+ name := uasset .GetName ()
233237 if name != "Set Values" {
234238 t .Errorf ("expected name of the resource is %v, got %v" , uasset .Name , name )
235239 }
240+ Services := uasset .GetServices ()
236241 if Services == nil {
237242 t .Fatalf ("If Services is nil, not worth to continue testing" )
238243 }
@@ -256,10 +261,12 @@ func Test_initTemplet(t *testing.T) {
256261 t .Errorf ("expected service defenition to be desired_temp" )
257262 }
258263 //GetCervice//
264+ Cervices := uasset .GetCervices ()
259265 if Cervices != nil {
260266 t .Fatalf ("If cervises not nil, not worth to continue testing" )
261267 }
262268 //Testing Details//
269+ Details := uasset .GetDetails ()
263270 if Details == nil {
264271 t .Errorf ("expected a map, but Details was nil, " )
265272 }
0 commit comments