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