public void GetTopResults_Returns_Most_Common_Schemes() { // Arrange var resultStatistics = new TestResultStatistics { Action = 14, Idea = 16, People = 16, Process = 5 }; // Act var analyzer = new UserResultStatAnalyzer(resultStatistics); var topResultArr = analyzer.GetTopResults(); // Assert topResultArr .Length .Should() .Be(2); var topResults = new[] { $"{nameof(resultStatistics.Idea).ToLower()}", $"{nameof(resultStatistics.People).ToLower()}" }; topResultArr[0] .Should() .BeOneOf(topResults); topResults[1] .Should() .BeOneOf(topResults); }
public void GetTopResults_Returns_Most_Common_Single_Scheme() { // Arrange var resultStatistics = new TestResultStatistics { Action = 14, Idea = 16, People = 2, Process = 27 }; // Act var analyzer = new UserResultStatAnalyzer(resultStatistics); var topResultArr = analyzer.GetTopResults(); // Assert topResultArr .Length .Should() .Be(1); topResultArr[0] .Should() .Be(nameof(resultStatistics.Process).ToLower()); }
/// <summary> /// Enqueue message to the Email Worker API for sending a mail /// to the user with his/hers results from the test. /// </summary> /// <param name="notification"></param> /// <param name="cancellationToken"></param> public async Task Handle(UserSubmittedPersonalData notification, CancellationToken cancellationToken) { var results = await _userTestResultRepository.GetByUserAsync(notification.UserIdentifier); var resultsAnalyzer = new UserResultStatAnalyzer(results.ResultStatistics); var mailBody = await CreateMailBodyByTopResultsAsync(resultsAnalyzer.GetTopResults()); var emailModel = new SendUserResultsEmail(notification.Email, mailBody); await _advancedBus.PublishAsync( exchange : _exchange, routingKey : _config.RoutingKey, mandatory : false, message : new Message <SendUserResultsEmail>(emailModel)); }
public void ValuesDictionary_Keeps_Right_Order() { // Arrange var resultStatistics = new TestResultStatistics { Action = 8, Idea = 3, People = 5, Process = 17 }; // Act var analyzer = new UserResultStatAnalyzer(resultStatistics); // Assert var keyValuePairs = analyzer.ValuePairs; keyValuePairs[3] .Key .Should() .Be(nameof(resultStatistics.Idea).ToLower()); keyValuePairs[2] .Key .Should() .Be(nameof(resultStatistics.People).ToLower()); keyValuePairs[1] .Key .Should() .Be(nameof(resultStatistics.Action).ToLower()); keyValuePairs[0] .Key .Should() .Be(nameof(resultStatistics.Process).ToLower()); }