コード例 #1
0
        public EnvironmentSetupHelper()
        {
            var datastore = new MemoryDataStore();

            AzureSession.DataStore = datastore;
            var profile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));

            AzureSMCmdlet.CurrentProfile = profile;
            AzureSession.DataStore       = datastore;
            ProfileClient = new ProfileClient(profile);

            // Ignore SSL errors
            System.Net.ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) => true;

            // Set RunningMocked
            if (HttpMockServer.GetCurrentMode() == HttpRecorderMode.Playback)
            {
                TestMockSupport.RunningMocked = true;
            }
            else
            {
                TestMockSupport.RunningMocked = false;
            }
        }
コード例 #2
0
 public GetAzureEnvironmentTests()
 {
     dataStore = new MemoryDataStore();
     AzureSession.DataStore = dataStore;
 }
コード例 #3
0
 public Patient SavePatient(Patient PatientToSave)
 {
     //WARNING - validate data before using.
     return(MemoryDataStore.SavePatient(PatientToSave));
 }
コード例 #4
0
 public IEnumerable <Patient> GetPatients()
 {
     return(MemoryDataStore.GetPatients());
 }
コード例 #5
0
        public void GetAzureRmSubscriptionByNameMultiplePages()
        {
            var tenants = new List <string> {
                Guid.NewGuid().ToString(), DefaultTenant.ToString()
            };
            var firstTenantSubscriptions = new List <string> {
                Guid.NewGuid().ToString(),
                Guid.NewGuid().ToString(),
                Guid.NewGuid().ToString(),
                Guid.NewGuid().ToString()
            };
            var secondTenantSubscriptions = new List <string> {
                Guid.NewGuid().ToString(),
                Guid.NewGuid().ToString(),
                Guid.NewGuid().ToString(),
                Guid.NewGuid().ToString()
            };

            var firstList = new List <string> {
                firstTenantSubscriptions[0], firstTenantSubscriptions[1]
            };
            var secondList = new List <string> {
                firstTenantSubscriptions[2], firstTenantSubscriptions[3]
            };

            var thirdList = new List <string> {
                secondTenantSubscriptions[0], secondTenantSubscriptions[1]
            };
            var fourthList = new List <string> {
                secondTenantSubscriptions[2], secondTenantSubscriptions[3]
            };

            var client = SetupTestEnvironment(tenants, firstList, secondList, thirdList, fourthList);

            var subscriptionName = MockSubscriptionClientFactory.GetSubscriptionNameFromId(secondTenantSubscriptions[2]);

            var dataStore = new MemoryDataStore();

            AzureSession.Instance.DataStore = dataStore;
            var commandRuntimeMock = new MockCommandRuntime();

            AzureSession.Instance.AuthenticationFactory = new MockTokenAuthenticationFactory();
            var profile = new AzureRmProfile();

            profile.EnvironmentTable.Add("foo", new AzureEnvironment(AzureEnvironment.PublicEnvironments.Values.FirstOrDefault()));
            profile.DefaultContext = Context;
            var cmdlt = new GetAzureRMSubscriptionCommand();

            // Setup
            cmdlt.DefaultProfile   = profile;
            cmdlt.CommandRuntime   = commandRuntimeMock;
            cmdlt.SubscriptionName = subscriptionName;

            // Act
            cmdlt.InvokeBeginProcessing();
            cmdlt.ExecuteCmdlet();
            cmdlt.InvokeEndProcessing();

            Assert.True(commandRuntimeMock.OutputPipeline.Count == 1);

            // Make sure we can get a subscription from the second page of the second tenant by subscription name
            var resultSubscription = (PSAzureSubscription)commandRuntimeMock.OutputPipeline[0];

            Assert.Equal(subscriptionName, resultSubscription.Name);
            Assert.Equal(tenants[1], resultSubscription.TenantId);
        }
コード例 #6
0
 public EnvironmentCmdletTests(ITestOutputHelper output)
 {
     XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
     dataStore = new MemoryDataStore();
     AzureSession.DataStore = dataStore;
 }
