コード例 #1
0
        public void OpenFileViaCommandLine()
        {
            MockEnvironmentService environmentService = Container.GetExportedValue <MockEnvironmentService>();

            environmentService.DocumentFileName = "Document.mock";

            var controller = Container.GetExportedValue <ModuleController>();

            controller.Initialize();


            // Open the 'Document.mock' file
            controller.Run();

            // Open a file with an unknown file extension and check if an error message is shown.
            environmentService.DocumentFileName = "Unknown.fileExtension";
            MockMessageService messageService = Container.GetExportedValue <MockMessageService>();

            messageService.Clear();

            controller.Run();

            Assert.AreEqual(MessageType.Error, messageService.MessageType);
            Assert.IsFalse(string.IsNullOrEmpty(messageService.Message));
        }
コード例 #2
0
        public void ShellViewModelBasicTest()
        {
            MockShellView      shellView      = Container.GetExportedValue <MockShellView>();
            MockMessageService messageService = Container.GetExportedValue <MockMessageService>();
            IShellService      shellService   = Container.GetExportedValue <IShellService>();
            ShellViewModel     shellViewModel = Container.GetExportedValue <ShellViewModel>();

            // The title isn't available in the unit test environment.
            Assert.AreEqual("", shellViewModel.Title);

            Assert.AreEqual(shellService, shellViewModel.ShellService);

            // Show the ShellView
            shellViewModel.Show();
            Assert.IsTrue(shellView.IsVisible);

            // Show the about message box
            messageService.Clear();
            shellViewModel.AboutCommand.Execute(null);
            Assert.IsFalse(string.IsNullOrEmpty(messageService.Message));
            Assert.AreEqual(MessageType.Message, messageService.MessageType);

            // Close the ShellView
            bool closingEventRaised = false;

            shellViewModel.Closing += (sender, e) =>
            {
                closingEventRaised = true;
            };
            shellViewModel.Close();
            Assert.IsFalse(shellView.IsVisible);
            Assert.IsTrue(closingEventRaised);
        }
コード例 #3
0
        public void ShowQuestionTest()
        {
            var messageService = new MockMessageService();

            var message = "Hello World";

            AssertHelper.ExpectedException <ArgumentNullException>(() => MessageServiceExtensions.ShowQuestion(null !, message));
            AssertHelper.ExpectedException <ArgumentNullException>(() => MessageServiceExtensions.ShowYesNoQuestion(null !, message));

            bool showQuestionCalled = false;

            messageService.ShowQuestionAction = m =>
            {
                showQuestionCalled = true;
                Assert.AreEqual(message, m);
                return(true);
            };
            Assert.IsTrue(messageService.ShowQuestion(message) == true);
            Assert.IsTrue(showQuestionCalled);

            showQuestionCalled = false;
            messageService.Clear();
            messageService.ShowYesNoQuestionAction = m =>
            {
                showQuestionCalled = true;
                Assert.AreEqual(message, m);
                return(true);
            };
            Assert.IsTrue(messageService.ShowYesNoQuestion(message));
            Assert.IsTrue(showQuestionCalled);
        }
コード例 #4
0
        public void ShowAndClose()
        {
            MockMessageService messageService = Container.GetExportedValue <MockMessageService>();
            MockShellView      shellView      = (MockShellView)Container.GetExportedValue <IShellView>();
            ShellViewModel     shellViewModel = Container.GetExportedValue <ShellViewModel>();

            // Show the ShellView
            Assert.IsFalse(shellView.IsVisible);
            shellViewModel.Show();
            Assert.IsTrue(shellView.IsVisible);

            Assert.AreNotEqual("", shellViewModel.Title);

            // Try to close the ShellView but cancel this operation through the closing event
            bool cancelClosing = true;

            shellViewModel.Closing += (sender, e) =>
            {
                e.Cancel = cancelClosing;
            };
            shellViewModel.Close();
            Assert.IsTrue(shellView.IsVisible);

            // Close the ShellView via the ExitCommand
            cancelClosing = false;
            AssertHelper.PropertyChangedEvent(shellViewModel, x => x.ExitCommand, () =>
                                              shellViewModel.ExitCommand = new DelegateCommand(() => shellViewModel.Close()));
            shellViewModel.ExitCommand.Execute(null);
            Assert.IsFalse(shellView.IsVisible);
        }
