Example #1
0
        public void RequestFindingTest()
        {
            // arrange
            var _client = new HttpClient();
            var uri     = new Uri(Constants.url + "/api/finding/requestfinding");


            //// act
            JObject o = new JObject();

            o.Add("userID", Guid.Parse(Constants.userID));
            o.Add("time", DateTime.Parse(Constants.lastTime));

            string json    = o.ToString();
            var    request = new HttpRequestMessage
            {
                Method     = HttpMethod.Post,
                RequestUri = uri,
                Content    = new StringContent(json, Encoding.UTF8, "application/json")
            };



            var response = _client.SendAsync(request).Result;


            Assert.IsTrue(response.IsSuccessStatusCode, "Statuscode " + response.StatusCode + " returned");

            UserResponseDataSet data = JsonConvert.DeserializeObject <UserResponseDataSet>(response.Content.ReadAsStringAsync().Result);

            System.Diagnostics.Trace.WriteLine(response.Content.ReadAsStringAsync().Result);

            // assert
            Assert.IsNotNull(response.Content);
        }
Example #2
0
        private UserResponseDataSet CreateUserReport(Guid userId, DateTime time)
        {
            if (!NewFindingAvailable(userId, time))
            {
                return(new UserResponseDataSet());
            }

            PropabilityDataSet sourceData = dataService.RequestDiseasePropability(userId, time);

            UserResponseDataSet res = new UserResponseDataSet();

            res.userID        = userId;
            res.time          = time;
            res.propabilities = sourceData?.propabilities;
            res.diseaseTypes  = knowledgeService.GetDiseaseIdentData();
            var maxLikelyDisease = res.propabilities.Aggregate((x, y) => x.propability > y.propability ? x : y);

            res.message = knowledgeService.EvaluateSpecificDisease(maxLikelyDisease.id, maxLikelyDisease.propability);
            return(res);
        }