Пример #1
0
        public void Setup()
        {
            _context = ContextHelper.GetDatabaseContext();

            sut = new InternshipService(_context);

            dto = new InternshipCreationDto
            {
                RequiredFieldsOfStudy  = new List <string>(),
                AssignedStudents       = new List <string>(),
                Environment            = new List <string>(),
                TechnicalDescription   = "TechnicalDescription",
                ExtraRequirements      = "ExtraRequirements",
                ResearchTheme          = "ResearchTheme",
                Activities             = new List <string>(),
                RequiredStudentsAmount = 2,
                AdditionalRemarks      = "AdditionalRemarks",
                PeriodOfInternship     = new List <string>(),
                Description            = "Description"
            };

            for (int i = 0; i < 10; i++)
            {
                dto.RequiredFieldsOfStudy.Add("ReqFOS" + i);
                dto.AssignedStudents.Add("AssignedStudent" + i);
                dto.Environment.Add("Environment" + i);
                dto.Activities.Add("Activity" + i);
                dto.PeriodOfInternship.Add("Period" + i);
            }

            internship = new Internship
            {
                CreatorId              = Guid.NewGuid(),
                RequiredFieldsOfStudy  = dto.RequiredFieldsOfStudy,
                AssignedStudents       = dto.AssignedStudents,
                Environment            = dto.Environment,
                TechnicalDescription   = "TechnicalDescription",
                ExtraRequirements      = "ExtraRequirements",
                ResearchTheme          = "ResearchTheme",
                Activities             = dto.Activities,
                RequiredStudentsAmount = 2,
                AdditionalRemarks      = "AdditionalRemarks",
                Id = Guid.NewGuid(),
                InternshipState = 0,
                Periods         = dto.PeriodOfInternship,
                Description     = "Description",
                DateOfState     = DateTime.UtcNow
            };

            userTeacher = new User
            {
                Id           = Guid.NewGuid(),
                City         = "City",
                Email        = "*****@*****.**",
                FirstName    = "John",
                HouseNumber  = 18,
                LastName     = "Doe",
                PasswordHash = Guid.NewGuid().ToString(),
                PhoneNumber  = "+3259874896",
                ZipCode      = 7890,
                UserName     = "******",
                StreetName   = "Easy Street"
            };

            userTeacher2 = new User
            {
                Id           = Guid.NewGuid(),
                City         = "City",
                Email        = "*****@*****.**",
                FirstName    = "John",
                HouseNumber  = 18,
                LastName     = "Doe",
                PasswordHash = Guid.NewGuid().ToString(),
                PhoneNumber  = "+3259874896",
                ZipCode      = 7890,
                UserName     = "******",
                StreetName   = "Easy Street"
            };

            company = new Company
            {
                Id = internship.CreatorId
            };


            ReviewerInternships reviewerInternships = new ReviewerInternships
            {
                ReviewedInternship = internship,
                Reviewer           = userTeacher
            };

            reviewerList = new List <ReviewerInternships> {
                reviewerInternships
            };

            internship.Reviewers = reviewerList;

            IFCDto = new InternshipFeedbackCoordinatorDto
            {
                Feedback      = "coordinator",
                InternshipId  = internship.Id,
                ReviewedState = InternshipState.ApprovedByAll
            };

            IFTDto = new InternshipFeedbackTeacherDto
            {
                Feedback     = "teacher",
                InternshipId = internship.Id,
                TeacherId    = userTeacher.Id
            };

            updateDto = new InternshipUpdate
            {
                ID            = internship.Id,
                ResearchTheme = "ResearchTheme",
                Description   = "DescriptionUpdate",
                Activities    = new List <string>()
                {
                    "test"
                },
                AdditionalRemarks = "test",
                AssignedStudents  = new List <string>()
                {
                    "Jan"
                },
                Environment = new List <string>()
                {
                    "test"
                },
                ExtraRequirements  = "test",
                PeriodOfInternship = new List <string>()
                {
                    "test"
                },
                RequiredFieldsOfStudy = new List <string>()
                {
                    "AON"
                },
                RequiredStudentsAmount = 1,
                TechnicalDescription   = "test",
                Title = "test"
            };

            _context.Add(reviewerInternships);
            _context.Add(userTeacher);
            _context.Add(internship);
            _context.SaveChanges();
        }
