/// <summary> /// ボタンイベント /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SearchButton_Click(object sender, System.EventArgs e) { try { _viewModel.Search(); } // innerExceptionに例外が発生したクラスの例外を通知する catch (Exception ex) { // 下記の処理は基底クラス(BaseForm)に移行し共通化 //MessageBoxIcon icon = MessageBoxIcon.Error; //string caption = "エラー"; //var exceptionBase = ex as ExceptionBase; //if(exceptionBase != null) { // if (exceptionBase.Kind == ExceptionBase.ExceptionKind.Info) { // icon = MessageBoxIcon.Information; // caption = "情報"; // } // else if(exceptionBase.Kind==ExceptionBase.ExceptionKind.Warning) { // icon = MessageBoxIcon.Warning; // caption = "警告"; // } //} //MessageBox.Show(ex.Message,caption,MessageBoxButtons.OK,icon); // 基底クラスに投げる(BaseForm) ExceptionProc(ex); } }
private void SearchButton_Click(object sender, EventArgs e) { try { _viewModel.Search(); } catch (Exception ex) { ExceptionProc(ex); } }
public void シナリオ() { var entity = new MeasureEntity(1, Convert.ToDateTime("2012/12/12 12:34:56"), 12.341f); var measureMock = new Mock <IMeasureRepository>(); var vm = new LatestViewModel(measureMock.Object); measureMock.Setup(x => x.GetLatest()).Returns(entity); vm.Search(); vm.AreaIDText.Is("0001"); vm.MeasureDateText.Is("2012/12/12 12:34:56"); vm.MeasureValueText.Is("12.34℃"); }
public void シナリオ() { // モックのデータを作成 var entity = new MeasureEntity( 1, Convert.ToDateTime("2020/05/26 22:00:00"), 12.34f); // Moqセット var measureMock = new Mock <IMeasureRepository>(); measureMock.Setup(x => x.GetLatest()).Returns(entity); var vm = new LatestViewModel(measureMock.Object); // エリアID // 計測日時 // 計測値 vm.Search(); vm.AreaIdText.Is("001"); vm.MeasureDateText.Is("2020/05/26 22:00:00"); vm.MeasureValueText.Is("12.34℃"); }
private void SearchButton_Click(object sender, System.EventArgs e) { _viewModel.Search(); }