Пример #1
0
        public void HistoryPresenter_ExportClick_Test()
        {
            // Arrange
            _database.Stub(x => x.Fetch(null, 0)).IgnoreArguments().Return(new HistoryEntry[0]);

            var saveFileDialogView = MockRepository.GenerateMock <ISaveFileDialogView>();

            saveFileDialogView.Expect(x => x.FileName).Return("test.csv");
            saveFileDialogView.Expect(x => x.FilterIndex).Return(1);
            saveFileDialogView.Expect(x => x.ShowDialog()).Return(DialogResult.OK);
            _viewFactory.Expect(x => x.GetSaveFileDialogView()).Return(saveFileDialogView);
            _viewFactory.Expect(x => x.Release(saveFileDialogView));

            var serializer = MockRepository.GenerateMock <IFileSerializer <List <HistoryEntry> > >();

            serializer.Expect(x => x.Serialize(null, null)).Constraints(new Equal("test.csv"), new TypeOf(typeof(List <HistoryEntry>)));
            // Act
            _presenter = CreatePresenter();
            _presenter.ExportSerializers = new[] { serializer };
            _presenter.ExportClick();
            // Assert
            _viewFactory.VerifyAllExpectations();
            saveFileDialogView.VerifyAllExpectations();
            serializer.VerifyAllExpectations();
        }
Пример #2
0
 private void mnuFileExport_Click(object sender, EventArgs e)
 {
     _presenter.ExportClick();
 }