Пример #2
0
        public void Setup()
        {
            _context = ContextHelper.GetDatabaseContext();

            sut = new UserService(_context);

            userTeacher = new User
            {
                Id           = Guid.NewGuid(),
                City         = "City",
                Email        = "*****@*****.**",
                FirstName    = "John",
                HouseNumber  = 18,
                LastName     = "Doe",
                PasswordHash = Guid.NewGuid().ToString(),
                PhoneNumber  = "+3259874896",
                ZipCode      = 7890,
                UserName     = "******",
                StreetName   = "Easy Street",
                IsValidated  = false
            };

            company = new Company
            {
                CompanyTitle = "Test inc."
            };

            dtoTeacher = new UserReadDto
            {
                FirstName = userTeacher.FirstName,
                LastName  = userTeacher.LastName,
                Id        = userTeacher.Id
            };

            userCompany = new User
            {
                Id           = Guid.NewGuid(),
                City         = "City",
                Email        = "*****@*****.**",
                FirstName    = "Johnnie",
                HouseNumber  = 19,
                LastName     = "Doe",
                PasswordHash = Guid.NewGuid().ToString(),
                PhoneNumber  = "+3259874896",
                ZipCode      = 7890,
                UserName     = "******",
                StreetName   = "Easy Street",
                IsValidated  = false
            };

            dtoCompany = new UserReadDto
            {
                FirstName = userCompany.FirstName,
                LastName  = userCompany.LastName,
                Id        = userCompany.Id
            };

            userStudent = new User
            {
                Id           = Guid.NewGuid(),
                City         = "City",
                Email        = "*****@*****.**",
                FirstName    = "Henk",
                HouseNumber  = 17,
                LastName     = "Doe",
                PasswordHash = Guid.NewGuid().ToString(),
                PhoneNumber  = "+3259874896",
                ZipCode      = 7890,
                UserName     = "******",
                StreetName   = "Easy Street",
                IsValidated  = false
            };

            dtoStudent = new UserReadDto
            {
                FirstName = userStudent.FirstName,
                LastName  = userStudent.LastName,
                Id        = userStudent.Id
            };

            roleCompany = new Role
            {
                Id             = Guid.NewGuid(),
                Name           = "Company",
                NormalizedName = "COMPANY"
            };

            roleStudent = new Role
            {
                Id             = Guid.NewGuid(),
                Name           = "Student",
                NormalizedName = "STUDENT"
            };

            roleTeacher = new Role
            {
                Id             = Guid.NewGuid(),
                Name           = "Teacher",
                NormalizedName = "TEACHER"
            };

            internship = new Internship
            {
                RequiredFieldsOfStudy  = new List <string>(),
                AssignedStudents       = new List <string>(),
                Environment            = new List <string>(),
                TechnicalDescription   = "TechnicalDescription",
                ExtraRequirements      = "ExtraRequirements",
                ResearchTheme          = "ResearchTheme",
                Activities             = new List <string>(),
                RequiredStudentsAmount = 2,
                AdditionalRemarks      = "AdditionalRemarks",
                Periods         = new List <string>(),
                Description     = "Description",
                DateCreated     = DateTime.UtcNow,
                DateOfState     = DateTime.UtcNow,
                Id              = Guid.NewGuid(),
                InternshipState = 0,
                Reviewers       = new List <ReviewerInternships> {
                    new ReviewerInternships
                    {
                        ReviewedInternship = internship,
                        Reviewer           = userTeacher
                    }
                }
            };

            updateUser = new UserUpdate
            {
                FieldOfStudy = "UpdatedFOS"
            };

            userValidateDto = new UserValidateDto
            {
                Id        = userCompany.Id,
                Validated = true
            };

            pwDto = new ChangePasswordDto
            {
                OldPassword = userStudent.PasswordHash,
                NewPassword = "******"
            };

            companyUpdate = new CompanyUpdate
            {
                CompanyName = "Updated"
            };

            _context.Add(company);

            _context.Add(userCompany);
            _context.Roles.Add(roleCompany);
            _context.UserRoles.Add(new Microsoft.AspNetCore.Identity.IdentityUserRole <Guid>
            {
                RoleId = roleCompany.Id,
                UserId = userCompany.Id
            });
            _context.Add(userTeacher);
            _context.Roles.Add(roleTeacher);
            _context.UserRoles.Add(new Microsoft.AspNetCore.Identity.IdentityUserRole <Guid>
            {
                RoleId = roleTeacher.Id,
                UserId = userTeacher.Id
            });
            _context.Add(userStudent);
            _context.Roles.Add(roleStudent);
            _context.UserRoles.Add(new Microsoft.AspNetCore.Identity.IdentityUserRole <Guid>
            {
                RoleId = roleStudent.Id,
                UserId = userStudent.Id
            });
            _context.Add(internship);
            _context.SaveChanges();
        }
        public void Setup()
        {
            _context = ContextHelper.GetDatabaseContext();

            moqInternshipService = new Mock <IInternshipService>();
            moqUserService       = new Mock <IUserService>();

            userTeacher = new User
            {
                Id           = Guid.NewGuid(),
                City         = "City",
                Email        = "*****@*****.**",
                FirstName    = "John",
                HouseNumber  = 18,
                LastName     = "Doe",
                PasswordHash = Guid.NewGuid().ToString(),
                PhoneNumber  = "+3259874896",
                ZipCode      = 7890,
                UserName     = "******",
                StreetName   = "Easy Street"
            };

            internship = new Internship
            {
                RequiredFieldsOfStudy  = new List <string>(),
                AssignedStudents       = new List <string>(),
                Environment            = new List <string>(),
                TechnicalDescription   = "TechnicalDescription",
                ExtraRequirements      = "ExtraRequirements",
                ResearchTheme          = "ResearchTheme",
                Activities             = new List <string>(),
                RequiredStudentsAmount = 2,
                AdditionalRemarks      = "AdditionalRemarks",
                Id = Guid.NewGuid(),
                InternshipState = 0,
                Periods         = new List <string>(),
                Description     = "Description",
                DateOfState     = DateTime.UtcNow,
            };

            roleTeacher = new Role
            {
                Id             = Guid.NewGuid(),
                Name           = "Teacher",
                NormalizedName = "TEACHER"
            };

            ReviewerInternships reviewerInternships = new ReviewerInternships
            {
                ReviewedInternship = internship,
                Reviewer           = userTeacher
            };

            reviewerList = new List <ReviewerInternships> {
                reviewerInternships
            };

            internship.Reviewers = reviewerList;

            var store = new Mock <IUserStore <User> >();


            moqUserManager = new Mock <UserManager <User> >(store.Object, null, null, null, null, null, null, null, null);

            moqUserManager.Object.UserValidators.Add(new UserValidator <User>());
            moqUserManager.Object.PasswordValidators.Add(new PasswordValidator <User>());



            sut = new InternshipController(moqInternshipService.Object, moqUserService.Object, moqUserManager.Object);

            assignDto = new InternshipAssign
            {
                InternshipID = Guid.NewGuid(),
                Teachers     = new List <Guid> {
                    Guid.NewGuid()
                }
            };

            _context.Add(userTeacher);
            _context.Roles.Add(roleTeacher);
            _context.UserRoles.Add(new IdentityUserRole <Guid>
            {
                RoleId = roleTeacher.Id,
                UserId = userTeacher.Id
            });

            _context.SaveChanges();
        }