public void GetGroupsWithUsingFiltersFunctionTest_ShouldBeSuccess()
        {
            var groupName   = "groupName";
            var inputGroups = new[] {
                new GroupBasedProxy {
                    GroupName = "firstNameOfGroup"
                },
                new GroupBasedProxy {
                    GroupName = "secondNameOfGroup"
                }
            };

            A.CallTo(() => databaseGroupReader.GetGroupsWithUsingFilters(groupName)).Returns(inputGroups);

            RunServer(new GetGroupsWithUsingFiltersFunction(DatabaseAuthorizer, databaseGroupReader));

            var parameters = GetDefaultParameters();

            parameters[HttpParameters.GroupName] = groupName;
            var receivedGroups = SendRequest <GroupExtendedProxy[]>("GetGroupsWithUsingFilters", parameters);

            A.CallTo(() => databaseGroupReader.GetGroupsWithUsingFilters(groupName)).MustHaveHappened(Repeated.Exactly.Once);
            CollectionAssert.AreEqual(inputGroups, receivedGroups);
        }
Exemplo n.º 2
0
        public FileWithContent Execute(StudentBasedProxy student)
        {
            var fullTemplateName = Path.Combine(folderWithTemplates, TemplateName);

            File.Copy(fullTemplateName, tempDocumentName, true);

            var studentExtended = databaseStudentReader.GetExtendedProxy(student);
            var disciplines     = databaseDisciplineReader.GetDisciplinesWithUsingFilters(null, null, studentExtended.GroupName)
                                  .Select(databaseDisciplineReader.GetExtendedProxy).ToArray();
            var group = databaseGroupReader.GetGroupsWithUsingFilters(studentExtended.GroupName)
                        .Select(databaseGroupReader.GetExtendedProxy).First();

            using (var outputDocument = new TemplateProcessor(tempDocumentName).SetRemoveContentControls(true)) {
                outputDocument.FillContent(CreateContent(studentExtended, disciplines, group));
                outputDocument.SaveChanges();
            }

            var fileWithContent = new FileWithContent(TemplateName, File.ReadAllBytes(tempDocumentName));

            File.Delete(tempDocumentName);
            return(fileWithContent);
        }
Exemplo n.º 3
0
        protected override GroupBasedProxy[] Run(NameValues parameters, byte[] requestBody)
        {
            var groupName = parameters.GetValueOrNull(HttpParameters.GroupName);

            return(databaseGroupReader.GetGroupsWithUsingFilters(groupName));
        }