
Writing
A Suite the Team Can Keep Trusting
A growing acceptance suite stays trustworthy through explicit scenarios and owned resources. Organize by feature, keep Act visible, review complete comparisons, and retain useful CI failures.

Topic
Material specific to C#, or illustrated with C# examples.
93 pages

Writing
A growing acceptance suite stays trustworthy through explicit scenarios and owned resources. Organize by feature, keep Act visible, review complete comparisons, and retain useful CI failures.

Writing
Random data must preserve the named test scenario. Constrained catalog sampling, immutable builders, deliberate threshold guards, and owned identities keep arrangements correct.

Writing
Assertions must compare every required field, count, and effect. Pure asserters separate observations from comparisons and report available failures together with verified expectations.

Writing
Functional acceptance tests verify complete outcomes through the assembled system. Correct arrangements, deep assertions, and controlled observations support release confidence.

Writing
Repeated and concurrent order requests must preserve accepted outcomes without duplicate work. Compare canonical request identity, allowed race outcomes, stored facts, and outgoing effects.

Writing
A green suite needs correct scenarios for established requirements. An obligation map connects each rule to its arrangement, expected outcome, independent observation, and assertion.

Writing
Acceptance tests let teammates learn requirements and production behavior together. Follow one order through Arrange, the visible Act, independent observations, and complete assertions.

Writing
One ordering scenario verifies the caller result, stored lines, fulfillment, and confirmation. Follow its complete C# test, independent observations, and accumulated failure reports.

Writing
A stable Domain Facade lets acceptance scenarios and assertions survive internal refactoring. Adapt test support behind unchanged observations and adopt complete boundary tests feature by feature.

Writing
Failure timing determines what an order still owes. Verify refusal, real transaction rollback, post-commit action failures, and accepted effects whose completion could not be recorded.

Writing
Real infrastructure must participate when transactions and messages are required outcomes. Provision SQL and broker topology, isolate runs, define observation windows, and verify actual rollback.

Writing
Interface tests verify wire conversion and exception translation at their owning boundaries. Controller Hooks, middleware checks, and hosted HTTP scenarios complement domain acceptance.

Writing
A Test Mediator and transport spy control delivery and expose observations while production gateways run. Capture email content, script retries, and measure bounded response reads.

Writing
Use null-conditional calls only when skipping work is correct. Required logging and optional disposal expose the difference between nullable warnings and runtime behavior.

Writing
An application logging adapter can accept a DTO and expose its fields as structured state. ILogger.Log<TState> separates that context from the formatted message.

Writing
Repeated work can hide inside a short LINQ query. A customer-filtering benchmark separates string conversions, lookup choices, iteration and changed behavior.

Writing
Give callers domain operations while collections and gateways own the details: service orchestration, model mapping and translation of recognized failures into domain exceptions.

Writing
Dependency inversion needs domain-owned contracts that hide implementation knowledge. Follow a show query from source dependencies through models to a stored procedure.

Writing
Useful abstractions express the caller's needs precisely. Broker, database and charting examples show where SDK types, storage details and excess generality get in the way.

Writing
Use a cast instead of `as` when the type is expected, so a mismatch raises InvalidCastException. Use `is` when the type genuinely varies and keep only guards backed by a real case.

Writing
Create instances for state or polymorphism and use inheritance for a common consumer. Static behavior and composition can keep testing from dictating every class's shape.

Writing
Business operations are easier to trace when immutable DTOs carry facts and stateless managers validate inputs and coordinate work through named methods at the call site.

Writing
Named ValueTuples make small results readable. Positional fields, copy behavior and Deconstruct methods explain the syntax and the limits of tuple return types.

Writing
Test-data builders keep each scenario's chosen values visible. C# expression trees select model properties, and stored overrides preserve explicit nulls.

Writing
The Adapter pattern keeps application messaging independent of broker SDKs by translating messages, callbacks and acknowledgements between RabbitMQ and Service Bus.

Writing
Build a working baseline, then change the design for a concrete benefit; a log parser evolves through a switch, delegates, and Strategy to test that judgment.

Writing
A one-to-many map must enforce unique values and return a key from a value. Shared tests and four implementations show how correctness shapes a benchmark.

Writing
LINQ rewrites can add work while removing repetition. Customer filters expose query projections, lookup choices and why benchmarks must compare equal results.

Writing
A terminal request delegate exposes the work behind an ASP.NET Core endpoint. A movie-service experiment compares a narrow handler with the controller pipeline.

Writing
StringBuilder suits growing results, but can cost more for fixed concatenation. Compiler output, allocations and benchmark checks explain when to choose it.