コード例 #5
0
ファイル: FileControllerTest.cs プロジェクト: zwq00000/waf
        public void OpenDocumentViaCommandLineTest()
        {
            FileController fileController = Container.GetExportedValue <FileController>();
            IFileService   fileService    = Container.GetExportedValue <IFileService>();

            MockDocumentType documentType = new MockDocumentType("Mock Document", ".mock");

            fileController.Register(documentType);

            Assert.IsFalse(fileService.Documents.Any());
            Assert.IsNull(fileService.ActiveDocument);

            // Open is called with a fileName which might be a command line parameter.
            fileService.OpenCommand.Execute("Document1.mock");
            IDocument document = fileService.Documents.Last();

            Assert.AreEqual("Document1.mock", document.FileName);

            Assert.IsTrue(fileService.Documents.SequenceEqual(new[] { document }));
            Assert.AreEqual(document, fileService.ActiveDocument);

            // Call open with a fileName that has an invalid extension
            MockMessageService messageService = Container.GetExportedValue <MockMessageService>();

            messageService.Clear();
            fileService.OpenCommand.Execute("Document.wrongextension");
            Assert.AreEqual(MessageType.Error, messageService.MessageType);
            Assert.IsFalse(string.IsNullOrEmpty(messageService.Message));

            // Call open with a fileName that doesn't exist
            messageService.Clear();
            fileService.OpenCommand.Execute("2i0501fh-89f1-4197-a318-d5241135f4f6.rtf");
            Assert.AreEqual(MessageType.Error, messageService.MessageType);
            Assert.IsFalse(string.IsNullOrEmpty(messageService.Message));
        }
コード例 #6
0
        public void ModuleControllerIsInvalidTest()
        {
            MockMessageService   messageService   = Container.GetExportedValue <MockMessageService>();
            MockEntityController entityController = Container.GetExportedValue <MockEntityController>();
            ModuleController     moduleController = Container.GetExportedValue <ModuleController>();

            moduleController.Initialize();
            moduleController.Run();

            MockShellView  shellView      = Container.GetExportedValue <MockShellView>();
            ShellViewModel shellViewModel = ViewHelper.GetViewModel <ShellViewModel>(shellView);


            // Exit the application although we have unsaved changes.
            entityController.HasChangesResult = true;
            // Simulate UI errors.
            entityController.CanSaveResult = false;
            // When the question box asks us to loose our changes we say "No" => false.
            messageService.ShowYesNoQuestionAction = (message) =>
            {
                Assert.AreEqual(Resources.LoseChangesQuestion, message);
                return(false);
            };
            shellViewModel.ExitCommand.Execute(null);
            // We expect the ShellView to stay open.
            Assert.IsTrue(shellView.IsVisible);


            // Exit the application again but this time we agree to loose our changes.
            messageService.ShowYesNoQuestionAction = (message) => true;
            shellViewModel.ExitCommand.Execute(null);
            Assert.IsFalse(shellView.IsVisible);
        }
コード例 #7
0
        public void ShowQuestionTest()
        {
            MockMessageService messageService = new MockMessageService();

            string message = "Hello World";
            AssertHelper.ExpectedException<ArgumentNullException>(() => MessageServiceExtensions.ShowQuestion(null, message));
            AssertHelper.ExpectedException<ArgumentNullException>(() => MessageServiceExtensions.ShowYesNoQuestion(null, message));

            bool showQuestionCalled = false;
            messageService.ShowQuestionAction = m =>
            {
                showQuestionCalled = true;
                Assert.AreEqual(message, m);
                return true;
            };
            Assert.IsTrue(messageService.ShowQuestion(message) == true);
            Assert.IsTrue(showQuestionCalled);

            showQuestionCalled = false;
            messageService.Clear();
            messageService.ShowYesNoQuestionAction = m =>
            {
                showQuestionCalled = true;
                Assert.AreEqual(message, m);
                return true;
            };
            Assert.IsTrue(messageService.ShowYesNoQuestion(message) == true);
            Assert.IsTrue(showQuestionCalled);
        }
