public void LastNameMissingCharacter()
        {
            var scores = new List <AssessmentScore>
            {
                new AssessmentScore
                {
                    FirstName         = "Eric",
                    LastName          = "Albrecht",
                    ClassStanding     = "4 - Senior",
                    Emphasis          = "Generalist",
                    Semester          = "Spring 2019",
                    SemesterSort      = AssessmentAnalyzer.ConvertToSortableValue("Spring 2019"),
                    StudentIdentifier = "Eric Albrecht",
                    ScoreName         = "Oral",
                    Score             = 4
                },
                new AssessmentScore
                {
                    FirstName         = "Eric",
                    LastName          = "ALbrecht",
                    ClassStanding     = "4 - Senior",
                    Emphasis          = "Generalist",
                    Semester          = "Spring 2019",
                    SemesterSort      = AssessmentAnalyzer.ConvertToSortableValue("Spring 2019"),
                    StudentIdentifier = "Eric Albrecht",
                    ScoreName         = "Oral",
                    Score             = 3
                },
                new AssessmentScore
                {
                    FirstName         = "Eric",
                    LastName          = "Albrecht",
                    ClassStanding     = "4 - Senior",
                    Emphasis          = "Generalist",
                    Semester          = "Spring 2019",
                    SemesterSort      = AssessmentAnalyzer.ConvertToSortableValue("Spring 2019"),
                    StudentIdentifier = "Eric Albrecht",
                    ScoreName         = "Oral",
                    Score             = 4
                },
                new AssessmentScore
                {
                    FirstName         = "Eric",
                    LastName          = "Albrect",
                    ClassStanding     = "4 - Senior",
                    Emphasis          = "Generalist",
                    Semester          = "Spring 2019",
                    SemesterSort      = AssessmentAnalyzer.ConvertToSortableValue("Spring 2019"),
                    StudentIdentifier = "Eric Albrect",
                    ScoreName         = "Oral",
                    Score             = 4
                }
            };

            var validationResult = ScoreValidator.ValidateScores(scores);

            Assert.AreEqual(2, validationResult.Count);
            Assert.IsFalse(scores.Any(s => s.LastName != "Albrecht"));
        }
Exemplo n.º 2
0
        public void ExtractXPFromStringuccess()
        {
            const string XPstring   = "700/1799 XP";
            const int    expectedXP = 700;

            var result = ScoreValidator.ScoreSplitter(XPstring);


            Assert.Equal(expectedXP, result);
        }
Exemplo n.º 3
0
        public void ExtractUrlFromTextResultSuccess()
        {
            const string expectedXP  = "https://techprofile.microsoft.com/en-us/msimpsonnz";
            string       sample_data = File.ReadAllText($"{cwd}\\Samples\\textResult.json");

            RecognitionResult recognitionResultData = JsonConvert.DeserializeObject <RecognitionResult>(sample_data);

            string result = ScoreValidator.ExtractUrl(recognitionResultData);


            Assert.Equal(expectedXP, result);
        }
Exemplo n.º 4
0
        public void ExtractXPFromTextResultSuccess()
        {
            const int expectedXP  = 700;
            string    sample_data = File.ReadAllText($"{cwd}\\Samples\\textResult.json");

            RecognitionResult recognitionResultData = JsonConvert.DeserializeObject <RecognitionResult>(sample_data);

            int result = ScoreValidator.ExtractScore(recognitionResultData);


            Assert.Equal(expectedXP, result);
        }
Exemplo n.º 5
0
        public void Setup()
        {
            var dict = new Dictionary <string, string>
            {
                { "PredictionChangesAllowedUntil:First", "2018-06-12T00:00:00.000" }
            };

            var builder = new ConfigurationBuilder();

            builder.AddInMemoryCollection(dict);
            ScoreValidator = new ScoreValidator(builder.Build());
        }
