public void TestGetFrameworksFromZipFile()
        {
            var             zipFIleExtractor    = new ZipFileExtractor();
            var             csvService          = new CsvService(null);
            var             applicationSettings = new AppServiceSettings();
            LarsDataService larsDataService     = new LarsDataService(applicationSettings, csvService, new HttpService(null), zipFIleExtractor, new AngleSharpService(), null, new HttpService(null));
            var             path = larsDataService.GetListOfCurrentFrameworks();

            Assert.IsTrue(path.Count > 100);
        }
        public void CreateQueueNameFromType(Type type, string queueName)
        {
            var settingsProvider = new Mock <IProvideSettings>();

            settingsProvider.Setup(m => m.GetSetting(It.IsAny <string>())).Returns(string.Empty);
            var settings = new AppServiceSettings(settingsProvider.Object);

            settings.QueueName(type);

            settingsProvider.Verify(m => m.GetSetting(queueName), Times.Once);
        }
Ejemplo n.º 3
0
        public async Task GetSetManagerTests(string storageConnectionString, string siteName)
        {
            if (string.IsNullOrEmpty(storageConnectionString))
            {
                return;
            }

            AppServiceSettings.StorageConnectionString = storageConnectionString;
            AppServiceSettings.SiteName         = siteName;
            AppServiceSettings.WorkerName       = "127.0.0.1";
            AppServiceSettings.HomeStampName    = "waws-prod-stamp-001";
            AppServiceSettings.CurrentStampName = "waws-prod-stamp-001";

            var worker = new AppServiceWorkerInfo
            {
                PartitionKey = AppServiceSettings.WorkerPartitionKey,
                RowKey       = AppServiceSettings.GetWorkerRowKey(AppServiceSettings.CurrentStampName, AppServiceSettings.WorkerName),
                StampName    = AppServiceSettings.CurrentStampName,
                WorkerName   = AppServiceSettings.WorkerName,
                LoadFactor   = 55
            };

            try
            {
                var table = AppServiceWorkerTable.Instance;

                // intialize
                await DeleteAllWorkers(table);

                var current = await table.GetManager();

                Assert.Null(current);

                // set manager
                await table.AddOrUpdate(worker);

                await table.SetManager(worker);

                current = await table.GetManager();

                Assert.True(ScaleUtils.WorkerEquals(worker, current));

                // delete
                await table.Delete(worker);

                current = await table.GetManager();

                Assert.Null(current);
            }
            finally
            {
                ResetEnvironment();
            }
        }
Ejemplo n.º 4
0
        public void ShouldGetFcsActiveProviders()
        {
            var moqVstsClient       = new Mock <IVstsClient>();
            var moqIProvideSettings = new Mock <IProvideSettings>();
            var appsettings         = new AppServiceSettings(moqIProvideSettings.Object);
            var moqIConvertFromCsv  = new Mock <IConvertFromCsv>();

            moqVstsClient.Setup(m => m.GetFileContent(It.IsAny <string>())).Returns(string.Empty);
            moqIConvertFromCsv.Setup(m => m.CsvTo <ActiveProviderCsvRecord>(It.IsAny <string>())).Returns(new[] { new ActiveProviderCsvRecord {
                                                                                                                      UkPrn = 26
                                                                                                                  }, new ActiveProviderCsvRecord {
                                                                                                                      UkPrn = 126
                                                                                                                  } });

            var client = new FcsActiveProvidersClient(moqVstsClient.Object, appsettings, moqIConvertFromCsv.Object, Mock.Of <ILog>());
            var result = client.Handle(null);

            result.Result.Providers.Count().Should().Be(2);
            result.Result.Providers.All(m => new[] { 26, 126 }.Contains(m)).Should().BeTrue();
        }
Ejemplo n.º 5
0
        public async Task CRUDTests(string storageConnectionString, string siteName)
        {
            if (string.IsNullOrEmpty(storageConnectionString))
            {
                return;
            }

            AppServiceSettings.StorageConnectionString = storageConnectionString;
            AppServiceSettings.SiteName         = siteName;
            AppServiceSettings.WorkerName       = "127.0.0.1";
            AppServiceSettings.HomeStampName    = "waws-prod-stamp-001";
            AppServiceSettings.CurrentStampName = "waws-prod-stamp-001";

            var worker = new AppServiceWorkerInfo
            {
                PartitionKey = AppServiceSettings.WorkerPartitionKey,
                RowKey       = AppServiceSettings.GetWorkerRowKey(AppServiceSettings.CurrentStampName, AppServiceSettings.WorkerName),
                StampName    = AppServiceSettings.CurrentStampName,
                WorkerName   = AppServiceSettings.WorkerName,
                LoadFactor   = 55
            };

            try
            {
                var table = AppServiceWorkerTable.Instance;

                // intialize
                await DeleteAllWorkers(table);

                var workers = await table.List();

                Assert.Equal(0, workers.Count());

                // insert
                await table.AddOrUpdate(worker);

                workers = await table.List();

                Assert.Equal(1, workers.Count());
                var entity1 = workers.FirstOrDefault();
                Assert.True(ScaleUtils.WorkerEquals(entity1, worker));
                Assert.True(DateTime.UtcNow >= entity1.LastModifiedTimeUtc);
                Assert.True(DateTime.UtcNow - entity1.LastModifiedTimeUtc <= TimeSpan.FromSeconds(30));
                Assert.Equal(worker.LoadFactor, entity1.LoadFactor);
                Assert.False(entity1.IsStale);
                Assert.Equal(worker.IsHomeStamp, entity1.IsHomeStamp);

                // update
                worker.LoadFactor = 45;
                await table.AddOrUpdate(worker);

                workers = await table.List();

                Assert.Equal(1, workers.Count());
                var entity2 = workers.FirstOrDefault();
                Assert.True(ScaleUtils.WorkerEquals(entity1, entity2));
                Assert.True(entity2.LastModifiedTimeUtc > entity1.LastModifiedTimeUtc);
                Assert.Equal(worker.LoadFactor, entity2.LoadFactor);
                Assert.NotEqual(entity1.LoadFactor, entity2.LoadFactor);

                // delete
                await table.Delete(worker);

                workers = await table.List();

                Assert.Equal(0, workers.Count());
            }
            finally
            {
                ResetEnvironment();
            }
        }