コード例 #8
0
        public void ShowQuestionTest()
        {
            var messageService = new MockMessageService();

            var view    = new object();
            var message = "Hello World";
            var format  = "Result: {0}";

            AssertHelper.ExpectedException <ArgumentNullException>(() => MessageServiceExtensions.ShowQuestion(null !, message));
            AssertHelper.ExpectedException <ArgumentNullException>(() => MessageServiceExtensions.ShowQuestion(null !, null, message));
            AssertHelper.ExpectedException <ArgumentNullException>(() => MessageServiceExtensions.ShowYesNoQuestion(null !, message));
            AssertHelper.ExpectedException <ArgumentNullException>(() => MessageServiceExtensions.ShowYesNoQuestion(null !, null, message));

            bool showQuestionCalled = false;

            messageService.ShowQuestionStub = (_, m) =>
            {
                showQuestionCalled = true;
                Assert.AreEqual(message, m);
                return(true);
            };
            Assert.IsTrue(messageService.ShowQuestion(message) == true);
            Assert.IsTrue(showQuestionCalled);

            showQuestionCalled = false;
            messageService.ShowQuestionStub = (o, m) =>
            {
                showQuestionCalled = true;
                Assert.AreSame(view, o);
                Assert.AreEqual(string.Format(CultureInfo.CurrentCulture, format, 42), m);
                return(true);
            };
            Assert.IsTrue(messageService.ShowQuestion(view, format, 42) == true);
            Assert.IsTrue(showQuestionCalled);

            showQuestionCalled = false;
            messageService.Clear();
            messageService.ShowYesNoQuestionStub = (_, m) =>
            {
                showQuestionCalled = true;
                Assert.AreEqual(message, m);
                return(true);
            };
            Assert.IsTrue(messageService.ShowYesNoQuestion(message));
            Assert.IsTrue(showQuestionCalled);

            showQuestionCalled = false;
            messageService.Clear();
            messageService.ShowYesNoQuestionStub = (o, m) =>
            {
                showQuestionCalled = true;
                Assert.AreSame(view, o);
                Assert.AreEqual(string.Format(CultureInfo.CurrentCulture, format, 42), m);
                return(true);
            };
            Assert.IsTrue(messageService.ShowYesNoQuestion(view, format, 42));
            Assert.IsTrue(showQuestionCalled);
        }
コード例 #9
0
        public PactConsumerTestSetup MockVerifyAndClearInteractions()
        {
            MockMessageService.VerifyInteractions();
            _output.WriteLine("Interactions Verified.");
            MockMessageService.ClearInteractions();
            _output.WriteLine("Interactions Cleared.");

            return(this);
        }
コード例 #10
0
 public void Init()
 {
     processRunner      = new MockProcessRunner();
     testResultsMonitor = new MockTestResultsMonitor();
     options            = new UnitTestingOptions(new Properties());
     fileSystem         = new MockFileSystem();
     messageService     = new MockMessageService();
     testRunner         = new DerivedCodeCoverageTestRunner(processRunner, testResultsMonitor, options, fileSystem, messageService);
 }
