Exemplo n.º 1
0
        public void Cancel_WhenImportingAndUncancelable_ImportActivityStateExecuted()
        {
            // Setup
            var mocks        = new MockRepository();
            var fileImporter = mocks.Stub <IFileImporter>();

            fileImporter.Stub(x => x.SetProgressChanged(null)).IgnoreArguments();
            fileImporter.Stub(i => i.Import()).Return(true);
            mocks.ReplayAll();

            var fileImportActivity = new FileImportActivity(fileImporter, "");

            fileImportActivity.ProgressChanged += (sender, args) =>
            {
                if (fileImportActivity.State != ActivityState.Canceled)
                {
                    // Call
                    fileImportActivity.Cancel();
                }
            };

            // Assert
            fileImportActivity.Run();
            Assert.AreEqual(ActivityState.Executed, fileImportActivity.State);
            mocks.VerifyAll();
        }
Exemplo n.º 2
0
        public void Cancel_FileImportActivityWithFileImporter_CancelsImporter()
        {
            // Setup
            var mocks        = new MockRepository();
            var fileImporter = mocks.Stub <IFileImporter>();

            fileImporter.Stub(x => x.SetProgressChanged(null)).IgnoreArguments();
            fileImporter.Expect(x => x.Cancel());
            mocks.ReplayAll();

            var fileImportActivity = new FileImportActivity(fileImporter, "");

            // Call
            fileImportActivity.Cancel();

            // Assert
            mocks.VerifyAll();
        }
Exemplo n.º 3
0
        public void Cancel_WhenImportingAndCancelable_ImportActivityStateCanceled()
        {
            // Setup
            var fileImporter       = new SimpleFileImporter <object>(new object());
            var fileImportActivity = new FileImportActivity(fileImporter, "");

            fileImportActivity.ProgressChanged += (sender, args) =>
            {
                if (fileImportActivity.State != ActivityState.Canceled)
                {
                    // Call
                    fileImportActivity.Cancel();
                }
            };

            // Assert
            fileImportActivity.Run();
            Assert.AreEqual(ActivityState.Canceled, fileImportActivity.State);
        }