NosePlug
Sometimes you have to test code that smells.
Install / Use
/learn @Keboo/NosePlugREADME
NosePlug
Sometimes you have to test code that smells. When using static methods it tightly couples two pieces of code together. When over used this can lead to code that is difficult to test since all coupled code will be invoked. Ideally the code should be refactored to eliminate this problem, however in the real world ideals are not always possible. This library serves to be a half way point to allow testing to occur during the interim before appropriate refactoring can occur.
Getting started
This library's API is heavily influenced by Moq. See the documentation for the full getting started guide.
A simple example "mocking" DateTime.Now.
var nowPlug = Nasal.Property(() => DateTime.Now)
.Returns(() => new DateTime(1987, 4, 20));
using (await Nasal.ApplyAsync(nowPlug))
{
Assert.Equal(new DateTime(1987, 4, 20), DateTime.Now);
}
Limitations
This library relies on Harmony to monkey patch methods. This library maintains all of the same limitations of Harmony. The most common failure comes from inlining. This is most apparent when compiling in Release configuration (optimizations enabled).
Related Skills
node-connect
339.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
339.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.9kCommit, push, and open a PR