コード例 #11
0
        public void CreateNewEmailTest()
        {
            Person harry = new Person()
            {
                Firstname = "Harry", Email = "*****@*****.**"
            };
            Person ron = new Person()
            {
                Firstname = "Ron", Email = "Wrong Address"
            };

            IEntityService entityService = Container.GetExportedValue <IEntityService>();

            entityService.Persons.Add(harry);
            entityService.Persons.Add(ron);

            PersonController personController = Container.GetExportedValue <PersonController>();

            personController.Initialize();

            MockPersonListView  personListView      = Container.GetExportedValue <MockPersonListView>();
            PersonListViewModel personListViewModel = ViewHelper.GetViewModel <PersonListViewModel>(personListView);
            MockPersonView      personView          = Container.GetExportedValue <MockPersonView>();
            PersonViewModel     personViewModel     = ViewHelper.GetViewModel <PersonViewModel>(personView);

            ICommand command = personListViewModel.CreateNewEmailCommand;

            Assert.AreEqual(command, personViewModel.CreateNewEmailCommand);

            MockEmailService emailService = Container.GetExportedValue <MockEmailService>();

            command.Execute(harry);
            Assert.AreEqual(harry.Email, emailService.ToEmailAddress);

            // An error message should occur when the email address is invalid.

            MockMessageService messageService = Container.GetExportedValue <MockMessageService>();

            messageService.Clear();
            emailService.ToEmailAddress = null;
            command.Execute(ron);
            Assert.AreEqual(MessageType.Error, messageService.MessageType);
            Assert.AreEqual(Resources.CorrectEmailAddress, messageService.Message);
            Assert.IsNull(emailService.ToEmailAddress);

            // An error message should occur when no email address was entered.

            messageService.Clear();
            emailService.ToEmailAddress = null;
            ron.Email = null;
            command.Execute(ron);
            Assert.AreEqual(MessageType.Error, messageService.MessageType);
            Assert.AreEqual(Resources.CorrectEmailAddress, messageService.Message);
            Assert.IsNull(emailService.ToEmailAddress);
        }
コード例 #12
0
        public void ModuleControllerHasChangesTest()
        {
            MockMessageService   messageService   = Container.GetExportedValue <MockMessageService>();
            MockEntityController entityController = Container.GetExportedValue <MockEntityController>();
            ModuleController     moduleController = Container.GetExportedValue <ModuleController>();

            moduleController.Initialize();
            moduleController.Run();

            MockShellView  shellView      = Container.GetExportedValue <MockShellView>();
            ShellViewModel shellViewModel = ViewHelper.GetViewModel <ShellViewModel>(shellView);


            // Exit the application although we have unsaved changes.
            entityController.HasChangesResult = true;
            // When the question box asks us to save the changes we say "Yes" => true.
            messageService.ShowQuestionAction = (message) =>
            {
                Assert.AreEqual(Resources.SaveChangesQuestion, message);
                return(true);
            };
            // Then we simulate that the EntityController wasn't able to save the changes.
            entityController.SaveResult = false;
            shellViewModel.ExitCommand.Execute(null);
            // The Save method must be called. Because the save operation failed the expect the ShellView to be
            // still visible.
            Assert.IsTrue(entityController.SaveCalled);
            Assert.IsTrue(shellView.IsVisible);


            // Exit the application although we have unsaved changes.
            entityController.HasChangesResult = true;
            entityController.SaveCalled       = false;
            // When the question box asks us to save the changes we say "Cancel" => null.
            messageService.ShowQuestionAction = (message) => null;
            // This time the Save method must not be called. Because we have chosen "Cancel" the ShellView must still
            // be visible.
            shellViewModel.ExitCommand.Execute(null);
            Assert.IsFalse(entityController.SaveCalled);
            Assert.IsTrue(shellView.IsVisible);


            // Exit the application although we have unsaved changes.
            entityController.HasChangesResult = true;
            entityController.SaveCalled       = false;
            // When the question box asks us to save the changes we say "No" => false.
            messageService.ShowQuestionAction = (message) => false;
            // This time the Save method must not be called. Because we have chosen "No" the ShellView must still
            // be closed.
            shellViewModel.ExitCommand.Execute(null);
            Assert.IsFalse(entityController.SaveCalled);
            Assert.IsFalse(shellView.IsVisible);
        }
コード例 #13
0
 void CreateTestDebugger()
 {
     debuggerService        = new MockDebuggerService();
     debugger               = debuggerService.MockDebugger;
     messageService         = new MockMessageService();
     testResultsMonitor     = new MockTestResultsMonitor();
     options                = new PythonAddInOptions(new Properties());
     options.PythonFileName = @"c:\ironpython\ipy.exe";
     standardLibraryPath    = new PythonStandardLibraryPath(@"c:\python\lib");
     fileService            = new MockScriptingFileService();
     testDebugger           = new PythonTestDebugger(debuggerService, messageService, testResultsMonitor, options, standardLibraryPath, fileService);
 }