コード例 #7
0
        public void ImportContextNoDefaultKey()
        {
            var serializedContext = @"{
  ""EnvironmentTable"": {
    ""testCloud"": {
      ""Name"": ""testCloud"",
      ""OnPremise"": false,
      ""ServiceManagementUrl"": null,
      ""ResourceManagerUrl"": null,
      ""ManagementPortalUrl"": null,
      ""PublishSettingsFileUrl"": null,
      ""ActiveDirectoryAuthority"": ""http://contoso.com"",
      ""GalleryUrl"": null,
      ""GraphUrl"": null,
      ""ActiveDirectoryServiceEndpointResourceId"": null,
      ""StorageEndpointSuffix"": null,
      ""SqlDatabaseDnsSuffix"": null,
      ""TrafficManagerDnsSuffix"": null,
      ""AzureKeyVaultDnsSuffix"": null,
      ""AzureKeyVaultServiceEndpointResourceId"": null,
      ""GraphEndpointResourceId"": null,
      ""DataLakeEndpointResourceId"": null,
      ""AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix"": null,
      ""AzureDataLakeStoreFileSystemEndpointSuffix"": null,
      ""AdTenant"": null,
      ""VersionProfiles"": [],
      ""ExtendedProperties"": {}
    }
  },
  ""Contexts"": {
    ""Default"": {
      ""Account"": {
        ""Id"": ""*****@*****.**"",
        ""Credential"": null,
        ""Type"": ""User"",
        ""TenantMap"": {},
        ""ExtendedProperties"": {
          ""Tenants"": ""3c0ff8a7-e8bb-40e8-ae66-271343379af6""
        }
      },
      ""Tenant"": {
        ""Id"": ""3c0ff8a7-e8bb-40e8-ae66-271343379af6"",
        ""Directory"": ""contoso.com"",
        ""ExtendedProperties"": {}
      },
      ""Subscription"": {
        ""Id"": ""00000000-0000-0000-0000-000000000000"",
        ""Name"": ""Contoso Test Subscription"",
        ""State"": ""Enabled"",
        ""ExtendedProperties"": {
          ""Account"": ""*****@*****.**"",
          ""Tenants"": ""3c0ff8a7-e8bb-40e8-ae66-271343379af6"",
          ""Environment"": ""testCloud""
        }
      },
      ""Environment"": {
        ""Name"": ""testCloud"",
        ""OnPremise"": false,
        ""ServiceManagementUrl"": null,
        ""ResourceManagerUrl"": null,
        ""ManagementPortalUrl"": null,
        ""PublishSettingsFileUrl"": null,
        ""ActiveDirectoryAuthority"": ""http://contoso.com"",
        ""GalleryUrl"": null,
        ""GraphUrl"": null,
        ""ActiveDirectoryServiceEndpointResourceId"": null,
        ""StorageEndpointSuffix"": null,
        ""SqlDatabaseDnsSuffix"": null,
        ""TrafficManagerDnsSuffix"": null,
        ""AzureKeyVaultDnsSuffix"": null,
        ""AzureKeyVaultServiceEndpointResourceId"": null,
        ""GraphEndpointResourceId"": null,
        ""DataLakeEndpointResourceId"": null,
        ""AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix"": null,
        ""AzureDataLakeStoreFileSystemEndpointSuffix"": null,
        ""AdTenant"": null,
        ""VersionProfiles"": [],
        ""ExtendedProperties"": {}
      },
      ""VersionProfile"": null,
      ""TokenCache"": {
        ""CacheData"": ""AgAAAAAAAAA=""
      },
      ""ExtendedProperties"": {}
    }
  },
  ""ExtendedProperties"": {}
}";
            var oldDataStore      = AzureSession.Instance.DataStore;
            var store             = new MemoryDataStore();
            var filePath          = "c:\\myfile.json";

            store.VirtualStore[filePath] = serializedContext;
            try
            {
                AzureSession.Instance.DataStore = store;
                var cmdlet = new ImportAzureRMContextCommand();
                cmdlet.CommandRuntime = commandRuntimeMock;
                cmdlet.Path           = filePath;
                cmdlet.DefaultProfile = new AzureRmProfile();
                cmdlet.MyInvocation.BoundParameters.Add("Path", filePath);
                cmdlet.InvokeBeginProcessing();
                cmdlet.ExecuteCmdlet();
                cmdlet.InvokeEndProcessing();

                var profile = cmdlet.DefaultProfile as AzureRmProfile;
                Assert.NotNull(profile);
                Assert.NotNull(profile.DefaultContextKey);
                var context = profile.DefaultContext;
                Assert.NotNull(context);
                var account = context.Account;
                Assert.NotNull(account);
                Assert.Equal("*****@*****.**", account.Id);
                Assert.Equal("User", account.Type);
                Assert.Contains("3c0ff8a7-e8bb-40e8-ae66-271343379af6", account.GetTenants());
                Assert.NotNull(context.Tenant);
                Assert.Equal("3c0ff8a7-e8bb-40e8-ae66-271343379af6", context.Tenant.Id);
                var subscription = context.Subscription;
                Assert.NotNull(subscription);
                Assert.Equal("Contoso Test Subscription", subscription.Name);
                Assert.Equal(Guid.Empty.ToString(), subscription.Id);
                Assert.NotNull(context.Environment);
                Assert.Equal("testCloud", context.Environment.Name);
                Assert.Equal(5, profile.EnvironmentTable.Count);
            }
            finally
            {
                AzureSession.Instance.DataStore = oldDataStore;
            }
        }
