Skip to content
Merged
Prev Previous commit
Next Next commit
docs: normalize tone, trim padding, expand thin pages
Tone normalization:
- Remove all first-person voice from framework-differences.md and things-to-know.md
- Remove marketing copy from property-injection.md and philosophy.md
- Remove emoji from headings across 13 files (benchmarks, installation, extensions, CI/CD)
- Fix "tests tests" typo in framework-differences.md

Padding trimmed (~1170 lines removed):
- boolean.md: remove 7 filler sections (LINQ, string methods, type checking, etc.)
- numeric.md: remove math library and arithmetic sections
- datetime.md: remove quarter calculation, first/last day, timezone sections
- equality-and-comparison.md: fix EqualTo alias, fix UtcNow double-call, remove redundant examples
- collections.md: remove duplicate nested/find-and-assert sections
- awaiting.md: strip grab-bag examples, keep core await explanation
- property-injection.md: reduce 3 identical container examples to 1
- generic-attributes.md: remove fabricated patterns (Fibonacci, Builder, Factory, IJsonSerializable)
- cookbook.md: replace duplicate TestWebServer with cross-reference
- method-data-source.md: reduce 4 code blocks to 2 (Func pattern only)

Pages expanded:
- playwright.md: 80→400 words (real interaction test, browser config, parallel limits)
- libraries.md: 50→250 words (csproj example, consumer usage)
- test-configuration.md: 80→200 words (missing keys, nested syntax, typed values)
- repeating.md: 130→250 words (Repeat vs Retry distinction, real test body)
- timeouts.md: 140→250 words (cancellation behavior, real test body)
- test-filters.md: 230→350 words (namespace, property, combined filters)
- explicit.md: 130→200 words (concrete filter commands, category example)
- parallel-groups.md: 85→250 words (clear semantics, step-by-step scenario)
  • Loading branch information
thomhurst committed Feb 26, 2026
commit 965658b66e0d5d34cf07e6a55114ce84cca293a3
127 changes: 1 addition & 126 deletions docs/docs/assertions/awaiting.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,77 +179,6 @@ public async Task CustomAssertionConditions()
}
```

### DateTime and TimeSpan Assertions

```csharp
[Test]
public async Task DateTimeAssertions()
{
var order = await CreateOrderAsync();

// Complex datetime assertions
await Assert.That(order.CreatedAt)
.IsGreaterThan(DateTime.UtcNow.AddMinutes(-1))
.And.IsLessThan(DateTime.UtcNow.AddMinutes(1));

// TimeSpan assertions
var processingTime = order.CompletedAt - order.CreatedAt;
await Assert.That(processingTime)
.IsLessThan(TimeSpan.FromMinutes(5))
.And.IsGreaterThan(TimeSpan.Zero);
}
```

### Floating Point Comparisons

```csharp
[Test]
public async Task FloatingPointAssertions()
{
var calculations = await PerformComplexCalculationsAsync();

// Use tolerance for floating point comparisons
await Assert.That(calculations.Pi)
.IsEqualTo(Math.PI).Within(0.0001);

// Assert on collections of floating point numbers
await Assert.That(calculations.Results)
.All(r => Math.Abs(r) < 1000000); // No overflow

// Check for approximate value in collection
var hasApproximate42 = calculations.Results.Any(r => Math.Abs(r - 42.0) < 0.1);
await Assert.That(hasApproximate42).IsTrue();

// Assert on sum with tolerance
var sum = calculations.Results.Sum();
await Assert.That(sum).IsEqualTo(expectedSum).Within(0.01);
}
```

### String Pattern Matching

```csharp
[Test]
public async Task StringPatternAssertions()
{
var logs = await GetLogEntriesAsync();

// Complex string assertions
await Assert.That(logs)
.All(log => Regex.IsMatch(log, @"^\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\]"))
.And.Any(log => log.Contains("ERROR"))
.And.DoesNotContain(log => log.Contains("SENSITIVE_DATA"));

// Assert on formatted output
var report = await GenerateReportAsync();
await Assert.That(report)
.StartsWith("Report Generated:")
.And.Contains("Total Items:")
.And.DoesNotContain("null")
.And.Length().IsBetween(1000, 5000);
}
```

### Combining Or and And Conditions

```csharp
Expand Down Expand Up @@ -279,58 +208,4 @@ public async Task ComplexLogicalConditions()
}
```

### Performance Assertions

```csharp
[Test]
public async Task PerformanceAssertions()
{
var stopwatch = Stopwatch.StartNew();
var results = new List<long>();

// Measure multiple operations
for (int i = 0; i < 100; i++)
{
var start = stopwatch.ElapsedMilliseconds;
await PerformOperationAsync();
results.Add(stopwatch.ElapsedMilliseconds - start);
}

// Assert on performance metrics
await Assert.That(results.Average())
.IsLessThan(100); // Average under 100ms

await Assert.That(results.Max())
.IsLessThan(500); // No operation over 500ms

await Assert.That(results.Where(r => r > 200).Count())
.IsLessThan(5); // Less than 5% over 200ms
}
```

### State Machine Assertions

```csharp
[Test]
public async Task StateMachineAssertions()
{
var workflow = new OrderWorkflow();

// Initial state
await Assert.That(workflow.State).IsEqualTo(OrderState.New);

// State transition assertions
await workflow.StartProcessing();
await Assert.That(workflow.State).IsEqualTo(OrderState.Processing);
await Assert.That(workflow.CanTransitionTo(OrderState.Completed)).IsTrue();
await Assert.That(workflow.CanTransitionTo(OrderState.New)).IsFalse();

// Complex workflow validation
await workflow.Complete();
await Assert.That(workflow.State).IsEqualTo(OrderState.Completed);
await Assert.That(workflow.CompletedAt).IsNotNull();
await Assert.That(workflow.History).Contains(h => h.State == OrderState.Processing);
}
```

These examples demonstrate the power and flexibility of TUnit's assertion system, showing how you can build complex, readable assertions for various testing scenarios.
For more assertion examples, see the dedicated pages for [collections](collections.md), [strings](string.md), [numeric](numeric.md), and [datetime](datetime.md) assertions.
Loading