IClock Interface
Defines a mechanism for retrieving the current date and time, allowing for consistent time handling within .NET applications.
Ideal for scenarios requiring time manipulation, such as unit testing, stock exchange replay, or cyber attack detection analysis.
Namespace:
WalterAssembly: Walter (in Walter.dll)
Remarks
Examples
Using IClock in a class and unit test
// Class using the IClock class Record { public Record(string name) { Time = IClock.Instance.Now; // Set the current time Name = name; } /// <summary> /// Time the action was recorded /// </summary> public DateTime Time { get; } // Other properties... } // In your unit test or replay class, validate logic based on date and time var clock = new Walter.TestClock(TimeSeries[0].Time); // Initialize TestClock with a specific time Walter.IClock.Instance = clock; // Swap the IClock instance with TestClock foreach (var item in TimeSeries) { var laps = item.Time - IClock.Instance.Now; // Calculate time difference clock.Add(laps); // Move the clock forward var record = new Record(item.Activity); // Perform time-sensitive activity using the time set by IClock bool isAllowed = UserCanLogin(record); }