コード例 #8
0
 public IEnumerable <Appointment> GetAppointments(int patientId)
 {
     Thread.Sleep(2000);
     return(MemoryDataStore.GetAppointments(patientId));
 }
コード例 #9
0
        public EnvironmentSetupHelper()
        {
            var module = GetModuleManifest(RmDirectory, "AzureRM.Accounts");

            if (string.IsNullOrWhiteSpace(module))
            {
                throw new InvalidOperationException("Could not find Accounts module");
            }

            LogIfNotNull($"Accounts Module path: {module}");
            RMProfileModule = module;
            module          = GetModuleManifest(RmDirectory, "AzureRM.Resources");
            LogIfNotNull($"Resources Module path: {module}");
            RMResourceModule = module;
            module           = GetModuleManifest(RmDirectory, "AzureRM.Insights");
            LogIfNotNull($"Insights Module path: {module}");
            RMInsightsModule = module;
            module           = GetModuleManifest(RmDirectory, "AzureRM.Storage");
            LogIfNotNull($"Storage Management Module path: {module}");
            RMStorageModule = module;
            module          = GetModuleManifest(StorageDirectory, "Azure.Storage");
            LogIfNotNull($"Storage Data Plane Module path: {module}");
            RMStorageDataPlaneModule = module;
            module = GetModuleManifest(RmDirectory, "AzureRM.OperationalInsights");
            LogIfNotNull($"Storage Data Plane Module path: {module}");
            RMOperationalInsightsModule = module;
            module = GetModuleManifest(RmDirectory, "AzureRM.Network");
            LogIfNotNull($"Network Module path: {module}");
            RMNetworkModule = module;
            module          = GetModuleManifest(RmDirectory, "AzureRM.EventHub");
            LogIfNotNull($"EventHub Module path: {module}");
            RMEventHubModule = module;
            module           = GetModuleManifest(RmDirectory, "AzureRM.Monitor");
            LogIfNotNull($"Monitor Module path: {module}");
            RMMonitorModule = module;
            module          = GetModuleManifest(StackRmDirectory, "AzureRM.Accounts");
            LogIfNotNull($"Stack Accounts Module path: {module}");
            StackRMProfileModule = module;
            module = GetModuleManifest(StackRmDirectory, "AzureRM.Resources");
            LogIfNotNull($"Stack Resources Module path: {module}");
            StackRMResourceModule = module;
            module = GetModuleManifest(StackRmDirectory, "AzureRM.Storage");
            LogIfNotNull($"Stack Storage Management Plane Module path: {module}");
            StackRMStorageModule = module;
            module = GetModuleManifest(StackStorageDirectory, "Azure.Storage");
            LogIfNotNull($"Stack Storage Data Plane Module path: {module}");
            StackRMStorageDataPlaneModule = module;
            module = GetModuleManifest(RmDirectory, "Az.KeyVault");
            LogIfNotNull($"KeyVault Module path: {module}");
            RMKeyVaultModule = module;

            TestExecutionHelpers.SetUpSessionAndProfile();
            IDataStore datastore = new MemoryDataStore();

            if (AzureSession.Instance.DataStore != null && (AzureSession.Instance.DataStore is MemoryDataStore))
            {
                datastore = AzureSession.Instance.DataStore;
            }

            AzureSession.Instance.DataStore = datastore;
            var rmprofile = new AzureRmProfile(Path.Combine(AzureSession.Instance.ProfileDirectory, AzureSession.Instance.ProfileFile));

            rmprofile.EnvironmentTable.Add("foo", new AzureEnvironment(AzureEnvironment.PublicEnvironments.Values.FirstOrDefault()));
            rmprofile.DefaultContext = new AzureContext(new AzureSubscription(), new AzureAccount(), rmprofile.EnvironmentTable["foo"], new AzureTenant());
            rmprofile.DefaultContext.Subscription.SetEnvironment("foo");
            if (AzureRmProfileProvider.Instance.Profile == null)
            {
                AzureRmProfileProvider.Instance.Profile = rmprofile;
            }

            AzureSession.Instance.DataStore = datastore;

            // Ignore SSL errors
            System.Net.ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) => true;

            // Set RunningMocked
            TestMockSupport.RunningMocked = HttpMockServer.GetCurrentMode() == HttpRecorderMode.Playback;

            if (File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".azure", "testcredentials.json")))
            {
                SetEnvironmentVariableFromCredentialFile();
            }
        }
