public void Start() { course = transform.parent.GetComponent <CourseController>(); score = 0; }
private void lvwCourses_ItemActivate(object sender, EventArgs e) { mySelectedCourse = CourseController.getCourse(lvwCourses.SelectedItems[0].Text); this.Dispose(); }
public void SetUp() { _controller = new CourseController(Repository.Object); StubRequest(_controller); StubCursors(); }
// [Fact] public async Task AssignStudents_SetStudentsToCoursesAndRedirectsToCourses_WhenCoursesAndStudentsAreAssigned() { //Arrange const int courseId = 1; const int assignedStudentId = 11; const int nonAssignedStudentId = 22; const string courseName = "test"; CourseStudentAssignmentViewModel expectedModel = new CourseStudentAssignmentViewModel() { Id = courseId, Name = courseName, Students = new List <StudentViewModel>() { new StudentViewModel() { StudentId = assignedStudentId, StudentFullName = "Test1", IsAssigned = true }, new StudentViewModel() { StudentId = nonAssignedStudentId, StudentFullName = "Test2", IsAssigned = false } } }; var courseServiceMock = Substitute.For <CourseService>(); courseServiceMock.GetCourse(courseId).Returns(new Course() { Id = courseId, Name = courseName, Students = new List <StudentCourse>() { new StudentCourse() { StudentId = assignedStudentId } } }); var studentService = Substitute.For <StudentService>(); var students = new List <Student>() { new Student() { Id = assignedStudentId, Name = "Test1" }, new Student() { Id = nonAssignedStudentId, Name = "Test2" } }; studentService.GetAllStudents().Returns(students); var controller = new CourseController(courseServiceMock, studentService, null); // Act var actionResult = controller.AssignStudents(courseId); // Assert actionResult.Should().BeOfType <RedirectToActionResult>().Which.ActionName.Should().Be("Courses"); }
public void Setup() { var entities = new List <Course> { new Course { Id = 1, Name = "Test", StudentCourses = new List <StudentCourse>() }, new Course { Id = 2, Name = "Test2", StudentCourses = new List <StudentCourse>() } }; var config = new MapperConfiguration(opts => { opts.AddProfile(new CourseProfile()); }); var collection = entities.AsQueryable().BuildMock(); var mapper = config.CreateMapper(); Service = new Mock <ICourseService>(); Logger = new Mock <ILogger <CourseController> >(); Service.Setup(x => x.GetAllCourses()) .Returns(collection.Object); Service.Setup(x => x.GetAllCoursesWithStudents()) .Returns(collection.Object); Service.Setup(x => x.GetAllCoursesWithLecturer()) .Returns(collection.Object); Service.Setup(x => x.GetCourseById(It.IsAny <int>())) .Returns((int id) => Task.Run(() => entities.Find(t => t.Id == id))); Service.Setup(x => x.GetCourseWithLecturerById(It.IsAny <int>())) .Returns((int id) => Task.Run(() => entities.Find(t => t.Id == id))); Service.Setup(x => x.GetCourseWithStudentsById(It.IsAny <int>())) .Returns((int id) => Task.Run(() => entities.Find(t => t.Id == id))); Service.Setup(x => x.CreateCourse(It.IsAny <Course>())) .Callback((Course course) => entities.Add(course)); Service.Setup(x => x.UpdateCourse(It.IsAny <Course>())) .Callback((Course course) => entities[entities.FindIndex(x => x.Id == course.Id)] = course); Service.Setup(x => x.DeleteCourse(It.IsAny <Course>())) .Callback((Course course) => entities.RemoveAt(entities.FindIndex(x => x.Id == course.Id))); Service.Setup(x => x.AddStudentToCourse(It.IsAny <int>(), It.IsAny <int>())) .Callback((int courseId, int studentId) => entities[entities.FindIndex(x => x.Id == courseId)].StudentCourses.Add(new StudentCourse { CourseId = courseId, StudentId = studentId })); Controller = new CourseController(Service.Object, mapper, Logger.Object); }
public CourseTest() { _courseRepository = new CourseService(); _courseController = new CourseController(_courseRepository); }
public void Setup() { _mockCourseAccessLayer = new Mock <ICourseAccessLayer>(); _sut = new CourseController(_mockCourseAccessLayer.Object); _createdAt = DateTime.Now; }
public CourseService() { logic = new CourseController(); }
public void GivenInitializeMockingData() { var mock = ScenarioContext.Current.Get <MockRepository>(); var classRoomRepo = mock.Create <IClassRoomRepository>(); var likeLessonRepo = mock.Create <ILikeLessonRepository>(); var userprofileRepo = mock.Create <IUserProfileRepository>(); var classCalendarRepo = mock.Create <IClassCalendarRepository>(); var lessonCatalogRepo = mock.Create <ILessonCatalogRepository>(); var commentRepo = mock.Create <ICommentRepository>(); var friendRequestRepo = mock.Create <IFriendRequestRepository>(); var userActivityRepo = mock.Create <IUserActivityRepository>(); var likeCommentRepo = mock.Create <ILikeCommentRepository>(); var likeDiscussionRepo = mock.Create <ILikeDiscussionRepository>(); var studentKeyRepo = mock.Create <IStudentKeyRepository>(); var notificationRepo = mock.Create <INotificationRepository>(); var contractRepo = mock.Create <IContractRepository>(); var courseCatalogRepo = mock.Create <ICourseCatalogRepository>(); var paymentRepo = mock.Create <IPaymentRepository>(); var payment = mock.Create <Engines.IPayment>(); var logger = mock.Create <ILogger>(); var loggerFactory = mock.Create <ILoggerFactory>(); var appConfigOption = mock.Create <IOptions <AppConfigOptions> >(); var errorOption = mock.Create <IOptions <ErrorMessageOptions> >(); var httpContext = mock.Create <Microsoft.AspNet.Http.HttpContext>(); var dateTime = mock.Create <IDateTime>(); appConfigOption.Setup(it => it.Value).Returns(new AppConfigOptions()); errorOption.Setup(it => it.Value).Returns(new ErrorMessageOptions()); ScenarioContext.Current.Set(classRoomRepo); ScenarioContext.Current.Set(likeLessonRepo); ScenarioContext.Current.Set(userprofileRepo); ScenarioContext.Current.Set(classCalendarRepo); ScenarioContext.Current.Set(lessonCatalogRepo); ScenarioContext.Current.Set(commentRepo); ScenarioContext.Current.Set(friendRequestRepo); ScenarioContext.Current.Set(userActivityRepo); ScenarioContext.Current.Set(likeCommentRepo); ScenarioContext.Current.Set(likeDiscussionRepo); ScenarioContext.Current.Set(studentKeyRepo); ScenarioContext.Current.Set(notificationRepo); ScenarioContext.Current.Set(contractRepo); ScenarioContext.Current.Set(courseCatalogRepo); ScenarioContext.Current.Set(paymentRepo); ScenarioContext.Current.Set(payment); ScenarioContext.Current.Set(logger); ScenarioContext.Current.Set(loggerFactory); ScenarioContext.Current.Set(appConfigOption); ScenarioContext.Current.Set(errorOption); ScenarioContext.Current.Set(httpContext); ScenarioContext.Current.Set(dateTime); loggerFactory.Setup(it => it.CreateLogger(It.IsAny <string>())) .Returns(() => logger.Object); var notificationCtrl = new NotificationController(userprofileRepo.Object, notificationRepo.Object, likeLessonRepo.Object, likeCommentRepo.Object, likeDiscussionRepo.Object, commentRepo.Object, classCalendarRepo.Object, friendRequestRepo.Object, dateTime.Object); var lessonCtrl = new LessonController(classCalendarRepo.Object, userprofileRepo.Object, classRoomRepo.Object, likeLessonRepo.Object, lessonCatalogRepo.Object, commentRepo.Object, friendRequestRepo.Object, userActivityRepo.Object, notificationCtrl, appConfigOption.Object, dateTime.Object); var commentCtrl = new CommentController(classCalendarRepo.Object, userprofileRepo.Object, commentRepo.Object, userActivityRepo.Object, likeCommentRepo.Object, notificationCtrl, dateTime.Object); var discussionCtrl = new DiscussionController(classCalendarRepo.Object, userprofileRepo.Object, commentRepo.Object, userActivityRepo.Object, likeDiscussionRepo.Object, notificationCtrl, dateTime.Object); var myCourseCtrl = new MyCourseController(classCalendarRepo.Object, userprofileRepo.Object, userActivityRepo.Object, classRoomRepo.Object, studentKeyRepo.Object, lessonCatalogRepo.Object, likeLessonRepo.Object, likeCommentRepo.Object, likeDiscussionRepo.Object, contractRepo.Object, courseCatalogRepo.Object, loggerFactory.Object, dateTime.Object); var friendCtrl = new FriendController(classCalendarRepo.Object, userprofileRepo.Object, friendRequestRepo.Object, userActivityRepo.Object, classRoomRepo.Object, dateTime.Object); var courseCtrl = new CourseController(courseCatalogRepo.Object, appConfigOption.Object); var purchaseCtrl = new PurchaseController(courseCtrl, myCourseCtrl, userprofileRepo.Object, classRoomRepo.Object, classCalendarRepo.Object, lessonCatalogRepo.Object, userActivityRepo.Object, paymentRepo.Object, appConfigOption.Object, errorOption.Object, loggerFactory.Object, payment.Object, dateTime.Object); ScenarioContext.Current.Set(notificationCtrl); ScenarioContext.Current.Set(lessonCtrl); ScenarioContext.Current.Set(commentCtrl); ScenarioContext.Current.Set(discussionCtrl); ScenarioContext.Current.Set(myCourseCtrl); ScenarioContext.Current.Set(friendCtrl); ScenarioContext.Current.Set(purchaseCtrl); }
public CourseControllerTests() : base() { _controller = new CourseController(_courseService); }
public CourseControllerTests() { courseRepo = Substitute.For <IRepository <Course> >(); sut = new CourseController(courseRepo); }
public void Setup() { _courseServiceMock = new Mock <ICourseService>(); _mapperMock = new Mock <IMapper>(); _courseController = new CourseController(_courseServiceMock.Object, _mapperMock.Object); }
public async Task AssignLecturers_ReturnsViewResult_WithCoursesAndStudentsAreAssigned() { // Arrange const int courseId = 1; const int assignedLecturerId = 11; const int nonassignedLecturerId = 22; const string courseName = "test"; CourseLecturerAssignmentViewModel expectedModel = new CourseLecturerAssignmentViewModel() { Id = courseId, Name = courseName, Lecturers = new List <LecturersViewModel>() { new LecturersViewModel() { LecturerId = assignedLecturerId, Name = "Test1", IsAssigned = true }, new LecturersViewModel() { LecturerId = nonassignedLecturerId, Name = "Test2", IsAssigned = false } } }; var courseServiceMock = Substitute.For <CourseService>(); courseServiceMock.GetCourse(courseId).Returns(new Course() { Id = courseId, Name = courseName, Lecturers = new List <LecturerCourse>() { new LecturerCourse() { LecturerId = assignedLecturerId } } }); var lecturerService = Substitute.For <LecturerService>(); var lecturers = new List <Lecturer>() { new Lecturer() { Id = assignedLecturerId, Name = "Test1" }, new Lecturer() { Id = nonassignedLecturerId, Name = "Test2" } }; lecturerService.GetAllLecturers().Returns(lecturers); var controller = new CourseController(courseServiceMock, null, lecturerService); // Act var result = controller.AssignLecturers(courseId); // Assert var viewResult = Assert.IsType <ViewResult>(result); var actualModel = Assert.IsAssignableFrom <CourseLecturerAssignmentViewModel>(viewResult.ViewData.Model); actualModel.Should().BeEquivalentTo(expectedModel); }
public void AssignStudents_Get_ReturnsViewResult_WithCourseStudentsAssignmentViewModel() { // Arrange const int courseId = 1; const string courseName = "test"; const int assignedStudentId = 2; const int nonAssignedStudentId = 3; var allStudents = new List <Student>() { new Student() { Id = assignedStudentId }, new Student() { Id = nonAssignedStudentId } }; CourseStudentsAssignmentViewModel expectedModel = new CourseStudentsAssignmentViewModel() { Course = new Course() { Id = courseId, Name = courseName, Students = new List <Student>() { new Student() { Id = assignedStudentId } } }, StudentsAssignmentsList = new List <StudentAssignment>() { new StudentAssignment() { Student = new Student() { Id = assignedStudentId }, IsAssigned = true }, new StudentAssignment() { Student = new Student() { Id = nonAssignedStudentId }, IsAssigned = false } } }; var courseServiceMock = Substitute.For <CourseService>(); courseServiceMock.GetCourse(courseId).Returns(new Course() { Id = courseId, Name = courseName, Students = new List <Student>() { new Student() { Id = assignedStudentId } } }); var studentService = Substitute.For <StudentService>(); studentService.GetAllStudents().Returns(allStudents); var controller = new CourseController(courseServiceMock, studentService, null, null, null); // Act var result = controller.AssignStudents(courseId); // Assert var viewResult = Assert.IsType <ViewResult>(result); var actualModel = Assert.IsType <CourseStudentsAssignmentViewModel>(viewResult.Model); actualModel.WithDeepEqual(expectedModel).Assert(); }
public static void Main(string[] args) { CourseController _controller = new CourseController(new CourseRepository()); _controller.Process(); }
public void AssignLecturers_Get_ReturnsViewResult_WithCourseLecturersAssignmentViewModel() { // Arrange const int courseId = 1; const int assignedLecturerId = 2; const int nonAssignedLecturerId = 3; var allLecturers = new List <Lecturer>() { new Lecturer() { Id = assignedLecturerId }, new Lecturer() { Id = nonAssignedLecturerId } }; CourseLecturersAssignmentViewModel expectedModel = new CourseLecturersAssignmentViewModel() { Course = new Course() { Id = courseId, Lecturers = new List <Lecturer>() { new Lecturer() { Id = assignedLecturerId } } }, LecturersAssignmentsList = new List <LecturerAssignment>() { new LecturerAssignment() { Lecturer = new Lecturer() { Id = assignedLecturerId }, IsAssigned = true }, new LecturerAssignment() { Lecturer = new Lecturer() { Id = nonAssignedLecturerId }, IsAssigned = false } } }; var courseServiceMock = Substitute.For <CourseService>(); courseServiceMock.GetCourse(courseId).Returns(new Course() { Id = courseId, Lecturers = new List <Lecturer>() { new Lecturer() { Id = assignedLecturerId } } }); var lecturerServise = Substitute.For <LecturerService>(); lecturerServise.GetAllLecturers().Returns(allLecturers); var controller = new CourseController(courseServiceMock, null, null, null, lecturerServise); // Act var result = controller.AssignLecturers(courseId); // Assert var viewResult = Assert.IsType <ViewResult>(result); var actualModel = Assert.IsType <CourseLecturersAssignmentViewModel>(viewResult.Model); actualModel.WithDeepEqual(expectedModel).Assert(); }
public void ShouldCreateCorrectly() { Mock <IGenericService <Course> > courseServiceMock = new Mock <IGenericService <Course> >(); Mock <IActivityLoggerService> loggerMock = new Mock <IActivityLoggerService>(); Mock <IObjectFinderService <Module> > moduleFinderMock = new Mock <IObjectFinderService <Module> >(); Mock <IGenericService <Module> > moduleServiceMock = new Mock <IGenericService <Module> >(); Mock <IGenericService <Teacher> > teacherServiceMock = new Mock <IGenericService <Teacher> >(); Mock <IManyToManyMapperService <Course, CourseModule, Module> > mapperServiceMock = new Mock <IManyToManyMapperService <Course, CourseModule, Module> >(); Mock <IGenericService <ExamProgram> > examProgramServiceMock = new Mock <IGenericService <ExamProgram> >(); CourseCreateUpdateViewModel course = new CourseCreateUpdateViewModel() { Id = 100, Name = "Periode 2.3 Data Science", Description = "Alle opdrachten in deze periode zijn gekoppeld aan vakken; dit kunnen individuele of groepsopdrachten zijn; er zijn geen opdrachten die meerdere vakken betreffen. Daarom is een verdere omschrijving hier niet nodig." }; ClaimsPrincipal identity = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.NameIdentifier, "123") })); teacherServiceMock.Setup(m => m.FindById(It.IsAny <int>(), It.IsAny <string[]>())).Returns(new Teacher()); moduleFinderMock.Setup(m => m.AreIdsValid(It.IsAny <int[]>())).Returns(true); moduleFinderMock.Setup(m => m.GetObjects(It.IsAny <int[]>())).Returns((int[] ids) => { return(new List <Module>()); }); mapperServiceMock.Setup(m => m.GetMappedEntities(It.IsAny <Course>(), It.IsAny <ICollection <Module> >())).Returns <Course, ICollection <Module> >((model, modules) => { return(new List <CourseModule>()); }); courseServiceMock.Setup(m => m.Insert(It.IsAny <Course>())).Returns((Course model) => { if (!string.IsNullOrWhiteSpace(model.Name)) { return(1); } return(0); }); loggerMock.Setup(m => m.Create(It.IsAny <string>())); CourseController controller = new CourseController(courseServiceMock.Object, moduleServiceMock.Object, moduleFinderMock.Object, mapperServiceMock.Object, examProgramServiceMock.Object, teacherServiceMock.Object) { ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = identity } } }; RedirectToActionResult result = controller.Create(course) as RedirectToActionResult; Assert.Equal("Index", result?.ActionName); }
void Start() { if (!isBusrider) { ContentManager cm = FindObjectOfType <ContentManager>(); //initialize car data object. specs = new CarData(); //LOAD CAR SPECS TextAsset ass = cm.Cars[0].LoadAsset("specs.json") as TextAsset; specs = specs.ImportData(ass.text); InitializeCar(); // Set game camera target CourseController ctrl = FindObjectOfType <CourseController>(); ctrl.Camera.GetComponent <CarCamera>().car = this.gameObject.transform; // load the default HUD if no car HUD if (!HUDPrefab) { HUDPrefab = ctrl.DefaultHUD; } HUD = Instantiate(HUDPrefab, ctrl.HUDCanvas.transform).GetComponent <HUD>(); //if no turbo then make sure boost is 1 if (!aspirated) { turboSpool = 1; } engineRPM = 800; GetComponent <Rigidbody>().centerOfMass = CenterOfGravity; gear = 1; wheelFR.ConfigureVehicleSubsteps(5, 12, 15); wheelFL.ConfigureVehicleSubsteps(5, 12, 15); wheelRL.ConfigureVehicleSubsteps(5, 12, 15); wheelRR.ConfigureVehicleSubsteps(5, 12, 15); DataController dataController = FindObjectOfType <DataController>(); dirtiness = dataController.GetDirtiness(); isBusrider = dataController.IsBusrider; tirewearlist = new float[4]; //call the FFB start routine FFBStart(); } if (isBusrider) { CourseController ctrl = FindObjectOfType <CourseController>(); HUDPrefab = ctrl.BusriderHUD; HUD = Instantiate(HUDPrefab, ctrl.HUDCanvas.transform).GetComponent <HUD>(); ctrl.Camera.GetComponent <CarCameraBusrider>().car = this.gameObject.transform; ctrl.Camera.GetComponent <CarCamera>().enabled = false; AIBehaviour AI = gameObject.AddComponent <AIBehaviour>(); AI.car = this; AI.courseController = ctrl; CustomInput.IsAI = true; } }
public void AssignStudents_ReturnsViewResult_WithCoursesAndStudentsAreAssigned() { // Arrange const int courseId = 1; const int assignedStudentId = 11; const int nonAssignedStudentId = 22; const string courseName = "test"; CourseStudentAssignmentViewModel expectedModel = new CourseStudentAssignmentViewModel() { Id = courseId, Name = courseName, Students = new List <AssignmentStudentViewModel>() { new AssignmentStudentViewModel() { StudentId = assignedStudentId, StudentFullName = "Test1", IsAssigned = true }, new AssignmentStudentViewModel() { StudentId = nonAssignedStudentId, StudentFullName = "Test2", IsAssigned = false } } }; var courseServiceMock = Substitute.For <CourseService>(); courseServiceMock.GetCourseById(courseId).Returns(new Course() { Id = courseId, Name = courseName, Students = new List <Student>() { new Student() { Id = assignedStudentId } } }); var studentService = Substitute.For <StudentService>(); var students = new List <Student>() { new Student() { Id = assignedStudentId, Name = "Test1" }, new Student() { Id = nonAssignedStudentId, Name = "Test2" } }; studentService.GetAllStudents().Returns(students); var controller = new CourseController(courseServiceMock, studentService); // Act var result = controller.AssignStudents(courseId); // Assert var viewResult = Assert.IsType <ViewResult>(result); var actualModel = Assert.IsAssignableFrom <CourseStudentAssignmentViewModel>(viewResult.ViewData.Model); actualModel.Should().BeEquivalentTo(expectedModel); }
public void Initialize() { this.controller = new CourseController(new CourseRepositoryMock(), new XmlLinqProcessorMock()); }
public void Setup() { mockCourseRepository = new Mock <IRepositoryHelper>(); courseController = new CourseController(mockCourseRepository.Object); }
public CourseManagementView(CourseController courseController) { this.courseController = courseController; }
public void TearDown() { mockCourseRepository = null; courseController = null; }
public static CourseController Fixture() { CourseController controller = new CourseController(new CourseRepository(), "", new LoginView()); return controller; }
public void IndexTest() { DbContextHelper.Init(typeof(CourseDbContext), GlobalSettings.DATABASE.ConnectionString, 8); CourseController c = new CourseController(); }