Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the form Shedule class.
        /// </summary>
        public Shedule()
        {
            InitializeComponent();
            cellPos = new int[2];

            grades       = new List <Grade>();
            subjects     = new List <Subject>();
            appointments = new List <Appointment>();

            taskController          = new TaskController();
            repeatingTaskController = new RepeatingTaskController();
            gradeController         = new GradeController();
            subjectController       = new SubjectController();
            appointmentController   = new AppointmentController();

            for (int i = 0; i < dgvShedule.Columns.Count; i++)
            {
                dgvShedule.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
            }

            for (int i = 0; i < 7; i++)
            {
                dgvShedule.Columns[i].HeaderText = DateTime.Today.AddDays(i).ToString("dd-MM-yyyy");
            }

            CleanupExpiredRecords();
            LoadToGrid(typeof(Task));
        }
        public void CreateGrade(string grName, int language_Id)
        {
            Grade           grade = new Grade(grName, language_Id);
            GradeController gc    = new GradeController();

            gc.Create(grade);
        }
        private GradeController GetController(IGradeService service, IIdentityProvider identityProvider, IValidateService validateService)
        {
            var claimPrincipal = new Mock <ClaimsPrincipal>();
            var claims         = new Claim[]
            {
                new Claim("username", "unittestusername")
            };

            claimPrincipal.Setup(claim => claim.Claims).Returns(claims);

            var controller = new GradeController(service, identityProvider, validateService)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = new DefaultHttpContext()
                    {
                        User = claimPrincipal.Object
                    }
                }
            };

            controller.ControllerContext.HttpContext.Request.Headers["Authorization"]     = "Bearer unittesttoken";
            controller.ControllerContext.HttpContext.Request.Headers["x-timezone-offset"] = $"{It.IsAny<int>()}";
            controller.ControllerContext.HttpContext.Request.Path = new PathString("/v1/unit-test");

            return(controller);
        }
    int[] toCalcScores = new int[2];     //This holds the number correct and the number of questions for homework


    public void Start()
    {
        OwO = GameObject.Find("HomeworkInterface").GetComponent <HomeworkInterface>();

        OwO = transform.parent.gameObject.GetComponent <HomeworkInterface>();

        graCon = GameObject.Find("Grade");
        gc     = (GradeController)graCon.GetComponent(typeof(GradeController));
    }
 /// <summary>
 /// Initializes a new instance of the form EditSubject class.
 /// </summary>
 /// <param name="model">Subject details to edit.</param>
 public EditSubject(Subject model)
 {
     InitializeComponent();
     this.model        = model;
     subjectController = new SubjectController();
     gradeController   = new GradeController();
     grades            = gradeController.Details();
     subjects          = subjectController.Details();
     txtName.Text      = model.Name;
 }
        public void GradeEditViewResultNotNull()
        {
            GradeName g = new GradeName();
            // Arrange
            GradeController controller = new GradeController();
            // Act
            ViewResult result = controller.GradeEdit(g) as ViewResult;

            // Assert
            Assert.NotNull(result);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the form DeleteUsers class.
 /// </summary>
 /// <param name="user">User details to extract.</param>
 public DeleteUsers(User user)
 {
     InitializeComponent();
     this.user                    = user;
     userController               = new UserController();
     taskController               = new TaskController();
     repeatingTaskController      = new RepeatingTaskController();
     gradeController              = new GradeController();
     subjectController            = new SubjectController();
     appointmentController        = new AppointmentController();
     dgvUsers.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
     LoadToGrid();
 }
        /// <summary>
        /// Initializes a new instance of the form Shedule class.
        /// </summary>
        /// <param name="model">User details to extract.</param>
        public Shedule(User model)
        {
            InitializeComponent();
            this.currentUser  = model;
            this.selectedUser = model;
            cellPos           = new int[2];
            logout            = false;

            grades       = new List <Grade>();
            subjects     = new List <Subject>();
            appointments = new List <Appointment>();

            taskController          = new TaskController();
            repeatingTaskController = new RepeatingTaskController();
            userController          = new UserController();
            gradeController         = new GradeController();
            subjectController       = new SubjectController();
            appointmentController   = new AppointmentController();

            for (int i = 0; i < dgvShedule.Columns.Count; i++)
            {
                dgvShedule.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
            }

            for (int i = 0; i < 7; i++)
            {
                dgvShedule.Columns[i].HeaderText = DateTime.Today.AddDays(i).ToString("dd-MM-yyyy");
            }

            lblUsername.Text = model.Username;
            if (model.Role != "Admin")
            {
                lblViewUser.Visible        = false;
                cbUsernames.Visible        = false;
                lblViewDeleteUsers.Visible = false;
                btnDeleteUser.Visible      = false;
            }
            else
            {
                cbUsernames.Click         += cbUsernames_Click;
                lblViewUser.Visible        = true;
                cbUsernames.Visible        = true;
                lblViewDeleteUsers.Visible = true;
                btnDeleteUser.Visible      = true;
                cbUsernames.Items.Add(currentUser.Username + " (ik)");
                cbUsernames.SelectedIndex = 0;
            }

            CleanupExpiredRecords();
            LoadToGrid(typeof(Task));
        }
Exemplo n.º 9
0
        public void Teacher_Role_Should_Be_Able_To_Edit_Grade(GradeController sut)
        {
            //arrange
            var roles  = new string[] { "teacher" };
            var method = sut.GetType().GetMethod("Index");
            //act
            var attrib = method.GetCustomAttributes(typeof(AuthorizeAttribute), true).FirstOrDefault() as AuthorizeAttribute;

            if (attrib == null)
            {
                throw new Exception();
            }
            //assert
            attrib.Roles.ShouldContain(roles[0]);
        }
        public void Grade_ShouldCallBusinessLogicMethodWithCurrentUserAndRedirectToShowArticle()
        {
            var mockLogic = new Mock <GradeLogic>();
            var mockUser  = new Mock <IPrincipal>();

            mockUser.SetupGet(u => u.Identity.Name).Returns("asmunde");
            var controller = new GradeController(mockLogic.Object);

            controller.MockUser = mockUser.Object;

            var result = (RedirectToRouteResult)controller.GradeArticle(20, 4);

            mockLogic.Verify(logic => logic.GradeArticle(20, "asmunde", 4));
            Assert.That(result.RouteValues["controller"], Is.EqualTo("Article"));
            Assert.That(result.RouteValues["action"], Is.EqualTo("Show"));
            Assert.That(result.RouteValues["id"], Is.EqualTo(20));
        }
Exemplo n.º 11
0
        public void TestInitialize()
        {
            this.logger           = new Mock <ILogger <GradeController> >();
            this.telemetryClient  = new TelemetryClient(new TelemetryConfiguration());
            this.unitOfWork       = new Mock <IUnitOfWork>();
            this.gradeMapper      = new Mock <IGradeMapper>();
            this.usersServiceMock = new Mock <IUsersService>();

            this.gradeController = new GradeController(
                this.logger.Object,
                this.telemetryClient,
                this.unitOfWork.Object,
                this.gradeMapper.Object,
                this.usersServiceMock.Object)
            {
                ControllerContext = new ControllerContext(),
            };
            this.gradeController.ControllerContext.HttpContext =
                FakeHttpContext.GetDefaultContextWithUserIdentity();
        }
Exemplo n.º 12
0
        public void Teacher_Role_Should_Be_Able_To_Update_Grade(GradeController sut)
        {
            //arrange
            var roles = new List <string> {
                "teacher"
            };
            var unauthorizedRoles = new List <string> {
                "student", "prospect"
            };
            var method = sut.GetType().GetMethod("AddGrade");
            //act
            var attrib = method.GetCustomAttributes(typeof(AuthorizeAttribute), true).FirstOrDefault() as AuthorizeAttribute;

            if (attrib == null)
            {
                throw new Exception();
            }
            //assert
            attrib.Roles.ShouldContain(roles[0]);
            unauthorizedRoles.ForEach(r => attrib.Roles.ShouldNotContain(r));
        }
Exemplo n.º 13
0
 public void show()
 {
     pageLayout = GradeController.getStudentGradeInfo();
 }