using System; using System.Collections.Generic; using System.Linq; public class HelperRating { // Rate 1,2,3,4,5 public List> Rating { get; set; } public HelperRating() { Rating = new List>(); } public void Rate(string helper, int value) { Rating.Insert(Rating.Count, new KeyValuePair(helper, value)); } public bool Award(string helper) { int count = 10; var helperRating = Rating .Where(d => d.Key == helper && d.Value == 5) .Count(); return helperRating >= count; } } Lisa is a hard working helper and has been on FHS platform for over two months now. She was systematically allocated 15 requests in one month and received ten 5-star ratings. Using the code above and all the possible rating values (1, 2, 3, 4, 5), write a unit test to check if Lisa has won a monthly price.
using System;
using System.Collections.Generic; using System.Linq;
public class HelperRating {
// Rate 1,2,3,4,5
public List<KeyValuePair<string, int>> Rating { get; set; }
public HelperRating() {
Rating = new List<KeyValuePair<string, int>>(); }
public void Rate(string helper, int value) {
Rating.Insert(Rating.Count, new KeyValuePair<string, int>(helper, value)); }
public bool Award(string helper) {
int count = 10;
var helperRating = Rating
.Where(d => d.Key == helper && d.Value == 5)
.Count();
return helperRating >= count;
}
}
Lisa is a hard working helper and has been on FHS platform for over two months now. She was systematically allocated 15 requests in one month and received ten 5-star ratings. Using the code above and all the possible rating values (1, 2, 3, 4, 5), write a unit test to check if Lisa has won a monthly price.
Step by step
Solved in 2 steps