@@ -125,13 +125,8 @@ func TestPlayer_FlashDurationTimeRemaining_Fallback(t *testing.T) {
125125}
126126
127127func TestPlayer_IsSpottedBy_HasSpotted_True (t * testing.T ) {
128- pl := newPlayer (0 )
129- entity := new (fake.Entity )
130- pl .Entity = entity
128+ pl := playerWithProperty ("m_bSpottedByMask.000" , sendtables.PropertyValue {IntVal : 2 })
131129 pl .EntityID = 1
132- prop := new (fake.Property )
133- prop .On ("Value" ).Return (sendtables.PropertyValue {IntVal : 2 })
134- entity .On ("FindPropertyI" , "m_bSpottedByMask.000" ).Return (prop )
135130
136131 other := newPlayer (0 )
137132 other .EntityID = 2
@@ -141,13 +136,8 @@ func TestPlayer_IsSpottedBy_HasSpotted_True(t *testing.T) {
141136}
142137
143138func TestPlayer_IsSpottedBy_HasSpotted_False (t * testing.T ) {
144- pl := newPlayer (0 )
145- entity := new (fake.Entity )
146- pl .Entity = entity
139+ pl := playerWithProperty ("m_bSpottedByMask.000" , sendtables.PropertyValue {IntVal : 0 })
147140 pl .EntityID = 1
148- prop := new (fake.Property )
149- prop .On ("Value" ).Return (sendtables.PropertyValue {IntVal : 0 })
150- entity .On ("FindPropertyI" , "m_bSpottedByMask.000" ).Return (prop )
151141
152142 other := newPlayer (0 )
153143 other .EntityID = 2
@@ -157,12 +147,7 @@ func TestPlayer_IsSpottedBy_HasSpotted_False(t *testing.T) {
157147}
158148
159149func TestPlayer_IsSpottedBy_HasSpotted_BitOver32 (t * testing.T ) {
160- pl := newPlayer (0 )
161- entity := new (fake.Entity )
162- prop := new (fake.Property )
163- prop .On ("Value" ).Return (sendtables.PropertyValue {IntVal : 1 })
164- entity .On ("FindPropertyI" , "m_bSpottedByMask.001" ).Return (prop )
165- pl .Entity = entity
150+ pl := playerWithProperty ("m_bSpottedByMask.001" , sendtables.PropertyValue {IntVal : 1 })
166151 pl .EntityID = 1
167152
168153 other := newPlayer (0 )
@@ -182,10 +167,55 @@ func TestPlayer_IsSpottedBy_EntityNull(t *testing.T) {
182167 assert .False (t , other .HasSpotted (pl ))
183168}
184169
170+ func TestPlayer_IsInBombZone (t * testing.T ) {
171+ pl := playerWithProperty ("m_bInBombZone" , sendtables.PropertyValue {IntVal : 1 })
172+
173+ assert .True (t , pl .IsInBombZone ())
174+ }
175+
176+ func TestPlayer_IsInBuyZone (t * testing.T ) {
177+ pl := playerWithProperty ("m_bInBuyZone" , sendtables.PropertyValue {IntVal : 1 })
178+
179+ assert .True (t , pl .IsInBuyZone ())
180+ }
181+
182+ func TestPlayer_IsWalking (t * testing.T ) {
183+ pl := playerWithProperty ("m_bIsWalking" , sendtables.PropertyValue {IntVal : 1 })
184+
185+ assert .True (t , pl .IsWalking ())
186+ }
187+
188+ func TestPlayer_IsScoped (t * testing.T ) {
189+ pl := playerWithProperty ("m_bIsScoped" , sendtables.PropertyValue {IntVal : 1 })
190+
191+ assert .True (t , pl .IsScoped ())
192+ }
193+
194+ func TestPlayer_CashSpentThisRound (t * testing.T ) {
195+ pl := playerWithProperty ("m_iCashSpentThisRound" , sendtables.PropertyValue {IntVal : 500 })
196+
197+ assert .Equal (t , 500 , pl .CashSpentThisRound ())
198+ }
199+
200+ func TestPlayer_CashSpentTotal (t * testing.T ) {
201+ pl := playerWithProperty ("m_iTotalCashSpent" , sendtables.PropertyValue {IntVal : 500 })
202+
203+ assert .Equal (t , 500 , pl .CashSpentTotal ())
204+ }
205+
185206func newPlayer (tick int ) * Player {
186207 return NewPlayer (128 , tickProvider (tick ))
187208}
188209
189210func tickProvider (tick int ) ingameTickProvider {
190211 return func () int { return tick }
191212}
213+
214+ func playerWithProperty (propName string , value sendtables.PropertyValue ) * Player {
215+ entity := new (fake.Entity )
216+ prop := new (fake.Property )
217+ prop .On ("Value" ).Return (value )
218+ entity .On ("FindPropertyI" , propName ).Return (prop )
219+ pl := & Player {Entity : entity }
220+ return pl
221+ }
0 commit comments