Writing
.NET generics retain runtime type arguments. Typed lists avoid boxing value-type elements, while CLR specialization and code sharing preserve distinct types.

Writing
C# embeds constants and default parameter values in compiled callers. Library-only builds and IL inspection explain why callers must be rebuilt to adopt changed values.

Writing
C# construction order determines which fields are ready. Field initializers, constructor chaining, virtual dispatch and static initialization explain what runs when.

Writing
The type a foreach loop sees determines its enumeration path. Array lowering, list enumerators and yield state machines explain the work behind the syntax.

Writing
Delegates let callers supply behavior to reusable methods. Lambda syntax and SingleElseException show how higher order functions add useful failure details.

Writing
Choose static classes when instances serve no purpose. Shared type state, autonomous methods and immutable inputs explain the discipline that makes them useful.

Writing
C# passes arguments by value by default. Integer, string and object examples explain what gets copied, how ref works and which changes reach the caller.

Writing
Async streams let callers process database rows before the full result exists. An async iterator combines await and yield return, keeping its reader open during enumeration.

Writing
A benchmark tests whether a change improves the same operation. BenchmarkDotNet makes input choice, setup, timing and allocation costs visible for .NET code.

Writing
Specific exceptions preserve failure meaning, causes, and context. A shallow C# hierarchy, Gateway translation, and middleware enrichment carry diagnostic records across service boundaries.

Writing
Structured logs preserve the facts needed to investigate failures. Application Insights custom dimensions make them searchable, while typed progress events track long-running work.

Writing
Method contracts let callers rely on completed work and let failures propagate. C# examples distinguish retrieval from search, validate domain entry points, and assign handling to its owner.

Writing
Dependency injection exposes private collaborators to callers when used for every internal relationship. Keep classes self-contained and let business code choose real variation.

Writing
C# interfaces do not inherently create contracts or loose coupling. Composition handles hierarchy conflicts; capability interfaces and structural typing let consumers see only what they need.

Writing
Keep project-specific helpers as static methods: extension methods hide behavior behind namespaces and can change meaning with imports. Use them when they serve the wider C# community.

Writing
A Factory selects and constructs a concrete descendant while callers program to an interface through the base class's public contract. C# thumbnailers show selection and polymorphic dispatch.

Writing
CPU caches reward useful data kept close together. Pipelines, branch prediction and cache lines explain why memory access patterns matter to .NET performance.

Writing
A Configuration Provider hides the source and returns validated, typed settings. Useful exceptions and composed settings providers keep configuration rules in one place.

Writing
A Gateway presents business operations, translates service models and transforms failures into domain exceptions, keeping external service details behind one boundary.

Writing
.NET allocation costs follow what gets stored and copied. Structs, classes, arrays and strings explain object layout, references and garbage collection.

Writing
A model should express required fields, genuine absence, and distinct variants in its type. Python unions and C# records encode those promises, while boundaries check external values.

Chapter
Structure communicates intent: strict layers from Domain Facade to Gateway, internal by default with a public surface the compiler enforces, and folder depth that marks each class's level of abstraction.

Chapter
Internal by default, behavior-only classes against state-only types, the two sanctioned uses of interfaces, and closing concrete descendants.

Chapter
A query does not run when you write it, and calling it twice may not give the same answer. Deferred execution, materialization, terminal operators, and untranslatable queries.

Chapter
C# methods tell callers what they do through explicit visibility, truthful signatures, and returns that express action, query, and cardinality; their bodies orchestrate at one level.

Chapter
Deriving names rather than inventing them, domain suffixes over indices, the Async exception, and why Retrieve and Search choose different failure contracts.

Writing
Factory Method lets consumer subclasses choose dependencies through an overridable creation hook. C# examples show its two class families and distinguish it from a separate Factory.

Writing
Asynchronous I/O frees server threads during waits and can improve capacity under load. IIS request flow, Task.WhenAll, and load tests show where the benefit ends.

Writing
Azure role startup configuration affects IIS administration. An OnStart impersonation example and a later elevated Runtime update explain the approaches explored.

Writing
Cross-domain CRUD needs changes on both sides: a Web API DelegatingHandler handles origin headers and method overrides while jQuery sends the matching requests.

Writing
A generic HttpClient wraps asynchronous RESTful CRUD operations and JSON formatting. A MemberRepository and console client show how to use it with typed resources.

Writing
Map member CRUD operations to HTTP methods and resource URIs, then implement an ApiController with response status codes, Location headers, and error responses.

