MockLocker is a simple library that simulates locker functionality, allowing you to perform actions like unlocking, checking status, and closing locks. This library is easy to use and integrate into your .NET projects.
MockLocker.Library is compatible with the following frameworks:
- .NET Framework 4.7.2 and later
- .NET Core 3.1 and later
- .NET 5.0 and later
- .NET Standard 2.0 and later
The MockLocker library supports four lock types:
- Lock16 - simulates a locker with 16 locks
- Lock32 - simulates a locker with 32 locks
- Lock48 - simulates a locker with 48 locks
- Lock64 - simulates a locker with 64 locks
You can choose the desired lock type when instantiating the MockLocker
class.
To start using the MockLocker library, follow these steps:
- Add a reference to the
MockLocker.Library
in your project. - In your code, add a
using
directive forMockLocker.Library
. - Instantiate the
MockLocker
class by providing theLockType
:
using MockLocker.Library;
using MockLocker.Library.Models;
var mockLocker = new MockLocker(LockType.Lock16);
To unlock a lock, call the Unlock
method with the lock number:
var response = mockLocker.Unlock(1);
if (response.IsSuccess)
{
Console.WriteLine("Lock unlocked successfully.");
}
else
{
Console.WriteLine($"Error: {response.Error}");
}
To close all locks at once, call the CloseAllLocks
method:
var response = mockLocker.CloseAllLocks();
if (response.IsSuccess)
{
Console.WriteLine("All locks closed successfully.");
}
else
{
Console.WriteLine($"Error: {response.Error}");
}
To check the status of all locks, call the CheckStatus
method:
var statusResponse = mockLocker.CheckStatus();
if (statusResponse.IsSuccess)
{
foreach (var status in statusResponse.Statuses)
{
Console.WriteLine($"Lock {status.LockNumber}: {(status.IsLocked ? "Locked" : "Unlocked")}");
}
}
else
{
Console.WriteLine($"Error: {statusResponse.Error}");
}