Exemple #1
0
            public async Task UpdateView_ReturnsAViewResult_WithData()
            {
                // Arrange
                var attes = new Attendance()
                {
                    Id          = 1,
                    PassesCount = 3,
                    StudentId   = 1,
                    SubjectId   = 1,
                    Student     = new Student {
                        Faculty = "AMI"
                    }
                };

                var mockLogic    = new Mock <IAttendancesLogic>();
                int attendanceId = 1;

                mockLogic.Setup(repo => repo.GetAttendance(attendanceId)).Returns(Task.FromResult(attes));
                var controller = new AttendancesController(mockLogic.Object);

                //  Act
                IActionResult actionResult = await controller.Edit(attendanceId, attes);

                // Assert
                var viewResult = Assert.IsType <RedirectToActionResult>(actionResult);

                mockLogic.Verify(repo => repo.UpdateAttendance(attes), Times.Once);
            }
Exemple #2
0
        public void AddAttendanceNoPerson()
        {
            int      groupId        = 111;
            int      locationId     = 14;
            int      scheduleId     = 19;
            DateTime occurrenceDate = new DateTime(2019, 8, 5);
            int?     personId       = null;
            int?     personAliasId  = null;

            var attendancesController = new AttendancesController();

            Rock.Model.Attendance attendance = new Rock.Model.Attendance();
            System.Web.Http.HttpResponseException exception = null;

            try
            {
                attendance = attendancesController.AddAttendance(groupId, locationId, scheduleId, occurrenceDate, personId, personAliasId);
            }
            catch (System.Web.Http.HttpResponseException ex)
            {
                exception = ex;
            }
            finally
            {
                Assert.IsTrue(exception.Response.StatusCode == System.Net.HttpStatusCode.BadRequest);
            }
        }
Exemple #3
0
            public async Task GetAttendence_OnlyOnce()
            {
                // Arrange
                var attes = new List <Attendance>()
                {
                    new Attendance
                    {
                        Id          = 1,
                        PassesCount = 3,
                        StudentId   = 1,
                        SubjectId   = 1,
                        Student     = new Student {
                            Faculty = "AMI"
                        }
                    }
                };
                var mockLogic = new Mock <IAttendancesLogic>();

                mockLogic.Setup(repo => repo.GetAttendances()).Returns(Task.FromResult(attes));
                var controller = new AttendancesController(mockLogic.Object);

                // Act
                var result = await controller.Index();

                // Assert
                var viewResult = Assert.IsType <ViewResult>(result);
                var model      = Assert.IsAssignableFrom <List <Attendance> >(
                    viewResult.ViewData.Model);

                mockLogic.Verify(s => s.GetAttendances(), Times.Once);
                Assert.Equal(attes[0].Student.Faculty, model[0].Student.Faculty);
            }
        public void Delete_Valid_Detail()
        {
            AttendanceRep         res = new AttendanceRep(db);
            AttendancesController obj = new AttendancesController(res);
            var data     = obj.Delete(1);
            var okResult = data as OkObjectResult;

            Assert.AreEqual(200, okResult.StatusCode);
        }
        public void GetDetailTest()
        {
            AttendanceRep         res  = new AttendanceRep(db);
            AttendancesController obj  = new AttendancesController(res);
            IActionResult         data = obj.Get(1);
            var okResult = data as OkObjectResult;

            Assert.AreEqual(200, okResult.StatusCode);
        }
        public void TestInitialize()
        {
            _mockUnitOfWork = new Mock <IUnitOfWork>();
            _mockUnitOfWork.SetupGet(u => u.Attendances).Returns(new Mock <IAttendancesRepository>().Object);

            _sut    = new AttendancesController(_mockUnitOfWork.Object);
            _userId = "1";
            _sut.MockCurrentUser(_userId, "*****@*****.**");
        }
        public void GetDetailsTest()
        {
            var res = new Mock <AttendanceRep>(db);
            AttendancesController obj = new AttendancesController(res.Object);
            var data     = obj.Get(1);
            var okResult = data as OkObjectResult;

            Assert.AreEqual(200, okResult.StatusCode);
        }
        public void SetUp()
        {
            _mockAttandanceRepository = new Mock <IAttendanceRepository>();

            _mockUnitOfWork = new Mock <IUnitOfWork>();
            _mockUnitOfWork.SetupGet(u => u.Attendances).Returns(_mockAttandanceRepository.Object);

            _controller = new AttendancesController(_mockUnitOfWork.Object);
            _controller.MockCurrentUser(_UserId, _UserName);
        }