Writing
An X-HTTP-Method-Override header lets POST requests carry PUT or DELETE intent. A Web API DelegatingHandler translates the method before controller dispatch.

Writing
A JsonMediaTypeFormatter subclass wraps JSON in a callback for JSONP responses. Registration and controller-level control explain both the solution and its limits.

Writing
Use HttpClient to send GET, POST, PUT, and DELETE requests, serialize Customer objects with ObjectContent, and read typed responses from a self-hosted Web API.

Writing
Run an ASP.NET Web API in a console process with HttpSelfHostServer, register routes, and exercise a CustomersController backed by an in-memory customer list.

Writing
Add an ApiController to an ASP.NET WebForms project and register its HTTP route in Global.asax, then test customer requests and inspect JSON or XML responses.

Writing
Roslyn syntax trees and semantic information drive a C# to HTML highlighter, with a SyntaxWalker and explicit handling for type names whose definitions are unavailable.

Writing
Build a WCF service and client around Customer contracts, then configure transport bindings, create client proxies, and publish metadata through WSDL and MEX.

Writing
Use the Response.Redirect overload with endResponse set to false to avoid ThreadAbortException, then structure request handling so execution finishes deliberately.

Writing
HttpWebRequest callbacks and Task.Factory.FromAsync support asynchronous GET and POST calls, with five approaches compared for collecting concurrent responses.

Writing
SelectMany flattens related sequences into a single result. Categories and posts explain its collection selector, result selector, joins, and nested foreach behavior.

Writing
Data parallelism distributes compute-bound work across cores. Prime-counting examples compare PLINQ, Parallel.For, thread-local state, partitioning, and measured timings.

Writing
WMI queries expose core counts, logical and physical processors, bitness, and architecture in C#, with narrower queries returning only the CPU information required.

Writing
Expose an existing synchronous method through Begin and End operations using delegates and IAsyncResult, carrying callback state while reusing the original computation.

Writing
A C# UrlEncode implementation preserves unreserved characters and percent-encodes others, with character-by-character comparisons against HttpUtility.UrlEncode.

Writing
Group lessons by AddedDate and select groups containing more than one item to find duplicates with LINQ, retaining the shared date and all matching lesson objects.

Writing
Start, stop, and restart Windows services from C# using net commands or ServiceController, with redirected process output, error handling, and completion waits.

Writing
A JsonSerializer streams IEnumerable<T> directly to JSON, preserving DataMember names and supporting JSONP while a DbDataReader wrapper avoids building an intermediate list.

Writing
An IMetaWeblogProvider separates blog operations from XML and HTTP. MetaWeblogManager translates requests, while an IHttpHandler connects the library to a blog engine.

Writing
Stored-procedure metadata drives ADO.NET code generation and typed DbDataReader wrappers, supporting streamed results or materialized lists according to how callers use the data.

Writing
An OAuth 1.0 C# library handles request and access tokens across providers. A web application demonstrates authorization redirects and a later request for user information.

Writing
A Factory decouples payment processing from concrete classes, discovers implementations, and caches constructor delegates built with DynamicMethod and ILGenerator.

Writing
A Data Access Layer isolates business logic from the logical data model through domain-specific methods, stored procedures, and results shaped for the business layer.

Writing
Create a BusinessModule in HttpApplication.Init to reuse it across requests. The proposed ASP.NET design relies on application-instance ownership and stateless business layers.

Writing
Typed DbDataReader wrappers centralize field access and null handling. Examples compare reusing one wrapper through IEnumerable<T> with creating objects for a List<T>.

Writing
Quartz composes ASP.NET pages through a Builder, reusable HTML templates, and view objects. The walkthrough covers their relationships and Visual Studio templates.

Writing
ChangeType<T> converts request strings through registered binders, handling numbers, arrays, enums, and custom DTOs while keeping conversion calls consistent across web pages.

Writing
A Razor host wrapper parses templates and compiles generated C# outside ASP.NET. A custom base class supplies execution and output methods for a desktop example.

Writing
ASP.NET MVC's indirect access to views spreads responsibilities across controllers and templates. ViewData, child actions, and typed view instances frame the critique.

Writing
Razor makes C# mixed with HTML easier to read through its @ syntax, code blocks, layouts, and sections. Worked templates show the output and the limits of view responsibilities.

Writing
Find links to a target domain with HtmlAgilityPack and C#. A LinkFinder downloads HTML, selects anchor elements, and returns their text and attributes.

Writing
IIS FTP 7.5 can authenticate IIS Manager Users with isolated directories. Folder permissions, provider settings, and C# user creation complete the setup.