Exemple #1
0
        public void OpenExistingSkippedTest()
        {
            const string       DefaultExt       = "uamdsl";
            const string       Filter           = "UA Model Designer Solution File (* .uamdsl)|*.uamdsl|UA Model Designer Solution File (* .xml)|*.xml|All files(*.*)|*.*";
            const string       Title            = "UA Model Designer Solution Open/Save dialog window";
            Mock <IFileDialog> _IFileDialogMock = new Mock <IFileDialog>();

            _IFileDialogMock.SetupProperty(x => x.DefaultExt);
            _IFileDialogMock.SetupProperty(x => x.Filter);
            _IFileDialogMock.SetupProperty(x => x.Title);
            _IFileDialogMock.Setup(x => x.ShowDialog()).Returns(false);
            Mock <IGraphicalUserInterface> _guiMock = new Mock <IGraphicalUserInterface>();

            _guiMock.SetupGet(x => x.OpenFileDialogFunc).Returns(() => _IFileDialogMock.Object);
            _guiMock.SetupGet(x => x.MessageBoxShowWarningAskYN).Returns(() => (x, y) => true);
            ISolutionConfigurationManagement    _instance      = null;
            SolutionConfigurationManagementRoot _freshInstance = null;

            SolutionConfigurationManagementRoot.GetInstance(c => _freshInstance = c);
            _freshInstance.AfterSolutionChange += (x, y) => _instance = y.Solution;
            SolutionConfigurationManagementRoot.OpenExisting(null, _guiMock.Object);
            _IFileDialogMock.VerifySet(x => x.DefaultExt       = DefaultExt, Times.Never);
            _IFileDialogMock.VerifySet(x => x.Filter           = Filter, Times.Never);
            _IFileDialogMock.VerifySet(x => x.Title            = Title, Times.Never);
            _IFileDialogMock.VerifySet(x => x.FileName         = It.IsAny <string>(), Times.Never);
            _IFileDialogMock.VerifySet(x => x.InitialDirectory = It.IsAny <string>(), Times.Never);
            _IFileDialogMock.Verify(x => x.ShowDialog(), Times.Never);
            _IFileDialogMock.Verify(x => x.Dispose(), Times.Never);
        }
Exemple #2
0
        public void OpenExistingFileExistTest()
        {
            Mock <IFileDialog> _IFileDialogMock = new Mock <IFileDialog>();

            _IFileDialogMock.Setup(x => x.ShowDialog()).Returns(false);
            Mock <IGraphicalUserInterface> _guiMock = new Mock <IGraphicalUserInterface>();

            _guiMock.SetupSet(x => x.UseWaitCursor = It.IsAny <bool>());
            _guiMock.SetupGet(x => x.OpenFileDialogFunc).Returns(() => _IFileDialogMock.Object);
            _guiMock.SetupGet(x => x.MessageBoxShowWarningAskYN).Returns(() => (x, y) => true);
            ISolutionConfigurationManagement    _instance      = null;
            SolutionConfigurationManagementRoot _freshInstance = null;

            SolutionConfigurationManagementRoot.GetInstance(c => _freshInstance = c);
            _freshInstance.AfterSolutionChange += (x, y) => _instance = y.Solution;
            SolutionConfigurationManagementRoot.OpenExisting(@"TestData\EmptySolution.uamdsl", _guiMock.Object);
            Assert.IsNotNull(_instance);
            Assert.IsFalse(_instance.ChangesArePresent);
            Assert.AreEqual <string>(Path.Combine(Directory.GetCurrentDirectory(), @"TestData\EmptySolution.uamdsl"), _instance.DefaultFileName);
            _IFileDialogMock.Verify(x => x.DefaultExt, Times.Never);
            _IFileDialogMock.Verify(x => x.Filter, Times.Never);
            _IFileDialogMock.Verify(x => x.Title, Times.Never);
            _IFileDialogMock.Verify(x => x.FileName, Times.Never);
            _IFileDialogMock.VerifySet(x => x.InitialDirectory = It.IsAny <string>(), Times.Never);
            _IFileDialogMock.Verify(x => x.ShowDialog(), Times.Never);
            _IFileDialogMock.Verify(x => x.Dispose(), Times.Never);
            _guiMock.Verify(x => x.MessageBoxShowWarningAskYN, Times.Never);
            _guiMock.VerifySet(x => x.UseWaitCursor = It.IsAny <bool>(), Times.Exactly(2));
        }
Exemple #3
0
 public void Open(IGraphicalUserInterface gui)
 {
     SolutionConfigurationManagementRoot.OpenExisting(null, gui);
 }