Exemplo n.º 6
0
        public void ExtractXPFromTextResultSuccess()
        {
            const int expectedXP = 400;

            var doc = new HtmlDocument();

            doc.Load($"{cwd}\\Samples\\onlineprofile.html");

            var result = ScoreValidator.ExtractScore(doc);


            Assert.Equal(expectedXP, result);
        }
        public void WoodAndSnow()
        {
            var scores = new List <AssessmentScore>
            {
                new AssessmentScore
                {
                    FirstName         = "Eric",
                    LastName          = "Snow",
                    ClassStanding     = "4 - Senior",
                    Emphasis          = "Generalist",
                    Semester          = "Spring 2019",
                    SemesterSort      = AssessmentAnalyzer.ConvertToSortableValue("Spring 2019"),
                    StudentIdentifier = "Eric Snow",
                    ScoreName         = "Oral",
                    Score             = 4
                },
                new AssessmentScore
                {
                    FirstName         = "Eric",
                    LastName          = "Snow",
                    ClassStanding     = "4 - Senior",
                    Emphasis          = "Generalist",
                    Semester          = "Spring 2019",
                    SemesterSort      = AssessmentAnalyzer.ConvertToSortableValue("Spring 2019"),
                    StudentIdentifier = "Eric Snow",
                    ScoreName         = "Oral",
                    Score             = 3
                },
                new AssessmentScore
                {
                    FirstName         = "Eric",
                    LastName          = "Wood",
                    ClassStanding     = "4 - Senior",
                    Emphasis          = "Generalist",
                    Semester          = "Spring 2019",
                    SemesterSort      = AssessmentAnalyzer.ConvertToSortableValue("Spring 2019"),
                    StudentIdentifier = "Eric Wood",
                    ScoreName         = "Oral",
                    Score             = 4
                }
            };

            var validationResult = ScoreValidator.ValidateScores(scores);

            Assert.AreEqual(0, validationResult.Count);
            Assert.IsTrue(scores.Any(s => s.LastName == "Wood"));
            Assert.IsTrue(scores.Any(s => s.LastName == "Snow"));
        }
        public void FirstNameIsNull()
        {
            var scores = new List <AssessmentScore>
            {
                new AssessmentScore
                {
                    FirstName         = null,
                    LastName          = "Means",
                    ClassStanding     = "4 - Senior",
                    Emphasis          = "Generalist",
                    Semester          = "Spring 2019",
                    SemesterSort      = AssessmentAnalyzer.ConvertToSortableValue("Spring 2019"),
                    StudentIdentifier = "Allison Means",
                    ScoreName         = "Oral",
                    Score             = 4
                },
                new AssessmentScore
                {
                    FirstName         = "Alison",
                    LastName          = "Means",
                    ClassStanding     = "4 - Senior",
                    Emphasis          = "Generalist",
                    Semester          = "Spring 2019",
                    SemesterSort      = AssessmentAnalyzer.ConvertToSortableValue("Spring 2019"),
                    StudentIdentifier = "Alison Means",
                    ScoreName         = "Oral",
                    Score             = 3
                },
                new AssessmentScore
                {
                    FirstName         = "Alison",
                    LastName          = "Means",
                    ClassStanding     = "4 - Senior",
                    Emphasis          = "Generalist",
                    Semester          = "Spring 2019",
                    SemesterSort      = AssessmentAnalyzer.ConvertToSortableValue("Spring 2019"),
                    StudentIdentifier = "Alison Means",
                    ScoreName         = "Oral",
                    Score             = 4
                }
            };

            var validationResult = ScoreValidator.ValidateScores(scores);

            Assert.AreEqual(0, validationResult.Count);
            Assert.IsTrue(scores.Any(s => s.FirstName == null));
        }
Exemplo n.º 9
0
 public void Setup()
 {
     this.scoreValidator = new ScoreValidator();
     this.score          = new Score
     {
         Id       = 1,
         Points   = 5d,
         UserFrom = new User {
             Id = 1, Email = "*****@*****.**", Password = "******", Username = "******"
         },
         UserIdFrom = 1,
         User       = new User {
             Id = 2, Email = "*****@*****.**", Password = "******", Username = "******"
         },
         UserIdTo = 2
     };
 }
