Exemplo n.º 1
0
        public void GetSourceFileLocation_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 OpenFileDialogTester(wnd);
                tester.ClickCancel();
            };

            // Call
            string result = helper.GetSourceFileLocation(new FileFilterGenerator().Filter);

            // Assert
            Assert.IsNull(result);
        }
Exemplo n.º 2
0
        public void GetSourceFileLocation_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.GetSourceFileLocation(new FileFilterGenerator().Filter);

            // Assert
            Assert.AreEqual("Openen", windowName);
        }
Exemplo n.º 3
0
        public void GetSourceFileLocation_ExistingFileSelected_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 OpenFileDialogTester(wnd);
                tester.OpenFile(expectedFilePath);
            };

            using (new FileDisposeHelper(expectedFilePath))
            {
                // Call
                string result = helper.GetSourceFileLocation(new FileFilterGenerator().Filter);

                // Assert
                Assert.AreEqual(expectedFilePath, result);
            }
        }