基于Singleton的設(shè)計 vs 基于MEF/Unity的依賴注入設(shè)計
依賴注入方式使得自動化測試變得有些麻煩。所以目前還是采用基于Singleton的設(shè)計。
分層設(shè)計中的代碼編寫規(guī)范
根據(jù)《C# WPF桌面程序分層結(jié)構(gòu)設(shè)計》。
不使用MEF等依賴注入技術(shù)的架構(gòu)設(shè)計
- Views,按功能劃分組織用戶控件文件
- Business,業(yè)務(wù)邏輯
應(yīng)該可用于自動測試腳本靜默運行。 - 不應(yīng)該包含任何MessageBox的彈出。
- DAL,數(shù)據(jù)庫ORM中間層
應(yīng)該可用于自動測試腳本靜默運行。 - 不應(yīng)該包含任何MessageBox的彈出。
- Infrastructure,基礎(chǔ)架構(gòu)工具
應(yīng)該可用于自動測試腳本靜默運行。 - 不應(yīng)該包含任何MessageBox的彈出。
面向方面的設(shè)計
錯誤處理設(shè)計
Design pattern for including errors with return values
WPF測試
Why AutomationProperties are needed in WPF
Question:
As per my understanding, AutomationProperties can be utilized to identify names of controls by UI Automation clients.
I want to understand need to create separate set of automation properties, and not using x:Name for the same purpose.
Answer:
Let’s think about a text box, in your application it is the PhoneNumberTextBox, and you also have a PhoneNumberLabel, and PhoneNumberValidationTick. These are then displayed inside of a group box with a label showing “Customer”
A blind person trying to use your application would like the screen reader to say “Customer Phone Number” when they tab into the text box, likewise a tester writing an automated UI test for your application would like to be able to find the text box that contains the “Customer Phone Number”.
Now what if your application has been translated to German…. Would the blind user not want the screen reader to say ”Kundentelefonnummer“?
Now imagine you change your app to use a PhoneNumberInputControl, you will likely want to change the names of the control in your code, but the tester would rather wish that the control name does not change….
So we need the concept of a name that is used by programs that try to walk the “important” logical controls of an application at run time and automate something about how a user interacts with the application.
Ian Ringrose answered Feb 12 '14 at 12:46
Common Mistakes should not Make
使用TAP(Task-based Asynchronous Pattern)
C#語言中定義了許多異步編程模型,包括IAsyncResult模式(Asynchronous Programming Model, APM),Event-based Asynchronous Pattern (EAP)。
TAP是一種新的設(shè)計模式,相對于其它模式:
- APM模式需要定義
BeginMethodNameandEndMethodNamemethods - EAP模式中, a
MethodName**Async**is required in addition to one or more events
在SO的一個問答中說,It also forces you to separate your background operation logic from your UI/ViewModel update code, which is a Good Thing.
SO的另一個問答中說:You may find my async
intro helpful, as well as the task based asynchronous pattern document.
For more information on the overhead of async
, I recommend the Zen of Async by Stephen Toub.
You probably also want to read "Should I Expose Asynchronous Wrappers for Synchronous Methods?" In short, the answer is "no."
提煉Bundle模塊:一種WPF MVVM/MEF程序架構(gòu)的優(yōu)化設(shè)計
MVVM+MEF架構(gòu)的一個缺點是:VIEW MODEL類以及直接相關(guān)的類做的事情太多,且不能作為獨立代碼進(jìn)行單獨測試,必須依賴于MEF容器(這就依賴于所有其它類的對象了)。本文介紹的設(shè)計方法解決了這個問題,使得新的功能開發(fā)更容易分工和測試。不過,本文尚需在TDD測試驅(qū)動開發(fā)、測試時使用mock等技術(shù)方面去尋找正確理論和實踐,以求讓Bundle方法找到自己的真實定位:是一種新方法,還是僅僅自己的方式,甚或比別人的方法還不如?