コード例 #14
0
 void CreateTestDebugger()
 {
     debuggerService    = new MockDebuggerService();
     debugger           = debuggerService.MockDebugger;
     messageService     = new MockMessageService();
     testResultsMonitor = new MockTestResultsMonitor();
     testResultsMonitor.InitialFilePosition = 3;
     options = new RubyAddInOptions(new Properties());
     options.RubyFileName = @"c:\ironruby\ir.exe";
     fileService          = new MockScriptingFileService();
     testDebugger         = new RubyTestDebugger(debuggerService, messageService, testResultsMonitor, options, fileService);
 }
        public void Init()
        {
            selectedTests = SelectedTestsHelper.CreateSelectedTestMember();
            FileUtility.ApplicationRootPath = @"C:\SharpDevelop";

            messageService              = new MockMessageService();
            debuggerService             = new MockDebuggerService();
            debugger                    = debuggerService.MockDebugger;
            testResultsMonitor          = new MockTestResultsMonitor();
            testResultsMonitor.FileName = @"c:\temp\tmp66.tmp";
            options          = new UnitTestingOptions(new Properties());
            options.NoShadow = true;
            testDebugger     = new NUnitTestDebugger(debuggerService, messageService, testResultsMonitor, options);
        }
        void CreateTestRunner()
        {
            processRunner      = new MockProcessRunner();
            testResultsMonitor = new MockTestResultsMonitor();
            testResultsMonitor.InitialFilePosition = 3;
            options = new RubyAddInOptions(new Properties());
            options.RubyFileName = @"c:\ironruby\ir.exe";
            fileService          = new MockScriptingFileService();
            MockMessageService messageService = new MockMessageService();

            RubyTestRunnerContext context = new RubyTestRunnerContext(processRunner, testResultsMonitor, options, fileService, messageService);

            testRunner = new RubyTestRunner(context);
        }
コード例 #17
0
        public PactConsumerTestSetup MockExpectedResponse(dynamic messageContract)
        {
            MockMessageService
            .WillRespondWith(new ProviderServiceResponse
            {
                Status  = 200,
                Headers = new Dictionary <string, object>()
                {
                    { "Content-Type", "application/json; charset=utf-8" }
                },
                Body = messageContract
            });

            return(this);
        }
コード例 #18
0
        public void ShowMessageTest()
        {
            var messageService = new MockMessageService();

            var view    = new object();
            var message = "Hello World";
            var format  = "Result: {0}";

            AssertHelper.ExpectedException <ArgumentNullException>(() => MessageServiceExtensions.ShowMessage(null !, message));
            AssertHelper.ExpectedException <ArgumentNullException>(() => MessageServiceExtensions.ShowMessage(null !, null, message));
            AssertHelper.ExpectedException <ArgumentNullException>(() => MessageServiceExtensions.ShowWarning(null !, message));
            AssertHelper.ExpectedException <ArgumentNullException>(() => MessageServiceExtensions.ShowWarning(null !, null, message));
            AssertHelper.ExpectedException <ArgumentNullException>(() => MessageServiceExtensions.ShowError(null !, message));
            AssertHelper.ExpectedException <ArgumentNullException>(() => MessageServiceExtensions.ShowError(null !, null, message));

            messageService.ShowMessage(message);
            Assert.AreEqual(MessageType.Message, messageService.MessageType);
            Assert.AreEqual(message, messageService.Message);

            messageService.Clear();
            messageService.ShowMessage(view, format, 42);
            Assert.AreSame(view, messageService.Owner);
            Assert.AreEqual(MessageType.Message, messageService.MessageType);
            Assert.AreEqual(string.Format(CultureInfo.CurrentCulture, format, 42), messageService.Message);

            messageService.Clear();
            messageService.ShowWarning(message);
            Assert.AreEqual(MessageType.Warning, messageService.MessageType);
            Assert.AreEqual(message, messageService.Message);

            messageService.Clear();
            messageService.ShowWarning(view, format, 42);
            Assert.AreSame(view, messageService.Owner);
            Assert.AreEqual(MessageType.Warning, messageService.MessageType);
            Assert.AreEqual(string.Format(CultureInfo.CurrentCulture, format, 42), messageService.Message);

            messageService.Clear();
            messageService.ShowError(message);
            Assert.AreEqual(MessageType.Error, messageService.MessageType);
            Assert.AreEqual(message, messageService.Message);

            messageService.Clear();
            messageService.ShowError(view, format, 42);
            Assert.AreSame(view, messageService.Owner);
            Assert.AreEqual(MessageType.Error, messageService.MessageType);
            Assert.AreEqual(string.Format(CultureInfo.CurrentCulture, format, 42), messageService.Message);
        }
