Ejemplo n.º 1
0
        public void VerifyThatUriManagerViewModelWorks()
        {
            // Create tmp file
            Directory.CreateDirectory(this.tempfile.DirectoryName);
            this.testfile.CopyTo(this.tempfile.FullName, true);

            // Create an empty UriManagerViewModel
            var configViewModel = new UriManagerViewModel();
            int initialSize     = configViewModel.UriRowList.Count;

            // Create a new UriRowViewModel from a UriConfig
            var cl1 = new UriConfig()
            {
                Alias = "Alias1", Uri = "Uri1", DalType = "Web"
            };
            var row1 = new UriRowViewModel()
            {
                UriConfig = cl1
            };

            configViewModel.UriRowList.Add(row1);
            Assert.IsNotNull(configViewModel.UriRowList);
            Assert.IsTrue(configViewModel.UriRowList[initialSize].Alias.Equals("Alias1"));
            Assert.IsTrue(configViewModel.UriRowList[initialSize].Uri.Equals("Uri1"));
            Assert.IsTrue(configViewModel.UriRowList[initialSize].DalType == CDP4Dal.Composition.DalType.Web);

            // Create a new UriRowViewModel
            var row2 = new UriRowViewModel()
            {
                Uri = "Uri2", DalType = CDP4Dal.Composition.DalType.File
            };

            configViewModel.UriRowList.Add(row2);

            // Test get Name
            Assert.IsTrue(row2.Name.Equals("Uri2"));
            row2.Alias = "Alias2";
            Assert.IsTrue(row2.Name.Equals("Alias2"));

            // Test get UriConfig from a UriRowViewModel
            var cl2 = row2.UriConfig;

            Assert.IsTrue(cl2.Alias.Equals("Alias2"));
            Assert.IsTrue(cl2.Uri.Equals("Uri2"));
            Assert.IsTrue(cl2.DalType.Equals("File"));

            // Test there are 2 existing DalTypes
            Assert.IsTrue(configViewModel.DalTypesList.Count >= 2);

            // Test removing elemnt
            configViewModel.SelectedUriRow = row1;
            configViewModel.DeleteRowCommand.Execute(null);
            configViewModel.SelectedUriRow = row2;
            configViewModel.DeleteRowCommand.Execute(null);
            Assert.IsTrue(configViewModel.UriRowList.Count == initialSize);

            // Re-Save config file.
            configViewModel.ApplyCommand.Execute(0);
            Assert.IsTrue(File.Exists(new UriConfigFileHandler().ConfigurationFilePath));
        }
        public void AssertViewModelWorksWithMultipleUris()
        {
            var viewmodel = new DataSourceSelectionViewModel(this.navService.Object);

            Assert.IsTrue(viewmodel.CancelCommand.CanExecute(null));
            Assert.That(viewmodel.ErrorMessage, Is.Null.Or.Empty);

            Assert.IsNotEmpty(viewmodel.AvailableDataSourceKinds);

            viewmodel.UserName = "******";
            viewmodel.Password = "******";

            var daltype0 = viewmodel.AvailableDataSourceKinds[0];
            var daltype1 = viewmodel.AvailableDataSourceKinds[1];

            viewmodel.SelectedDataSourceKind = null;

            UriConfig cl1 = new UriConfig()
            {
                Alias = "BadAlias", Uri = "KKK", DalType = daltype0.DalType.ToString()
            };
            UriRowViewModel row1 = new UriRowViewModel()
            {
                UriConfig = cl1
            };

            UriConfig cl2 = new UriConfig()
            {
                Uri = "http://www.rheagroup.com", DalType = daltype0.DalType.ToString()
            };
            UriRowViewModel row2 = new UriRowViewModel()
            {
                UriConfig = cl2
            };

            UriConfig cl3 = new UriConfig()
            {
                Uri = "http://www.rheagroup.com", DalType = daltype1.DalType.ToString()
            };
            UriRowViewModel row3 = new UriRowViewModel()
            {
                UriConfig = cl3
            };

            viewmodel.AllDefinedUris.Clear();
            viewmodel.AllDefinedUris.Add(row1);
            viewmodel.AllDefinedUris.Add(row2);
            viewmodel.AllDefinedUris.Add(row3);

            viewmodel.SelectedDataSourceKind = daltype0;
            viewmodel.SelectedUri            = viewmodel.AvailableUris.Last();
            Assert.IsTrue(viewmodel.OkCommand.CanExecute(null));
            Assert.IsTrue(viewmodel.AvailableUris.Count == 2);

            viewmodel.SelectedDataSourceKind = daltype1;
            Assert.IsTrue(viewmodel.AvailableUris.Count == 1);
        }
Ejemplo n.º 3
0
 public EnvConfig(IConfigurationRoot root)
 {
     this._root   = root;
     this._csp    = new CspConfig(root);
     this._cert   = new CertConfig(root);
     this._uri    = new UriConfig(root);
     this._db     = new DatabaseConfig(root);
     this._client = new ClientConfig(root);
     this._smtp   = new SmtpConfig(root);
     this._dp     = new DpConfig(root, this._uri, AppName);
 }
Ejemplo n.º 4
0
 internal DpConfig(IConfigurationRoot root, UriConfig uriConfig, string appName)
 {
     _root      = root;
     _appName   = appName;
     _uriConfig = uriConfig;
 }