public void GetAllTypes_Should_Return_BenchMarkTypes()
        {
            //  Arrange



            //  Act

            var benchMarkTypes = BenchMarkTypeGenerator.GetAllTypes();



            //  Assert

            Assert.NotNull(benchMarkTypes);
            Assert.NotEmpty(benchMarkTypes);
        }
        public static IServiceCollection AddBenchMarkClients(this IServiceCollection services)
        {
            var benchMarkTypes = BenchMarkTypeGenerator.GetAllTypes();

            foreach (var benchMarkType in benchMarkTypes)
            {
                services.AddHttpClient(benchMarkType.ClientName,
                                       client =>
                {
                    client.BaseAddress = new Uri(Environment.GetEnvironmentVariable(benchMarkType.UrlName));
                    if (benchMarkType.SetXFunctionsKey)
                    {
                        client.DefaultRequestHeaders.Add("x-functions-key", Environment.GetEnvironmentVariable(benchMarkType.KeyName));
                    }
                });
            }
            return(services);
        }
        public void GetAllTypes_Should_Return_BenchMarkType_With_All_Data()
        {
            //  Arrange



            //  Act

            var benchMarkTypes = BenchMarkTypeGenerator.GetAllTypes();



            //  Assert

            Assert.NotNull(benchMarkTypes);

            // we hard coded verify only the first and last(because its so different) entries for now
            var firstTypeForTesting = benchMarkTypes.First();

            Assert.Equal(CloudProvider.Azure, firstTypeForTesting.CloudProvider);
            Assert.Equal(HostEnvironment.Windows, firstTypeForTesting.HostEnvironment);
            Assert.Equal(Runtime.Csharp, firstTypeForTesting.Runtime);
            Assert.Equal("AzureWindowsCsharp", firstTypeForTesting.Name);
            Assert.Equal("AzureWindowsCsharpClient", firstTypeForTesting.ClientName);
            Assert.Equal("AzureWindowsCsharpKey", firstTypeForTesting.KeyName);
            Assert.Equal("AzureWindowsCsharpUrl", firstTypeForTesting.UrlName);
            Assert.True(firstTypeForTesting.SetXFunctionsKey);


            var lastTypeForTesting = benchMarkTypes.Last();

            Assert.Equal(CloudProvider.Firebase, lastTypeForTesting.CloudProvider);
            Assert.Equal(HostEnvironment.Linux, lastTypeForTesting.HostEnvironment);
            Assert.Equal(Runtime.Nodejs, lastTypeForTesting.Runtime);
            Assert.Equal("FirebaseLinuxNodejs", lastTypeForTesting.Name);
            Assert.Equal("FirebaseLinuxNodejsClient", lastTypeForTesting.ClientName);
            Assert.Equal("FirebaseLinuxNodejsKey", lastTypeForTesting.KeyName);
            Assert.Equal("FirebaseLinuxNodejsUrl", lastTypeForTesting.UrlName);
            Assert.False(lastTypeForTesting.SetXFunctionsKey);
        }
Esempio n. 4
0
 public IEnumerable <BenchMarkType> GetAllTypes()
 {
     return(BenchMarkTypeGenerator.GetAllTypes());
 }