mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-13 11:44:54 +00:00
Implement basic unit test infrastructure with abstraction patterns
Co-authored-by: ngenovese11 <23391587+ngenovese11@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Tests.Abstractions
|
||||
{
|
||||
/// <summary>
|
||||
/// Abstraction for logging operations to enable testing
|
||||
/// </summary>
|
||||
public interface ILogger
|
||||
{
|
||||
/// <summary>
|
||||
/// Logs a debug message
|
||||
/// </summary>
|
||||
/// <param name="source">Source of the log message</param>
|
||||
/// <param name="message">Message to log</param>
|
||||
/// <param name="args">Format arguments</param>
|
||||
void LogDebug(object source, string message, params object[] args);
|
||||
|
||||
/// <summary>
|
||||
/// Logs a verbose message
|
||||
/// </summary>
|
||||
/// <param name="source">Source of the log message</param>
|
||||
/// <param name="message">Message to log</param>
|
||||
/// <param name="args">Format arguments</param>
|
||||
void LogVerbose(object source, string message, params object[] args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Tests.Abstractions
|
||||
{
|
||||
/// <summary>
|
||||
/// Abstraction for queue operations to enable testing
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of items in the queue</typeparam>
|
||||
public interface IQueue<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Number of items in the queue
|
||||
/// </summary>
|
||||
int Count { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the queue
|
||||
/// </summary>
|
||||
/// <param name="item">Item to add</param>
|
||||
void Enqueue(T item);
|
||||
|
||||
/// <summary>
|
||||
/// Removes and returns the next item from the queue
|
||||
/// </summary>
|
||||
/// <returns>The next item, or default(T) if queue is empty</returns>
|
||||
T Dequeue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Tests.Abstractions
|
||||
{
|
||||
/// <summary>
|
||||
/// Abstraction for thread operations to enable testing
|
||||
/// </summary>
|
||||
public interface IThreadService
|
||||
{
|
||||
/// <summary>
|
||||
/// Sleeps the current thread for the specified milliseconds
|
||||
/// </summary>
|
||||
/// <param name="milliseconds">Time to sleep in milliseconds</param>
|
||||
void Sleep(int milliseconds);
|
||||
|
||||
/// <summary>
|
||||
/// Creates and starts a new thread
|
||||
/// </summary>
|
||||
/// <param name="threadFunction">The function to execute in the thread</param>
|
||||
/// <param name="parameter">Parameter to pass to the thread function</param>
|
||||
/// <returns>Thread identifier or handle</returns>
|
||||
object CreateAndStartThread(Func<object, object> threadFunction, object parameter);
|
||||
|
||||
/// <summary>
|
||||
/// Aborts the specified thread
|
||||
/// </summary>
|
||||
/// <param name="thread">The thread to abort</param>
|
||||
void AbortThread(object thread);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the thread is currently running
|
||||
/// </summary>
|
||||
/// <param name="thread">The thread to check</param>
|
||||
/// <returns>True if the thread is running, false otherwise</returns>
|
||||
bool IsThreadRunning(object thread);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user