Exemple #9
0
        public void Testinitialize()
        {
            _mockRepository = new Mock <IAttendanceRepository>();
            var mockUoW = new Mock <IUnitOfWork>();

            mockUoW.SetupGet(r => r.Attendance).Returns(_mockRepository.Object);

            _controller = new AttendancesController(mockUoW.Object);
            _controller.MockCurrentUser(_userId, _username);
        }
        public void TestInitialize()
        {
            _mockRepository = new Mock <IAttendanceRepository>();
            var mockUoW = new Mock <IUnitOfWork>();

            mockUoW.Setup(u => u.Attendance).Returns(_mockRepository.Object);
            _controller = new AttendancesController(mockUoW.Object);
            _controller.MockCurrentUser("1", "*****@*****.**");
            _userId = "1";
        }
        public AttendancesControllerTest()
        {
            _userRepository        = new Mock <IUserRepository>();
            _dayActivityRepository = new Mock <IDayActivityRepository>();
            _attendanceRepository  = new Mock <IAttendanceRepository>();

            _dummyDBContext = new DummyDBContext();

            _controller = new AttendancesController(_userRepository.Object, _dayActivityRepository.Object, _attendanceRepository.Object);
        }
        public void TestInitialize()
        {
            _mockRepositoty = new Mock <IAttendanceRepository>();
            var mockUnitOfWork = new Mock <IUnitOfWork>();

            mockUnitOfWork.Setup(m => m.Attendances).Returns(_mockRepositoty.Object);
            _controller = new AttendancesController(mockUnitOfWork.Object);
            _userId     = "2";
            _controller.MockCurrentUser(_userId, "*****@*****.**");
        }
Exemple #13
0
        public void TestInitialize()
        {
            _mockRepository = new Mock <IAttendanceRepository>();
            _mockUoW        = new Mock <IUnitOfWork>();
            _mockUoW.SetupGet(u => u.Attendances).Returns(_mockRepository.Object);

            _userId     = "1";
            _controller = new AttendancesController(_mockUoW.Object);
            _controller.MockCurrentUser(_userId, "*****@*****.**");
        }
        public void TestInitialize()
        {
            _mockRepository = new Mock <IAttendanceRepository>();
            var mockUoW = new Mock <IUnitOfWork>();

            mockUoW.SetupGet(u => u.Attendance).Returns(_mockRepository.Object);
            _attendancesController = new AttendancesController(mockUoW.Object);
            _userid = "1";
            _attendancesController.MockCurrentUser(_userid, "*****@*****.**");
        }
        public AttendancesControllerTests()
        {
            _mockRepository = new Mock <IAttendanceRepository>();
            var mockUnitOfWork = new Mock <IUnitOfWork>();

            mockUnitOfWork.SetupGet(u => u.AttendanceRepository).Returns(_mockRepository.Object);

            _controller = new AttendancesController(mockUnitOfWork.Object);
            _userId     = "1";
            _controller.MockUser(_userId, "*****@*****.**");
        }
        public AttendancesControllerTests()
        {
            _attendanceRepository = new Mock <IAttendanceRepository>();

            _unitOfWork = new Mock <IUnitOfWork>();
            _unitOfWork.SetupGet(a => a.Attendances).Returns(_attendanceRepository.Object);

            _userId     = "1";
            _controller = new AttendancesController(_unitOfWork.Object);
            _controller.MockCurrentUser(_userId, "*****@*****.**");
        }
