跨平台 Windows平台 .NET Core.NET Framework ASP.NET Core ASP.NET ASP.NET Core MVC ASP.NET MVC .NET Core與.NET名詞對比
10.
兩兩種.NET Core開發途徑 Visual Studio2017 & 2019 CLI + ⽂文字編輯器 ( Visual Studio Code, vim, Atom…) Visual Studio 2017/2019 Visual Studio for Mac Visual Studio Code .NET Core CLI tools
Choosing .NET Framework Yourapp uses third-party .NET libraries or NuGet packages not available for .NET Core. Your app uses .NET technologies that aren't available for .NET Core. Your app uses a platform that doesn’t support .NET Core.
.NET Core內建單元測試框架 dotnet new dotnetnew mstest Templates Short Name Language Tags ----------------------------------------------------------------------- Unit Test Project mstest [C#], F#, VB Test/MSTest NUnit 3 Test Project nunit [C#], F#, VB Test/NUnit xUnit Test Project xunit [C#], F#, VB Test/xUnit
Unit Test —Bad Naming Public void Test_SqrtValue() { //Arrange Var Calc = new Calc(); //Act Var sqrtValue = Calc.GetSqrt(4); //Assert Assert.Equal(2, sqrtValue); } 初始化 動作(執⾏行行) 斷⾔言(評估執⾏行行結果預
48.
Unit Test —Good Naming Public void GetSqrt_SingleNumber_ReturnrSqrtValue() { //Arrange Var Calc = new Calc(); //Act Var sqrtValue = Calc.GetSqrt(4); //Assert Assert.Equal(2, sqrtValue); } MethodName_TestScenario_ExpectedBehavior
但~相依特定實作是不好的 FubonBankServices service =new FubonBankServices() EsunBankServices service = new EsunBankServices() 相依特定實作,⼀一旦替換實作,所有類別程式必須修改 在專案中⼀一堆類別程式初始FubonBankServices,若若 FubonBankSevices需要組態,會在專案的各⾓角設定組態 未實作interface介⾯面,導致單元測試難以Mocking或Stubing
註冊服務的三種Lifetime指令 AddScoped⽅方法—Scoped lifetime service arecreated once per request AddTransient⽅方法 — Transient lifetime service are created each time they're requested AddSingleton⽅方法 — Singleton lifetime service are only created at the first request time
Better integration withpopular Open API (Swagger) libraries including design-time checks with code analyzers Introduction of Endpoint Routing with up to 20% improved routing performance in MVC Improved URL generation with the LinkGenerator class & support for route Parameter Transformers (and a post from Scott Hanselman) New Health Checks API for application health monitoring Up to 400% improved throughput on IIS due to in-process hosting support Up to 15% improved MVC model validation performance Problem Details (RFC 7807) support in MVC for detailed API error results Preview of HTTP/2 server support in ASP.NET Core Template updates for Bootstrap 4 and Angular 6 Java client for ASP.NET Core SignalR Up to 60% improved HTTP Client performance on Linux and 20% on Windows http://bit.ly/2sn6oWT