Exemplo n.º 1
0
        public void GetTargetFileLocation_CancelClicked_ResultFileSelectedIsFalse()
        {
            // Setup
            dialogParent.Expect(d => d.Handle).Repeat.AtLeastOnce().Return(default(IntPtr));
            mocks.ReplayAll();

            var helper = new DialogBasedInquiryHelper(dialogParent);

            DialogBoxHandler = (name, wnd) =>
            {
                var tester = new SaveFileDialogTester(wnd);
                tester.ClickCancel();
            };

            // Call
            string result = helper.GetTargetFileLocation(new FileFilterGenerator().Filter, null);

            // Assert
            Assert.IsNull(result);
        }
Exemplo n.º 2
0
        public void GetTargetFileLocation_FileSelected_ResultFileSelectedIsTrueFileNameSet()
        {
            // Setup
            dialogParent.Expect(d => d.Handle).Repeat.AtLeastOnce().Return(default(IntPtr));
            mocks.ReplayAll();

            var    helper           = new DialogBasedInquiryHelper(dialogParent);
            string expectedFilePath = Path.GetFullPath(Path.GetRandomFileName());

            DialogBoxHandler = (name, wnd) =>
            {
                var tester = new SaveFileDialogTester(wnd);
                tester.SaveFile(expectedFilePath);
            };

            // Call
            string result = helper.GetTargetFileLocation(new FileFilterGenerator().Filter, null);

            // Assert
            Assert.AreEqual(expectedFilePath, result);
        }
Exemplo n.º 3
0
        public void GetTargetFileLocation_Always_ShowsOpenFileDialog()
        {
            // Setup
            dialogParent.Expect(d => d.Handle).Repeat.AtLeastOnce().Return(default(IntPtr));
            mocks.ReplayAll();

            var helper = new DialogBasedInquiryHelper(dialogParent);

            string windowName = null;

            DialogBoxHandler = (name, wnd) =>
            {
                var tester = new OpenFileDialogTester(wnd);
                windowName = name;
                tester.ClickCancel();
            };

            // Call
            helper.GetTargetFileLocation(new FileFilterGenerator().Filter, null);

            // Assert
            Assert.AreEqual("Opslaan als", windowName);
        }