Exemplo n.º 10
0
        public async static void Run(
            [EventGridTrigger] JObject eventGridEvent,
            [CosmosDB("%Cosmos:DatabaseName%", "%Cosmos:CollectionName%", ConnectionStringSetting = "Cosmos:ConnectionString")] IAsyncCollector <dynamic> documentOut,
            ILogger log)
        {
            log.LogInformation(eventGridEvent.ToString(Formatting.Indented));

            string  blobUrl = eventGridEvent["data"]["url"].ToString();
            dynamic body    = new
            {
                url = blobUrl
            };
            string bodyJson = JsonConvert.SerializeObject(body);

            log.LogInformation($"Status: Extract blob: {bodyJson}");

            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", Environment.GetEnvironmentVariable("OCR:Subscription"));

            var queryString = HttpUtility.ParseQueryString(string.Empty);
            var recTextUri  = "https://westus.api.cognitive.microsoft.com/vision/v2.0/recognizeText?mode=Printed";

            HttpResponseMessage response;

            // Request body
            byte[] byteData = Encoding.UTF8.GetBytes(bodyJson);

            log.LogInformation("Status: Send Request to Vision");
            using (var content = new ByteArrayContent(byteData))
            {
                content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                response = await client.PostAsync(recTextUri, new ByteArrayContent(byteData));
            }
            log.LogInformation("Status: Vison Request Process");
            string textOperationUri = response.Headers.FirstOrDefault(x => x.Key == "Operation-Location").Value.FirstOrDefault();

            log.LogInformation($"Staus: Get URL, {textOperationUri}");
            HttpResponseMessage textOperationReq;

            textOperationReq = await client.GetAsync(textOperationUri);

            var textOperationRes = await textOperationReq.Content.ReadAsStringAsync();

            RecognitionResult recognitionResultData = JsonConvert.DeserializeObject <RecognitionResult>(textOperationRes);

            while (recognitionResultData.status != "Succeeded")
            {
                await Task.Delay(1000);

                textOperationReq = await client.GetAsync(textOperationUri);

                textOperationRes = await textOperationReq.Content.ReadAsStringAsync();

                recognitionResultData = JsonConvert.DeserializeObject <RecognitionResult>(textOperationRes);
            }
            log.LogInformation("Status: Received Result");

            var    validateScore  = ScoreValidator.ExtractScore(recognitionResultData);
            var    techProfileUrl = ScoreValidator.ExtractUrl(recognitionResultData);
            var    onlineScore    = ScoreValidator.GetOnlineProfile(techProfileUrl);
            string status;

            if (onlineScore >= validateScore)
            {
                status = "Pass";
            }
            else
            {
                status = "FAIL";
            }


            Submission document = new Submission
            {
                Id            = eventGridEvent["id"].ToString(),
                Date          = eventGridEvent["eventTime"].ToString(),
                UserId        = Guid.NewGuid().ToString(),
                BlobUri       = blobUrl,
                ValidateScore = validateScore,
                OnlineScore   = onlineScore,
                Status        = status ?? "Validation Failure",
                TechProfile   = techProfileUrl ?? "Failed to extract profile",
                Type          = "submission"
            };

            await documentOut.AddAsync(document);
        }
Exemplo n.º 11
0
        public void ValidateScore(int scoreRed, int scoreBlue, bool expect)
        {
            var validator = new ScoreValidator(scoreRed, scoreBlue);

            Assert.AreEqual(expect, validator.IsValid, validator.Message);
        }
Exemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScoreServices" /> class.
 /// </summary>
 /// <param name="repository">The repository.</param>
 /// <param name="userService">The user service.</param>
 public ScoreServices(IRepositoryScore repository, IUserServices userService)
 {
     this.repository  = repository;
     this.validator   = new ScoreValidator();
     this.userService = userService;
 }