@@ -206,6 +206,50 @@ func TestPlayer_IsAirborne(t *testing.T) {
206206 assert .True (t , pl .IsAirborne ())
207207}
208208
209+ func TestPlayer_IsControllingBot_NilEntity (t * testing.T ) {
210+ pl := new (Player )
211+
212+ assert .False (t , pl .IsControllingBot ())
213+ }
214+
215+ func TestPlayer_IsControllingBot (t * testing.T ) {
216+ pl := playerWithProperty ("m_bIsControllingBot" , st.PropertyValue {IntVal : 0 })
217+
218+ assert .False (t , pl .IsControllingBot ())
219+
220+ pl = playerWithProperty ("m_bIsControllingBot" , st.PropertyValue {IntVal : 1 })
221+
222+ assert .True (t , pl .IsControllingBot ())
223+ }
224+
225+ func TestPlayer_ControlledBot_NilEntity (t * testing.T ) {
226+ pl := new (Player )
227+
228+ assert .Nil (t , pl .ControlledBot ())
229+ }
230+
231+ func TestPlayer_ControlledBot (t * testing.T ) {
232+ dave := & Player {
233+ Name : "Dave" ,
234+ IsBot : true ,
235+ }
236+ demoInfoProvider := & demoInfoProviderMock {
237+ playersByHandle : map [int ]* Player {
238+ 12 : dave ,
239+ },
240+ }
241+
242+ pl := playerWithProperty ("m_iControlledBotEntIndex" , st.PropertyValue {IntVal : 0 })
243+ pl .demoInfoProvider = demoInfoProvider
244+
245+ assert .Nil (t , pl .ControlledBot ())
246+
247+ pl = playerWithProperty ("m_iControlledBotEntIndex" , st.PropertyValue {IntVal : 12 })
248+ pl .demoInfoProvider = demoInfoProvider
249+
250+ assert .Same (t , dave , pl .ControlledBot ())
251+ }
252+
209253func newPlayer (tick int ) * Player {
210254 return NewPlayer (mockDemoInfoProvider (128 , tick ))
211255}
0 commit comments