我是单元测试用例写作的新手.我在WPF中使用MVVMLigh.是否有必要使用一些第三方测试框架或.Net Unit测试框架呢?另外如何在单元测试用例中处理静态类?在这种情况下AppMessages类.
有人可以指导我如何编写以下代码的单元格:
public MyViewModel(Participant participant)
{
if (participant != null)
{
this.ParentModel = parentModel;
OkCommand = new RelayCommand(() => OkCommandExecute());
CalculateAmountCommand = new RelayCommand(() => CalculateAmount());
}
else
{
ExceptionLogger.Instance.LogException(Constants.ErrorMessages.FinancialLineCanNotBeNull, "FinancialLineViewModel");
AppMessages.DisplayDialogMessage.Send(Constants.ErrorMessages.FinancialLineCanNotBeNull, MessageBoxButton.OK, Constants.DefaultCaption, null);
}
}
public static class AppMessages
{
enum AppMessageTypes
{
FinancialLineViewDisplay,
FinancialLineViewClose,
DisplayDialogMessage
}
public static class DisplayDialogMessage
{
public static void Send(string message, MessageBoxButton button, string caption, System.Action<MessageBoxResult> action)
{
DialogMessage dialogMessage = new DialogMessage(message, action)
{
Button = button,
Caption = caption …Run Code Online (Sandbox Code Playgroud) 我有一个包含ComboBox作为列的DataGrid.
让我们考虑DataGrid将ItemsSource作为ObservableCollection而ComboBox ItemsSource是List.
我想基于DataGrid ItemsSource中的属性设置ComboBox SelectedItem属性.
但是,Product类具有类型为int而不是ProductType的属性ProductTypeId.
那么如何设置ComboBox SelectedItem以使其显示Product.ProductTypeId的值.而且我想将SeletedItems与Mode = TwoWay绑定,这样每当ComboBox SelectedItem发生变化时,它都会反映在DataGrid的ItemsSource中.
任何帮助将非常感激.
谢谢.