public void StartExport()
        {
            // arrange
            var exportUtility = new ExportUtility();

            var exportViewModel = new ExportOptionsViewModel();
            exportUtility.TheExportOptionsViewModel = new Lazy<ExportOptionsViewModel>(() => exportViewModel);

            var shell = Mock.Create<IShell>(Behavior.Loose);
            exportUtility.TheWindowManager = new Lazy<IShell>(() => shell);

            var dynamicTypeManager = Mock.Create<IDynamicTypeManager>(Behavior.Loose);
            exportUtility.TheDynamicTypeManager = new Lazy<IDynamicTypeManager>(() => dynamicTypeManager);

            Mock.Arrange(() => Utils.CurrentUserAccountId).Returns(-1);

            var beginInsertEmailLogWasCalled = false;
            Mock.Arrange(() => MethodCaller.CallFactoryMethod(Arg.IsAny<Type>(), Arg.AnyString, Arg.IsAny<object[]>())).DoInstead(() => beginInsertEmailLogWasCalled = true);

            var popupFactory = new PopupFactory();

            var notifySuccessCalled = false;
            Mock.Arrange(() => popupFactory.NotifySuccess(LanguageService.Translate("Msg_ProcessExported"), "Popup_Success")).DoInstead(() => notifySuccessCalled = true);

            var notifyFailureCalled = false;
            Mock.Arrange(() => popupFactory.NotifyFailure(LanguageService.Translate("Msg_ExportError"), "Popup_Error", 3, false)).DoInstead(() => notifyFailureCalled = true);

            exportUtility.ThePopupFactory = new Lazy<PopupFactory>(() => popupFactory);

            var exportMethodWasCalled = false;
            Mock.NonPublic.Arrange<bool>(exportUtility, "Export", new object[] { ArgExpr.IsAny<GridViewDataControl>(), ArgExpr.IsAny<string>() }).DoInstead(() => exportMethodWasCalled = true).Returns(true);

            // act
            exportUtility.ExportStart("eCar_p", new GridViewDataControl(), "Id|CurrentState");

            // assert
            Assert.IsTrue(beginInsertEmailLogWasCalled);
            Assert.IsTrue(notifySuccessCalled);
            Assert.IsFalse(notifyFailureCalled);
            Assert.IsTrue(exportMethodWasCalled); // After exporting, we have to return it as it was, that is, back 25 info items

            // arrange
            notifySuccessCalled = notifyFailureCalled = false;
            Mock.NonPublic.Arrange<bool>(exportUtility, "Export", new object[] { ArgExpr.IsAny<GridViewDataControl>(), ArgExpr.IsAny<string>() }).Returns(false);

            // act
            exportUtility.ExportStart("eCar_p", new GridViewDataControl(), "Id|CurrentState");

            // assert
            Assert.IsFalse(notifySuccessCalled);
            Assert.IsTrue(notifyFailureCalled);
        }
        public void OnAfterDataRefreshed()
        {
            var vm = GetNewSearchListVm();

            var infoClass = Mock.Create<IInfoClass>(Behavior.Loose);
            Mock.Arrange(() => vm.InfoListViewSource).ReturnsCollection(new Collection<IInfoClass> { infoClass });
            
            var exportUtility = new ExportUtility();

            var exportStartWasCalled = false;
            Mock.Arrange(() => exportUtility.ExportStart(Arg.AnyString, Arg.IsAny<GridViewDataControl>(), Arg.AnyString)).DoInstead(() => exportStartWasCalled = true);

            var refreshSearchListWasCalled = false;
            Mock.Arrange(() => vm.RefreshSearchList(Arg.IsAny<IFilterViewModel>())).DoInstead(() => refreshSearchListWasCalled = true);

            vm.TheExportUtility = new Lazy<ExportUtility>(() => exportUtility);

            var privateAccessor = new PrivateAccessor(vm);
            privateAccessor.SetField("_tempPageSize", 25);
            privateAccessor.SetField("_tempPageIndex", 10);

            // act
            privateAccessor.CallMethod("OnAfterDataRefreshed", new[] { new object(), EventArgs.Empty});

            // assert
            Assert.IsTrue(exportStartWasCalled);
            Assert.IsTrue(refreshSearchListWasCalled);

            Assert.AreEqual(25, privateAccessor.GetField("_pageSize"));
            Assert.AreEqual(10, privateAccessor.GetField("_currentPageNumber"));

            // arrange
            exportStartWasCalled = false;
            Mock.Arrange(() => vm.InfoListViewSource).ReturnsCollection(new Collection<IInfoClass>());

            // act
            privateAccessor.CallMethod("OnAfterDataRefreshed", new[] { new object(), EventArgs.Empty});

            // assert
            Assert.IsFalse(exportStartWasCalled);
        }