Exemple #17
0
        public void TestInicialize()
        {
            _mockRepository = new Mock <IAttendanceRepository>();
            var mockUnitOfWork = new Mock <IUnitOfWork>();

            mockUnitOfWork.SetupGet(a => a.Attendances).Returns(_mockRepository.Object);

            _controller = new AttendancesController(mockUnitOfWork.Object);
            _userId     = "1";
            _controller.MockCurrentUser(_userId, "*****@*****.**");
        }
Exemple #18
0
        public AttendancesControllerTests()
        {
            _mockAttendanceRepository = new Mock <IAttendanceRepository>();
            var mockUoW = new Mock <IUnitOfWork>();

            mockUoW.Setup(u => u.Attendances).Returns(_mockAttendanceRepository.Object);

            _controller = new AttendancesController(mockUoW.Object);
            _userId     = "1";
            _controller.MockCurrentUser(_userId, "*****@*****.**");
        }
Exemple #19
0
        public void SetUp()
        {
            _mockRepository = new Mock <IAttendanceRepository>();

            var mockUnitOfWork = new Mock <IUnitOfWork>();

            mockUnitOfWork.SetupGet(u => u.Attendances).Returns(_mockRepository.Object);

            _controller = new AttendancesController(mockUnitOfWork.Object);
            _userId     = "1";
            _controller.MockCurrentUser(_userId, "*****@*****.**");
        }
        public void TestInitialize()
        {
            _userId = "1";

            _mockRepo = new Mock <IAttendanceRepo>();
            var mockUoW = new Mock <IUnitOfWork>();

            mockUoW.SetupGet(u => u.Attendances).Returns(_mockRepo.Object);

            _controller = new AttendancesController(mockUoW.Object);
            _controller.MockCurrentUser(_userId, "*****@*****.**");
        }
        public void TestInitialize()
        {
            _mockRepository = new Mock <IAttendanceRepository>();

            var mockUoW = new Mock <IUnitOfWork>();

            mockUoW.SetupGet(u => u.Attendances).Returns(_mockRepository.Object);

            _controller = new AttendancesController(mockUoW.Object);
            _userId     = "87aa1ce5-a727-4044-b00c-4014a23e8912";
            _controller.MockCurrentUser(_userId, "*****@*****.**");
            _gigId = 1;
        }
        public void Update_Valid_Detail()
        {
            AttendanceRep         res = new AttendanceRep(db);
            AttendancesController obj = new AttendancesController(res);

            Attendance emp = new Attendance {
                RollNo = 1, Attendance1 = "32", Result = 96
            };
            var data     = obj.Put(1, emp);
            var okResult = data as OkObjectResult;

            Assert.AreEqual(200, okResult.StatusCode);
        }
        public void Add_Valid_Detail()
        {
            var res = new Mock <AttendanceRep>(db);
            AttendancesController obj = new AttendancesController(res.Object);
            Attendance            emp = new Attendance {
                RollNo = 1, Attendance1 = "59", Result = 96
            };

            var data     = obj.Post(emp);
            var okResult = data as OkObjectResult;

            Assert.AreEqual(200, okResult.StatusCode);
        }