コード例 #19
0
        public PactConsumerTestSetup MockPreconditions(string given, string uponReceiving)
        {
            MockMessageService.Given(given)
            .UponReceiving(uponReceiving)
            .With(new ProviderServiceRequest
            {
                Method  = HttpVerb.Get,
                Path    = "/servicebusmock/message",
                Headers = new Dictionary <string, object>
                {
                    { "Accept", "application/json" }
                },
                Query = ""
            });

            return(this);
        }
        void CreateTestRunner()
        {
            processRunner          = new MockProcessRunner();
            testResultsMonitor     = new MockTestResultsMonitor();
            options                = new PythonAddInOptions(new Properties());
            options.PythonFileName = @"c:\ironpython\ipy.exe";
            fileService            = new MockScriptingFileService();
            messageService         = new MockMessageService();
            standardLibraryPath    = new PythonStandardLibraryPath(@"c:\python\lib");
            PythonTestRunnerContext context = new PythonTestRunnerContext(processRunner,
                                                                          testResultsMonitor,
                                                                          messageService,
                                                                          options,
                                                                          standardLibraryPath,
                                                                          fileService);

            testRunner = new PythonTestRunner(context);
        }
コード例 #21
0
ファイル: FileControllerTest.cs プロジェクト: zwq00000/waf
        public void SaveDocumentTest()
        {
            MockFileDialogService fileDialogService = Container.GetExportedValue <MockFileDialogService>();
            FileController        fileController    = Container.GetExportedValue <FileController>();
            IFileService          fileService       = Container.GetExportedValue <IFileService>();
            MockDocumentType      documentType      = new MockDocumentType("Mock Document", ".mock");

            fileController.Register(documentType);
            fileController.New(documentType);
            IDocument document = fileService.Documents.Single();

            document.FileName = "Document.mock";

            fileDialogService.Result = new FileDialogResult("Document1.mock", new FileType("Mock Document", ".mock"));
            fileService.SaveAsCommand.Execute(null);

            Assert.AreEqual(FileDialogType.SaveFileDialog, fileDialogService.FileDialogType);
            Assert.AreEqual("Mock Document", fileDialogService.FileTypes.Single().Description);
            Assert.AreEqual(".mock", fileDialogService.FileTypes.Single().FileExtension);
            Assert.AreEqual("Mock Document", fileDialogService.DefaultFileType.Description);
            Assert.AreEqual(".mock", fileDialogService.DefaultFileType.FileExtension);
            Assert.AreEqual("Document", fileDialogService.DefaultFileName);

            Assert.AreEqual(DocumentOperation.Save, documentType.DocumentOperation);
            Assert.AreEqual(document, documentType.Document);

            Assert.AreEqual("Document1.mock", documentType.FileName);

            // Change the CanSave to return false so that no documentType is able to save the document anymore

            documentType.CanSaveResult = false;
            Assert.IsFalse(fileService.SaveCommand.CanExecute(null));

            // Simulate an exception during the Save operation.

            MockMessageService messageService = Container.GetExportedValue <MockMessageService>();

            messageService.Clear();
            documentType.ThrowException = true;
            documentType.CanSaveResult  = true;
            fileService.SaveAsCommand.Execute(null);
            Assert.AreEqual(MessageType.Error, messageService.MessageType);
            Assert.IsFalse(string.IsNullOrEmpty(messageService.Message));
        }
