Exemplo n.º 1
0
        public void GetInquiryHelper_GuiIsNull_ThrowsInvalidOperationException()
        {
            // Setup
            var plugin = new SimplePlugin();

            // Call
            void Call() => plugin.GetInquiryHelperFromBase();

            // Assert
            var exception = Assert.Throws <InvalidOperationException>(Call);

            Assert.AreEqual("Gui cannot be null", exception.Message);
        }
Exemplo n.º 2
0
        public void GivenPluginWithGui_WhenGetInquiryHelperCalled_ThenAlwaysSameInquiryHelperReturned()
        {
            // Given
            var mocks      = new MockRepository();
            var mainWindow = mocks.Stub <IMainWindow>();
            var gui        = mocks.Stub <IGui>();

            gui.Stub(g => g.MainWindow).Return(mainWindow);
            mocks.ReplayAll();

            var plugin = new SimplePlugin
            {
                Gui = gui
            };

            // When
            IInquiryHelper inquiryHelper1 = plugin.GetInquiryHelperFromBase();
            IInquiryHelper inquiryHelper2 = plugin.GetInquiryHelperFromBase();

            // Then
            Assert.AreSame(inquiryHelper1, inquiryHelper2);
            mocks.VerifyAll();
        }
Exemplo n.º 3
0
        public void GetInquiryHelper_WithGui_ReturnsDialogBasedInquiryHelper()
        {
            // Setup
            var mocks      = new MockRepository();
            var mainWindow = mocks.Stub <IMainWindow>();
            var gui        = mocks.Stub <IGui>();

            gui.Stub(g => g.MainWindow).Return(mainWindow);
            mocks.ReplayAll();

            var plugin = new SimplePlugin
            {
                Gui = gui
            };

            // Call
            IInquiryHelper inquiryHelper = plugin.GetInquiryHelperFromBase();

            // Assert
            Assert.IsInstanceOf <DialogBasedInquiryHelper>(inquiryHelper);
            mocks.VerifyAll();
        }