コード例 #10
0
        public void NewRowWithTooManyColumns()
        {
            var source = new MemoryDataStore(DataStoreConfiguration.FromColumns("First Name", "Last Name", "Age"));

            TestHelper.ExpectedException <ArgumentException>(() => source.NewRow("John", "Doe", "23", "1979/01/02"), "The input values do not match the column count.");
        }
コード例 #11
0
 public EnvironmentCmdletTests()
 {
     dataStore = new MemoryDataStore();
     AzureSession.DataStore = dataStore;
 }
コード例 #12
0
ファイル: MainForm.cs プロジェクト: wind101net/atmo
        public MainForm(ProgramContext appContext)
        {
            if (null == appContext) {
                throw new ArgumentNullException();
            }

            AppContext = appContext;
            InitializeComponent();

            timerWU = new System.Timers.Timer();
            timerWU.Interval = 5000; //pov2500
            timerWU.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEventWU);
            timerWU.Enabled = false;
            timerWU.Start();

            _advancedSensorValues = new AdvancedSensorValues[10];
            _advancedSensorValues[0] = new AdvancedSensorValues();
            _advancedSensorValues[1] = new AdvancedSensorValues();
            _advancedSensorValues[2] = new AdvancedSensorValues();
            _advancedSensorValues[3] = new AdvancedSensorValues();
            _advancedSensorValues[4] = new AdvancedSensorValues();
            _advancedSensorValues[5] = new AdvancedSensorValues();
            _advancedSensorValues[6] = new AdvancedSensorValues();
            _advancedSensorValues[7] = new AdvancedSensorValues();
            _advancedSensorValues[8] = new AdvancedSensorValues();
            _advancedSensorValues[9] = new AdvancedSensorValues();

            Text = ProgramContext.ProgramFriendlyName;

            ConverterCache = ReadingValuesConverterCache<IReadingValues, ReadingValues>.Default;
            ConverterCacheReadingValues = ReadingValuesConverterCache<ReadingValues>.Default;
            ConverterCacheReadingAggregate = ReadingValuesConverterCache<ReadingAggregate>.Default;
            liveAtmosphericGraph.ConverterCacheReadingValues = ConverterCacheReadingValues;

            _deviceConnection = new UsbDaqConnection(); // new Demo.DemoDaqConnection();

            // create the DB file using the application privilages instead of using the installer
            if (!File.Exists(DatabaseFileName)) {
                using(var dbTemplateDataStream = typeof (DbDataStore).Assembly.GetManifestResourceStream("Atmo." + DatabaseFileName))
                using(var outDbTemplate = File.Create(DatabaseFileName)) {
                    var buffer = new byte[1024];
                    int totalRead;
                    while(0 < (totalRead = dbTemplateDataStream.Read(buffer, 0, buffer.Length)))
                        outDbTemplate.Write(buffer,0, totalRead);
                }

                Thread.Sleep(250); // just to be safe
                Log.InfoFormat("Core DB file created at: {0}", Path.GetFullPath(DatabaseFileName));
            }
            try {
                _dbConnection = new System.Data.SQLite.SQLiteConnection(
                    @"data source=" + DatabaseFileName + @";page size=4096;cache size=4000;journal mode=Off");
                _dbConnection.Open();
            }
            catch(Exception ex) {
                Log.Error("Database connection failure.", ex);
                throw;
            }
            _dbStore = new DbDataStore(_dbConnection);

            _memoryDataStore = new MemoryDataStore();

            _sensorViewPanelControler = new SensorViewPanelController(groupControlSensors) {
                DefaultSelected = true
            };
            _historicSensorViewPanelController = new HistoricSensorViewPanelController(groupControlDbList) {
                DefaultSelected = true,
            };
            _historicSensorViewPanelController.OnDeleteRequested += OnDeleteRequested;
            _historicSensorViewPanelController.OnRenameRequested += OnRenameRequested;

            historicalTimeSelectHeader.CheckEdit.CheckedChanged += histNowChk_CheckedChanged;

            historicalTimeSelectHeader.TimeRange.SelectedIndex = historicalTimeSelectHeader.TimeRange.FindNearestIndex(AppContext.PersistentState.HistoricalTimeScale);
            liveAtmosphericHeader.TimeRange.SelectedIndex = liveAtmosphericHeader.TimeRange.FindNearestIndex(AppContext.PersistentState.LiveTimeScale);

            historicalTimeSelectHeader.TimeRange.ValueChanged += historicalTimeSelectHeader_TimeRangeValueChanged;
            liveAtmosphericHeader.TimeRange.ValueChanged += liveTimeSelectHeader_TimeRangeValueChanged;

            foreach(var view in _historicSensorViewPanelController.Views.Where(v => null != v)) {
                bool selected = false;
                if(
                    null != view.SensorInfo
                    && AppContext.PersistentState.SelectedDatabases.Contains(view.SensorInfo.Name)
                ) {
                    selected = true;
                }
                view.IsSelected = selected;
            }

            //HandleRapidFireSetup();
            HandleDaqTemperatureSourceSet(_deviceConnection.UsingDaqTemp);

            //rp
            HandleWFSetup();

            //rp
            HandleAWSetup();

            //rp
            HandleWeatherSetup();

            //rp
            _internetStreamingStatistics = new InternetStreamingStatistics();

            ReloadHistoric();
            _historicSensorViewPanelController.OnSelectionChanged += RequestHistoricalUpdate;
            historicalGraphBreakdown.OnSelectedPropertyChanged += RequestHistoricalUpdate;
            historicalTimeSelectHeader.OnTimeRangeChanged += RequestHistoricalUpdate;
            windResourceGraph.OnWeibullParamChanged += RequestHistoricalUpdate;
            #if DEBUG
            barSubItemDebug.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
            #endif
        }
コード例 #13
0
 public RemoveAzureEnvironmentTests()
 {
     dataStore = new MemoryDataStore();
     AzureSession.Instance.DataStore = dataStore;
 }