コード例 #1
0
 private void RadUpload_FileUploadFailed(object sender, FileUploadFailedEventArgs e)
 {
     Status_EventEnter("FileUploadFailed");
     e.ErrorMessage = "My Message";
     Status_Write("Failed Message:" + e.HandlerData.Message);
     Status_EventEnd("FileUploadFailed");
 }
コード例 #2
0
        public void OnUploadFailed()
        {
            // arrange
            var vm = new FieldFileViewModel();

            var fileProcess = Mock.Create<IFileProcess>(Behavior.Loose);
            fileProcess.IsUploading = true;
            fileProcess.FileName = "8AAC798B-ED88-4366-AF0A-5E727111A9CB.txt";
            fileProcess.OriginalFileName = "1.txt";
            Mock.NonPublic.Arrange<IFileProcess>(vm, "CurrentFileProcess").Returns(fileProcess);

            var e = new FileUploadFailedEventArgs(null, null, new Exception().ToString());

            // act
            vm.OnUploadFailed(null, e);

            // assert
            Assert.IsFalse(fileProcess.IsUploading);
            Assert.IsNull(fileProcess.OriginalFileName);
            Assert.IsNull(fileProcess.FileName);

            var privateAccessor = new PrivateAccessor(vm);
            Assert.IsTrue((bool)privateAccessor.GetProperty("UploadError"));

            Assert.AreEqual("Invalid System Paths. Contact your administrator, please.", vm.Message);

            Assert.AreEqual(new Exception().ToString(), privateAccessor.GetProperty("ExceptionMessage"));
            Assert.AreEqual(FileControlMode.NotifyFail, vm.CurrentState);
        }
コード例 #3
0
        private void OnFileUploadFailed(object sender, FileUploadFailedEventArgs e)
        {
            Action action = () =>
                {
                    var paperclipsViewModel = DataContext as IPaperclipsViewModel;

                    if (paperclipsViewModel != null)
                        paperclipsViewModel.OnFileUploadFailed(sender, e);
                };

            if (Dispatcher.CheckAccess())
                action();
            else
                Dispatcher.BeginInvoke(action);
        }