售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Title Page
Copyright and Credits
C# and .NET Core Test-Driven Development
Dedication
Packt Upsell
Why subscribe?
PacktPub.com
Contributors
About the author
About the reviewer
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Download the color images
Conventions used
Get in touch
Reviews
Exploring Test-Driven Development
Difficulty in maintaining code
How does bad code appear?
Tight coupling
Code smell
Bad or broken designs
Naming the program elements
Source code readability
Poor source code documentation
Non-tested code
What we can do to prevent bad code
Loose coupling
Sound architecture and design
Preventing and detecting code smell
C# coding conventions
Succinct and proper documentation
Why test-driven development?
Building for longevity
The principles of test-driven development
Origin of TDD
TDD misconceptions
Benefits of TDD
Types of tests
Unit tests
Integration tests
System testing
User acceptance testing
Principles of TDD
Writing the tests
Writing the code
Running the tests
Refactoring
Doing TDD the wrong way
The TDD cycle
Summary
Getting Started with .NET Core
.NET Core framework
.NET Standard
.NET Core components
Supported languages
When to choose .NET Core over .NET Framework
Cross-platform requirements
Ease of deployment
Scalability and performance
Limitations of .NET Core
Structure of a .NET Core application
ASP.NET Core MVC project structure
wwwroot folder
Models, Views, and Controllers folders
JSON files – bower.json, appsettings.json, bundleconfig.json
Program.cs
Startup.cs
Tour of Microsoft's Visual Studio Code editor
Installing .NET Core on Linux
Installing and setting up Visual Studio Code on Linux
Exploring Visual Studio Code
A look at the new features of C# 7
Tuples enhancement
Out keyword
Ref locals and returns
Ref locals
Ref returns
Local function
Patterns matching
Digit separator and binary literal
Creating an ASP.NET MVC Core application
Summary
Writing Testable Code
Warning signs when writing untestable code
Tight coupling
Monster Constructor
Classes with more than one responsibility
Static objects
Law of Demeter
Train Wreck
The SOLID architecture principles
Single Responsibility Principle
Open-Closed Principle
Liskov Substitution Principle
Interface Segregation Principle
Dependency Inversion Principle
Setting up a DI container for ASP.NET Core MVC
Summary
.NET Core Unit Testing
The attributes of a good unit test
Readable
Unit independence
Repeatable
Maintainable and runs fast
Easy to set up, non-trivial, and with good coverage
Unit testing framework ecosystem for .NET Core and C#
.NET Core testing with MSTest
.NET Core testing with NUnit
xUnit.net
How to configure xUnit.net
xUnit.net test runners
Test parallelism
Unit testing consideration for ASP.NET MVC Core
Unit testing controllers
Unit testing razor pages
Structuring unit tests with xUnit
xUnit.net shared test context
Live unit testing with Visual Studio 2017 Enterprise
Proving unit test results with xUnit.net assertions
The test runners available on both .NET Core and Windows
ReSharper
Summary
Data-Driven Unit Tests
The benefits of data-driven unit testing
Tests brevity
Inclusive testing
xUnit.net theory attribute for creating data-driven tests
Inline data-driven unit tests
Property data-driven unit tests
MemberData attribute
ClassData attribute
Integrating data from other sources
SqlServerData attribute
Custom attribute
Summary
Mocking Dependencies
The benefits of mocking objects
Fast running tests
Dependencies isolation
Refactoring legacy code
Wider test coverage
The shortcomings of mocking frameworks
Interface explosion
Extra complexity
Mock explosion
Hand-rolling mocks versus using a mocking framework
Mocking concept
Benefits of hand-rolling mocks
Mocks and stubs
Hand-rolled mock
Mocking objects using Moq framework
Mocking methods, properties, and callback
Properties
Matching parameters
Events
Callbacks
Mock customization
CallBase
Mock repository
Implementing multiple interfaces in a mock
Verification method and property invocations with Moq
LINQ to mocks
Advanced Moq features
Mocking internal types
Summary
Continuous Integration and Project Hosting
Continuous integration
CI workflow
Single source code repository
Build automation
Automated tests
Identical test and production environments
Daily commit
Benefits of CI
Quick bugs detection
Improved productivity
Reduced risks
Facilitating continuous delivery
CI tools
Microsoft Team Foundation Server
TeamCity
Jenkins
Continuous delivery
Benefits of continuous delivery
Lower risks
Quality software products
Reduced costs
GitHub online project hosting
Project hosting
Branching with GitHub Flow
Pull request
Reviewing changes and merging
Basic Git commands
Configuration commands
Initializing repository commands
Change commands
Branching and merging commands
Configuring GitHub WebHooks
Consuming WebHooks
GitHub WebHook
Events and payloads
Setting up your first WebHook
TeamCity CI platform
TeamCity concepts
Installing TeamCity Server
TeamCity CI workflow
Configuring and running build
Summary
Creating Continuous Integration Build Processes
Installing the Cake Bootstrapper
Installation
PowerShell security
Cake Bootstrapper installation steps
Step 1
Step 2
Step 3
Writing build scripts in C#
Task
TaskSetup and TaskTeardown
Configuration and preprocessor directives
Dependencies
Criteria
Cake's error handling and finally block
LoanApplication build script
Cake Extension for Visual Studio
Cake templates
Task Runner Explorer
Syntax highlighting
Using Cake tasks to build steps
CI with Visual Studio Team Services
Setting up a project in VSTS
Installing Cake into VSTS
Adding a build task
Summary
Testing and Packaging the Application
Executing xUnit.net tests with Cake
Executing xUnit.net tests in .NET projects
Executing xUnit.net tests in .NET Core projects
.NET Core versioning
Versioning principle
Installer
Package manager
Docker
Semantic Versioning
.NET Core packages and metapackages
Metapackage
Microsoft.AspNetCore.All metapackage
Packaging for NuGet distribution
dotnet publish command
Creating a NuGet package
Summary
Other Books You May Enjoy
Leave a review - let other readers know what you think
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