@@ -416,5 +416,38 @@ public void WhenStaleDataArrivesToReanticipatedVariable_ItIsAppliedAndReanticipa
416416 Assert . AreEqual ( 25 , otherClientComponent . ReanticipateOnAnticipationFailVariable . Value ) ;
417417 Assert . AreEqual ( 20 , otherClientComponent . ReanticipateOnAnticipationFailVariable . AuthoritativeValue ) ;
418418 }
419+
420+ private int m_PreviousSnapValue ;
421+ /// <summary>
422+ /// Validates the previous value is being properly updated on the non-authoritative side.
423+ /// </summary>
424+ [ Test ]
425+ public void PreviousValueIsMaintainedProperly ( )
426+ {
427+ var testComponent = GetTestComponent ( ) ;
428+
429+ testComponent . SnapOnAnticipationFailVariable . OnAuthoritativeValueChanged += OnAuthoritativeValueChanged ;
430+ testComponent . SnapOnAnticipationFailVariable . Anticipate ( 10 ) ;
431+ testComponent . SetSnapValueRpc ( 10 ) ;
432+ WaitForMessageReceivedWithTimeTravel < NetworkVariableDeltaMessage > ( m_ClientNetworkManagers . ToList ( ) ) ;
433+ // Verify the previous value is 0
434+ Assert . AreEqual ( 0 , m_PreviousSnapValue ) ;
435+ testComponent . SetSnapValueRpc ( 20 ) ;
436+
437+ WaitForMessageReceivedWithTimeTravel < NetworkVariableDeltaMessage > ( m_ClientNetworkManagers . ToList ( ) ) ;
438+ // Verify the previous value is 10
439+ Assert . AreEqual ( 10 , m_PreviousSnapValue ) ;
440+
441+ testComponent . SetSnapValueRpc ( 30 ) ;
442+ WaitForMessageReceivedWithTimeTravel < NetworkVariableDeltaMessage > ( m_ClientNetworkManagers . ToList ( ) ) ;
443+ // Verify the previous value is 20
444+ Assert . AreEqual ( 20 , m_PreviousSnapValue ) ;
445+ }
446+
447+ private void OnAuthoritativeValueChanged ( AnticipatedNetworkVariable < int > anticipatedValue , in int previous , in int current )
448+ {
449+ m_PreviousSnapValue = previous ;
450+ }
451+
419452 }
420453}
0 commit comments