public void Add(StudentOpticalForm form, StudentOpticalFormSection section) { if (!_dictionary.ContainsKey(section.LessonName)) { _dictionary.Add(section.LessonName, new Dictionary <int, List <float> >()); } var secondaryKey = _secondaryKeySelector(form); if (!_dictionary[section.LessonName].ContainsKey(secondaryKey)) { _dictionary[section.LessonName].Add(secondaryKey, new List <float>()); } _dictionary[section.LessonName][secondaryKey].Add(_valueSelector(section)); }
public async Task When_FormsExists_Then_ShouldReplaceStudentOpticalForms(IFixture fixture, int userId, StudentOpticalFormSection section, int examId) { var client = _webApplicationFactory.CreateClientWithUserId(userId); var forms = new List <StudentOpticalForm> { GenerateStudentForm(fixture, examId, userId), GenerateStudentForm(fixture, examId, userId), }; var response = await client.PostAsync(ApiPath, forms.ToJsonContent()); response.EnsureSuccessStatusCode(); forms.First().Sections.Clear(); forms.First().Sections.Add(section); forms.Last().Sections.Clear(); forms.Last().Sections.Add(section); response = await client.PostAsync(ApiPath, forms.ToJsonContent()); response.EnsureSuccessStatusCode(); var examForms = await GetListAsync <StudentOpticalForm>(client, examId); examForms.Should().HaveCount(2); examForms.Should().Contain( f => f.Sections.First().LessonName == forms.First().Sections.First().LessonName); }