コード例 #22
0
        public void ShowAndClose()
        {
            MockMessageService messageService = Container.GetExportedValue <MockMessageService>();
            MockShellView      shellView      = Container.GetExportedValue <MockShellView>();
            ShellViewModel     shellViewModel = Container.GetExportedValue <ShellViewModel>();

            // Show the ShellView
            Assert.IsFalse(shellView.IsVisible);
            shellViewModel.Show();
            Assert.IsTrue(shellView.IsVisible);

            // In this case it tries to get the title of the unit test framework which is ""
            Assert.AreEqual("", shellViewModel.Title);

            Assert.AreEqual(1d, shellViewModel.ShellService.ActiveZoomCommands.Zoom);

            // Show the About Dialog
            Assert.IsNull(messageService.Message);
            shellViewModel.AboutCommand.Execute(null);
            Assert.AreEqual(MessageType.Message, messageService.MessageType);
            Assert.IsNotNull(messageService.Message);

            // Try to close the ShellView but cancel this operation through the closing event
            bool cancelClosing = true;

            shellViewModel.Closing += (sender, e) =>
            {
                e.Cancel = cancelClosing;
            };
            shellViewModel.Close();
            Assert.IsTrue(shellView.IsVisible);

            // Close the ShellView via the ExitCommand
            cancelClosing = false;
            AssertHelper.PropertyChangedEvent(shellViewModel, x => x.ExitCommand, () =>
                                              shellViewModel.ExitCommand = new DelegateCommand(() => shellViewModel.Close()));
            shellViewModel.ExitCommand.Execute(null);
            Assert.IsFalse(shellView.IsVisible);
        }
コード例 #23
0
        public void ShowMessageTest()
        {
            MockMessageService messageService = new MockMessageService();

            string message = "Hello World";
            AssertHelper.ExpectedException<ArgumentNullException>(() => MessageServiceExtensions.ShowMessage(null, message));
            AssertHelper.ExpectedException<ArgumentNullException>(() => MessageServiceExtensions.ShowWarning(null, message));
            AssertHelper.ExpectedException<ArgumentNullException>(() => MessageServiceExtensions.ShowError(null, message));

            messageService.ShowMessage(message);
            Assert.AreEqual(MessageType.Message, messageService.MessageType);
            Assert.AreEqual(message, messageService.Message);

            messageService.Clear();
            messageService.ShowWarning(message);
            Assert.AreEqual(MessageType.Warning, messageService.MessageType);
            Assert.AreEqual(message, messageService.Message);

            messageService.Clear();
            messageService.ShowError(message);
            Assert.AreEqual(MessageType.Error, messageService.MessageType);
            Assert.AreEqual(message, messageService.Message);
        }
コード例 #24
0
        public void ShowMessageTest()
        {
            var messageService = new MockMessageService();

            var message = "Hello World";

            AssertHelper.ExpectedException <ArgumentNullException>(() => MessageServiceExtensions.ShowMessage(null !, message));
            AssertHelper.ExpectedException <ArgumentNullException>(() => MessageServiceExtensions.ShowWarning(null !, message));
            AssertHelper.ExpectedException <ArgumentNullException>(() => MessageServiceExtensions.ShowError(null !, message));

            messageService.ShowMessage(message);
            Assert.AreEqual(MessageType.Message, messageService.MessageType);
            Assert.AreEqual(message, messageService.Message);

            messageService.Clear();
            messageService.ShowWarning(message);
            Assert.AreEqual(MessageType.Warning, messageService.MessageType);
            Assert.AreEqual(message, messageService.Message);

            messageService.Clear();
            messageService.ShowError(message);
            Assert.AreEqual(MessageType.Error, messageService.MessageType);
            Assert.AreEqual(message, messageService.Message);
        }
コード例 #25
0
 public void Init()
 {
     this.messageService = new MockMessageService();
     this.view           = new MockRockListView();
 }
コード例 #26
0
 public void Init()
 {
     messageService = new MockMessageService();
 }