# CustomToolContract

> Tracon documentation. Tracon is a .NET package family that adds a control
> plane on Microsoft Agent Framework, published as NuGet packages that run
> inside your own ASP.NET Core application.
>
> Page: https://tracon.dev/api/tracon.testing.contracts.tools.customtoolcontract/
> Summary: CustomToolContract: Behavior tests for a code-defined custom tool registration.

<div class="api-provenance">Namespace Tracon.Testing.Contracts.Tools · Assembly <code>Tracon.Testing.Contracts.Xunit.dll</code></div>

Behavior tests for a code-defined custom tool registration.

```csharp
public abstract class CustomToolContract : IAsyncLifetime, IAsyncDisposable
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.testing.contracts.tools.customtoolcontract/">CustomToolContract</a></dd><dt>Derived</dt><dd><a href="/api/tracon.testing.contracts.tools.repeatabletoolcontract/">RepeatableToolContract</a></dd><dt>Implements</dt><dd>IAsyncLifetime, <a href="https://learn.microsoft.com/dotnet/api/system.iasyncdisposable">IAsyncDisposable</a></dd><dt>Inherited Members</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone">object.MemberwiseClone()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a></dd></dl>

## Constructors

### <a id="Tracon_Testing_Contracts_Tools_CustomToolContract__ctor"></a> CustomToolContract\(\)

```csharp
protected CustomToolContract()
```

## Properties

### <a id="Tracon_Testing_Contracts_Tools_CustomToolContract_ExpectedResultText"></a> ExpectedResultText

Gets the semantic result text expected from an argument-free invocation.

```csharp
protected abstract string ExpectedResultText { get; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_Testing_Contracts_Tools_CustomToolContract_Registration"></a> Registration

The registration under test.

```csharp
protected TraconToolRegistration Registration { get; }
```

#### Property Value

 [TraconToolRegistration](/api/tracon.tracontoolregistration/)

## Methods

### <a id="Tracon_Testing_Contracts_Tools_CustomToolContract_Concurrent_server_calls_complete"></a> Concurrent\_server\_calls\_complete\(\)

Starts eight calls against the SAME singleton instance before awaiting
any of them, and requires every one to run to completion.

```csharp
[Fact]
public Task Concurrent_server_calls_complete()
```

#### Returns

 [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task)

#### Remarks

This contract has no knowledge of what the tool's arguments or result
mean, so it cannot assert that concurrent calls returned the RIGHT,
non-corrupted value for each caller — only that none of them faulted
(`TaskStatus.RanToCompletion`), which a naive
non-thread-safe shared field (a counter, a cache, a mutable buffer)
tends to violate under real concurrent access. A tool with per-call
state worth corrupting is proven at the semantic level by its own
tests — see `ConcurrentToolInvocationTests` in
`Tracon.AspNetCore.FunctionalTests` for a body that
deliberately holds a shared `Barrier` to guarantee genuine overlap.

### <a id="Tracon_Testing_Contracts_Tools_CustomToolContract_CreateRegistrationAsync"></a> CreateRegistrationAsync\(\)

Creates the custom tool registration under test.

```csharp
protected abstract ValueTask<TraconToolRegistration> CreateRegistrationAsync()
```

#### Returns

 [ValueTask](https://learn.microsoft.com/dotnet/api/system.threading.tasks.valuetask\-1)<[TraconToolRegistration](/api/tracon.tracontoolregistration/)\>

### <a id="Tracon_Testing_Contracts_Tools_CustomToolContract_DisposeAsync"></a> DisposeAsync\(\)

```csharp
public ValueTask DisposeAsync()
```

#### Returns

 [ValueTask](https://learn.microsoft.com/dotnet/api/system.threading.tasks.valuetask)

### <a id="Tracon_Testing_Contracts_Tools_CustomToolContract_InitializeAsync"></a> InitializeAsync\(\)

Called immediately after the class has been created, before it is used.

```csharp
public ValueTask InitializeAsync()
```

#### Returns

 [ValueTask](https://learn.microsoft.com/dotnet/api/system.threading.tasks.valuetask)

### <a id="Tracon_Testing_Contracts_Tools_CustomToolContract_Metadata_is_self_consistent"></a> Metadata\_is\_self\_consistent\(\)

```csharp
[Fact]
public void Metadata_is_self_consistent()
```

### <a id="Tracon_Testing_Contracts_Tools_CustomToolContract_Name_is_stable_and_valid"></a> Name\_is\_stable\_and\_valid\(\)

```csharp
[Fact]
public void Name_is_stable_and_valid()
```
