TimeSimulator 1.1.1

dotnet add package TimeSimulator --version 1.1.1
                    
NuGet\Install-Package TimeSimulator -Version 1.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TimeSimulator" Version="1.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TimeSimulator" Version="1.1.1" />
                    
Directory.Packages.props
<PackageReference Include="TimeSimulator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TimeSimulator --version 1.1.1
                    
#r "nuget: TimeSimulator, 1.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TimeSimulator@1.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TimeSimulator&version=1.1.1
                    
Install as a Cake Addin
#tool nuget:?package=TimeSimulator&version=1.1.1
                    
Install as a Cake Tool

Let's update the project with a README file and the necessary metadata in the .csproj file before publishing to NuGet.

Step 1: Create a README.md file

Create a file named README.md in the root directory of your project (C:\Users\Nandha5321\source\TimeSimulator):

# TimeSimulator

A .NET library for simulating accelerated time execution to test time-dependent systems without waiting for real time to pass.

## Features

- Virtual time acceleration (run days of simulation in seconds)
- Intercepts .NET time operations (DateTime.Now, Task.Delay, etc.)
- Component registration for time-dependent objects
- Event tracking and visualization for time-based patterns
- Easily test caching, scheduling, and other time-dependent behaviors

## Installation

```bash
dotnet add package TimeSimulator

Quick Start

// Create simulator with 1000x acceleration
using var simulator = new Simulator();
simulator.AccelerationFactor = 1000;

// Initialize time interceptors
SimulatorContext.Initialize(simulator);

// Now use standard .NET time operations with accelerated time
Console.WriteLine($"Starting at: {DateTimeInterceptor.Now}");

// This will only take a few milliseconds in real time
await TaskDelayInterceptor.Delay(TimeSpan.FromHours(1));

Console.WriteLine($"After 1 hour: {DateTimeInterceptor.Now}");

// Run simulation forward
await simulator.RunFor(TimeSpan.FromDays(7));

Console.WriteLine($"After 7 days: {DateTimeInterceptor.Now}");

// Don't forget to reset when done
SimulatorContext.Reset();

Creating Time-Aware Components

Implement the ITemporalComponent interface to create components that respond to time changes:

public class CacheSystem : ITemporalComponent
{
    // Your implementation
    
    public void OnTimeAdvanced(DateTime newTime, TimeSpan advancedDuration)
    {
        // Handle time advancement, e.g., expire cache entries
    }
}

// Register with simulator
simulator.Register(myCache);

Use Cases

  • Test caching systems with expiration
  • Verify scheduled job execution over long periods
  • Identify time-based race conditions
  • Test time-dependent behaviors without long waits
  • Simulate complex time-based patterns
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.1 176 3/23/2025
1.0.1 165 3/23/2025
1.0.0 161 3/23/2025