Skip to content

API Overview

Complete API reference for the Skugga mocking library.

Mock Lifecycle

MethodDescription
Mock.Create<T>()Create a mock with Loose behavior
Mock.Create<T>(MockBehavior.Strict)Create a strict mock
Mock.Get<T>(object)Retrieve mock interface from a mocked object
Mock.Of<T>()LINQ-style mock creation

Setup API

MethodDescription
.Setup(x => x.Method(args))Setup method behavior
.Setup(x => x.Property)Setup property getter
.SetupSet(x => x.Property = value)Setup property setter
.SetupSequence(x => x.Method(args))Setup sequential returns
.Protected().Setup<T>(name, args)Setup protected members

Returns API

MethodDescription
.Returns(value)Return a fixed value
.ReturnsAsync(value)Return an async value
.Throws(exception)Throw an exception
.Throws<TException>()Throw a typed exception
.Callback<T>(action)Execute callback

Verify API

MethodDescription
.Verify(x => x.Method(args))Verify method was called
.Verify(expr, Times)Verify with call count
.VerifyAll()Verify all verifiable setups
.VerifyNoOtherCalls()No unexpected calls
.VerifySet(x => x.Prop = val)Verify property setter

Argument Matchers

MatcherDescription
It.IsAny<T>()Match any value
It.Is<T>(predicate)Match with predicate
It.IsIn<T>(values)Match value in set
It.IsNotNull<T>()Match non-null
It.IsRegex(pattern)Match regex
It.Ref<T>.IsAnyMatch ref/out params
Match.Create<T>(pred)Custom matcher

Times

ValueDescription
Times.OnceExactly once
Times.NeverNever called
Times.Exactly(n)Exactly n times
Times.AtLeast(n)At least n times
Times.AtMost(n)At most n times
Times.Between(min, max)Between min and max

Exclusive Features

APIDescription
mock.Chaos(policy => { ... })Configure chaos engineering
mock.GetChaosStatistics()Get chaos metrics
AssertAllocations.Zero(action)Assert zero allocations
AssertAllocations.AtMost(action, bytes)Assert allocation budget
AssertAllocations.Measure(action)Measure allocations
AutoScribe.Capture<T>(impl)Record interactions
[SkuggaFromOpenApi("spec")]Generate from OpenAPI

MockRepository

MethodDescription
new MockRepository(behavior)Create repository
repo.Create<T>()Create attached mock
repo.Register(mock)Register existing mock
repo.VerifyAll()Verify all mocks
repo.VerifyNoOtherCalls()No unexpected calls

Diagnostics

CodeDescription
SKUGGA001Cannot mock sealed class
SKUGGA002Class has no virtual members
SKUGGA_OPENAPI_*OpenAPI generation errors
SKUGGA_LINT_*OpenAPI linting warnings

Released under the MIT License.