private IndexListController GetController()
        {
            var mockDAL  = new Mock <IKustoDataAccess>();
            var response = new FieldCapabilityResponse();

            response.AddField(new FieldCapabilityElement {
                Name = "testFieldName"
            });
            var responseTask = Task.FromResult(response);

            mockDAL.Setup(kusto => kusto.GetFieldCapsAsync(It.IsNotNull <string>())).Returns(responseTask);
            mockDAL.Setup(kusto => kusto.GetIndexListAsync(It.IsNotNull <string>())).Returns(Task.FromResult(new IndexListResponseElement()
            {
            }));
            var mockLogger = new Mock <ILogger <IndexListController> >();

            var ctr = new IndexListController(mockDAL.Object, mockLogger.Object)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = new DefaultHttpContext(),
                },
            };

            const string correlationIdHeader = "x-correlation-id";

            ctr.HttpContext.Request.Headers[correlationIdHeader] = Guid.NewGuid().ToString();

            return(ctr);
        }
Exemplo n.º 2
0
        private void MapFieldCaps(IDataReader kustoResults, FieldCapabilityResponse response)
        {
            while (kustoResults.Read())
            {
                var fieldCapabilityElement = FieldCapabilityElementFactory.CreateFromDataRecord(kustoResults);
                if (string.IsNullOrEmpty(fieldCapabilityElement.Type))
                {
                    Logger.LogWarning("Field: {@fieldCapabilityElement} doesn't have a type.", fieldCapabilityElement);
                }

                response.AddField(fieldCapabilityElement);

                Logger.LogDebug("Found field: {@fieldCapabilityElement}", fieldCapabilityElement);
            }
        }
Exemplo n.º 3
0
        public static ISchemaRetrieverFactory CreateMockSchemaRetriever(string name = "dayOfWeek", string type = "string")
        {
            var response = new FieldCapabilityResponse();

            response.AddField(
                new FieldCapabilityElement
            {
                Name = name,
                Type = type,
            });
            var responseTask = Task.FromResult(response);

            var mockDAL = new Mock <IKustoDataAccess>();

            mockDAL.Setup(kusto => kusto.GetFieldCapsAsync(It.IsNotNull <string>())).Returns(responseTask);

            var mockLogger = new Mock <ILogger <SchemaRetriever> >();

            return(new SchemaRetrieverFactory(mockLogger.Object, mockDAL.Object));
        }