Exemple #24
0
        public void TestInitilize()//public GigControllerTests()
        {
            _mockRepository = new Mock <IAttendanceRepository>();

            var mockUnitOfWork = new Mock <IUnitOfWork>();

            mockUnitOfWork.SetupGet(u => u.Attendance).Returns(_mockRepository.Object);

            //referencing controller from our project, therefore we need an object passed to this controller
            _controller = new AttendancesController(mockUnitOfWork.Object);
            // this mock.Object is an actual implementation of IUnitOfWork
            _userId = "1";
            _controller.MockCurrentUser(_userId, "*****@*****.**"); //this is an extension method
        }
        public void DeletetAttendance_ShouldReturnOk()
        {
            //Arrange
            testSchoolRegisterContext = new TestSchoolRegisterContext();
            attendanceRepo            = new MockAttendanceRepo(testSchoolRegisterContext);
            attendancesController     = new AttendancesController(attendanceRepo);
            PopulateAttendanceFields();

            //Act
            var actionResult = attendancesController.DeleteAttendance(1);

            // Assert
            Assert.IsNotNull(actionResult);
        }
        public void TestInitialize()
        {
            _mockRepository = new Mock <IAttendanceRepository>();

            var mockUoW = new Mock <IUnityOfWork>();

            mockUoW.SetupGet(u => u.Attendances).Returns(_mockRepository.Object);

            var appUser = new MockApplicationUser();

            _controller = new AttendancesController(appUser.TestUserManager <ApplicationUser>(), mockUoW.Object);
            _userId     = "1";
            _controller.MockCurrentUser(_userId, "*****@*****.**");
        }
Exemple #27
0
        public void AddAttendance()
        {
            int      groupId        = 111;
            int      locationId     = 14;
            int      scheduleId     = 19;
            DateTime occurrenceDate = new DateTime(2019, 8, 12);
            int?     personId       = 4;
            int?     personAliasId  = null;

            var attendancesController = new AttendancesController();

            var attendance = attendancesController.AddAttendance(groupId, locationId, scheduleId, occurrenceDate, personId, personAliasId);

            Assert.IsNotNull(attendance);
        }
Exemple #28
0
        public void TestInitialize()
        {
            _mockRepository = new Mock <IAttendanceRepository>();

            var mockUoW = new Mock <IUnitOfWork>();

            mockUoW.SetupGet(u => u.Attendances).Returns(_mockRepository.Object);

            _controller = new AttendancesController(mockUoW.Object);
            _userId     = "1";
            _controller.MockCurrentUser(_userId, "user1");

            _dto = new AttendanceDto {
                GigId = 1
            };
        }
        public void GetAttendance_ShouldReturnOk()
        {
            //Arrange
            testSchoolRegisterContext = new TestSchoolRegisterContext();
            attendanceRepo            = new MockAttendanceRepo(testSchoolRegisterContext);
            attendancesController     = new AttendancesController(attendanceRepo);
            PopulateAttendanceFields();

            //Act
            var actionResult  = attendancesController.Get(1);
            var contentResult = actionResult as OkNegotiatedContentResult <AttendanceDto>;

            // Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(1, contentResult.Content.Id);
        }
        public void TestInitialize()
        {
            // Create mock repository - will be empty unless setup in test methods below
            _mockRepository = new Mock <IAttendanceRepository>();

            // Create a mock unit of work
            var mockUoW = new Mock <IUnitOfWork>();                               // because we are unit testing the controller, we don't want to couple to the real UnitOfWork which uses EntityFramework to talk to the db

            mockUoW.SetupGet(a => a.Attendances).Returns(_mockRepository.Object); // * --> when we access the Attendances property of UoW, we get the mock repository *

            // Create the controller
            _controller = new AttendancesController(mockUoW.Object);             // the Object property is the actual mock implementation of IUnitOfWork

            // Set controller user w/ the generic principal object by calling extension method, passing in the userid/username we want to use
            _userId = "1";
            _controller.MockCurrentUser(_userId, "*****@*****.**");
        }
        protected void btnPlayer_Click(object sender, EventArgs e)
        {
            using (AttendancesController ac = new AttendancesController())
            {
                ClickablePanel panel = (ClickablePanel)sender;

                ac.AddNew(new Attendance()
                {
                    CreateDate = DateTime.Now.ToUniversalTime(),
                    CreateUserID = CurrentUser.UserID,
                    IsActive = true,
                    PlayerID = panel.PlayerID,
                    TeamScheduleID = TeamScheduleID.Value
                });

                panel.CssClass += " success";
                panel.IsDisabled = true;
            }
        }