Change SupportObserverTests to use newer mock data.
This commit is contained in:
Родитель
908a54f47b
Коммит
be7b49a2ce
|
@ -44,12 +44,35 @@ namespace Diagnostics.DataProviders
|
|||
|
||||
public Task<Dictionary<string, List<RuntimeSitenameTimeRange>>> GetRuntimeSiteSlotMap(string siteName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return GetRuntimeSiteSlotMap(null, siteName);
|
||||
}
|
||||
|
||||
public Task<Dictionary<string, List<RuntimeSitenameTimeRange>>> GetRuntimeSiteSlotMap(string stampName, string siteName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (string.IsNullOrWhiteSpace(siteName))
|
||||
{
|
||||
throw new ArgumentNullException("siteName");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(stampName))
|
||||
{
|
||||
throw new ArgumentNullException("stampName");
|
||||
}
|
||||
|
||||
var mock = new Dictionary<string, List<RuntimeSitenameTimeRange>>();
|
||||
|
||||
switch (siteName.ToLower())
|
||||
{
|
||||
case "thor-api":
|
||||
mock.Add("production", new List<RuntimeSitenameTimeRange> { new RuntimeSitenameTimeRange { RuntimeSitename = "thor-api", StartTime = DateTime.UtcNow.AddDays(-5), EndTime = DateTime.UtcNow } });
|
||||
mock.Add("staging", new List<RuntimeSitenameTimeRange> { new RuntimeSitenameTimeRange { RuntimeSitename = "thor-api__a88nf", StartTime = DateTime.UtcNow.AddDays(-5), EndTime = DateTime.UtcNow } });
|
||||
mock.Add("testing", new List<RuntimeSitenameTimeRange> { new RuntimeSitenameTimeRange { RuntimeSitename = "thor-api__v85ae", StartTime = DateTime.UtcNow.AddDays(-5), EndTime = DateTime.UtcNow } });
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return Task.FromResult(mock);
|
||||
}
|
||||
|
||||
public Task<IEnumerable<Dictionary<string, string>>> GetServerFarmsInResourceGroup(string subscriptionName, string resourceGroupName)
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
using Diagnostics.DataProviders;
|
||||
using Diagnostics.ModelsAndUtils;
|
||||
using Diagnostics.Scripts;
|
||||
using Diagnostics.Scripts.Models;
|
||||
using Diagnostics.Tests.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
|
@ -9,27 +14,38 @@ namespace Diagnostics.Tests.DataProviderTests
|
|||
{
|
||||
public class SupportObserverTests
|
||||
{
|
||||
private SupportObserverDataProvider _dataProvider;
|
||||
public SupportObserverTests()
|
||||
{
|
||||
//setup
|
||||
var configurationFactory = new MockDataProviderConfigurationFactory();
|
||||
var configuration = configurationFactory.LoadConfigurations();
|
||||
_dataProvider = new SupportObserverDataProvider(null, configuration.SupportObserverConfiguration);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetRuntimeSlotMap()
|
||||
public async void E2E_Test_RuntimeSlotMapData()
|
||||
{
|
||||
var runtimeSlotMap = _dataProvider.GetRuntimeSiteSlotMap("waws-prod-bn1-71717c45", "thor-api").Result;
|
||||
Assert.True(runtimeSlotMap.ContainsKey("Production"));
|
||||
}
|
||||
EntityMetadata metadata = ScriptTestDataHelper.GetRandomMetadata();
|
||||
//read a sample csx file from local directory
|
||||
metadata.ScriptText = await File.ReadAllTextAsync("GetRuntimeSiteSlotMapData.csx");
|
||||
|
||||
[Fact]
|
||||
public void GetSiteObject()
|
||||
{
|
||||
var siteObject = _dataProvider.GetSite("thor-api").Result;
|
||||
Assert.Equal(siteObject.SiteName, "thor-api");
|
||||
var configFactory = new MockDataProviderConfigurationFactory();
|
||||
var config = configFactory.LoadConfigurations();
|
||||
|
||||
var dataProviders = new DataProviders.DataProviders(config);
|
||||
|
||||
using (EntityInvoker invoker = new EntityInvoker(metadata, ScriptHelper.GetFrameworkReferences(), ScriptHelper.GetFrameworkImports()))
|
||||
{
|
||||
await invoker.InitializeEntryPointAsync();
|
||||
|
||||
var siteResource = new SiteResource
|
||||
{
|
||||
SiteName = "thor-api",
|
||||
Stamp = "waws-prod-bn1-71717c45"
|
||||
};
|
||||
var operationContext = new OperationContext(siteResource, null, null);
|
||||
var response = new Response();
|
||||
|
||||
Response result = (Response)await invoker.Invoke(new object[] { dataProviders, operationContext, response });
|
||||
|
||||
Assert.Equal("thor-api__a88nf", result.Dataset.First().Table.Rows[1][1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче