public FormMarks() { InitializeComponent(); this.marksService = new MarkService(); this.Text = "Zarządzanie ocenami"; this.LoadDataToDataGrid(); }
public void AddMarkToDatabase() { // Arrange var marks = new List <Mark>(); var queryable = marks.AsQueryable(); var mockDbSet = new Mock <IDbSet <Mark> >(); mockDbSet.As <IQueryable <Mark> >().Setup(m => m.Provider).Returns(queryable.Provider); mockDbSet.As <IQueryable <Mark> >().Setup(m => m.Expression).Returns(queryable.Expression); mockDbSet.As <IQueryable <Mark> >().Setup(m => m.ElementType).Returns(queryable.ElementType); mockDbSet.As <IQueryable <Mark> >().Setup(m => m.GetEnumerator()).Returns(() => queryable.GetEnumerator()); mockDbSet.Setup(d => d.Add(It.IsAny <Mark>())).Callback <Mark>((m) => marks.Add(m)); var mockDbContext = new Mock <IDatabaseContext>(); mockDbContext.Setup(c => c.Marks).Returns(mockDbSet.Object); var markService = new MarkService(mockDbContext.Object); var mark = new Mark(); // Act markService.Add(mark); // Assert Assert.IsTrue(marks.Count() == 1); Assert.IsTrue(marks.Contains(mark)); }
public async Task Remove_WhenMarkRemoved_OneMarkLessInRepository() { // Arrange var firstMark = new Mark { ID = 123, SubjectID = 321, StudentID = 321 }; var secondMark = new Mark { ID = 321, SubjectID = 322, StudentID = 322 }; var fakeStudentRepository = new FakeRepository <Mark>(); await fakeStudentRepository.Add(firstMark); await fakeStudentRepository.Add(secondMark); var markService = new MarkService(fakeStudentRepository); // Act await markService.Remove(firstMark.ID); var allMarks = await markService.GetAll(); var mark = allMarks.FirstOrDefault(); // Assert Assert.Equal(1, allMarks.Count); Assert.Same(mark, secondMark); }
public async Task Create_WhenThreeMarksWereCreated_ThreeNewMarksAreInRepository() { // Arrange var fakeMarkRepository = new FakeRepository <Mark>(); var markService = new MarkService(fakeMarkRepository); List <Mark> marks = new List <Mark> { new Mark { SubjectID = 1, StudentID = 4 }, new Mark { SubjectID = 2, StudentID = 5 }, new Mark { SubjectID = 3, StudentID = 6 } }; // Act foreach (var mark in marks) { await markService.Create(mark.StudentID, mark.SubjectID); } var allMarks = await markService.GetAll(); // Assert Assert.Equal(3, allMarks.Count); }
public async Task RemoveGroup_WhenMarkRemoved_OneMarkLessInRepository() { // Arrange var firstMark = new Mark { ID = 123, SubjectID = 321, StudentID = 321 }; var secondMark = new Mark { ID = 321, SubjectID = 322, StudentID = 322 }; var fakeStudentRepository = new FakeRepository <Mark>(); await fakeStudentRepository.Add(firstMark); await fakeStudentRepository.Add(secondMark); var markService = new MarkService(fakeStudentRepository); // Act await markService.RemoveGroup(new List <Mark> { firstMark, secondMark }); var allMarks = await markService.GetAll(); // Assert Assert.Equal(0, allMarks.Count); }
public async Task GetAll_ReturnsAllMarksFromRepository() { // Arrange var firstMark = new Mark { ID = 123, SubjectID = 321, StudentID = 321 }; var secondMark = new Mark { ID = 321, SubjectID = 322, StudentID = 322 }; var fakeStudentRepository = new FakeRepository <Mark>(); await fakeStudentRepository.Add(firstMark); await fakeStudentRepository.Add(secondMark); var markService = new MarkService(fakeStudentRepository); // Act var allMarks = await markService.GetAll(); var mark = allMarks.FirstOrDefault(m => m.ID == 123); // Assert Assert.Equal(2, allMarks.Count); Assert.Same(firstMark, mark); }
public static void Main(string[] args) { IPerson person = new Person(); IMarkService mark = new MarkService(); IStudent student = new Student(); Console.WriteLine(student.CheckMark(person)); }
public MarkTui(MarkService service) { _service = service; Initialize("Mark TUI", new Dictionary <string, Action> { { "Create mark", CreateMark }, { "Read one mark", ReadOneMark }, { "Read all marks", ReadAllMarks } }); }
public FormAddMark() { InitializeComponent(); this.markService = new MarkService(); this.studentService = new StudentService(); this.lessonService = new LessonService(); this.professorsService = new ProfessorService(); this.LoadToComboBox(); }
public FormEditMark(Mark markd) { InitializeComponent(); this.markService = new MarkService(); this.studentService = new StudentService(); this.lessonService = new LessonService(); this.professorsService = new ProfessorService(); this.numericUpDown1.Value = markd.MarkNumber; this.LoadToComboBox(markd); this.markId = markd.MarkId; }
public DiaryEditModel(DataContext dc) { _userService = new UserService(dc); _markService = new MarkService(dc); var id = _userService.LoggedIn().Id; Settings = _markService.GetUserSettings(id); Row = new FilmRow(Settings.AdditionalFieldNames); Found = false; Suggestion = new[] { "", "", "" }; }
private async Task TestCreateMarkEnglish_WithTestData_ShouldNotReturnZeroCount() { var context = PMGDbContextInMemoryFactory.CreateDbContext(); var markService = new MarkService(context); var mark = 5.50m; await markService.CreateMarkEnglishAsync(mark, User); var actualResult = User.Bookmark.EnglishMarks.SingleOrDefault(x => x.Mark == mark).Mark; Assert.Equal(mark, actualResult); }
public void CallDbContext_SaveMethod() { // Arrange var mockedDbContext = new Mock <IDatabaseContext>(); mockedDbContext.Setup(c => c.Save()).Returns(1).Verifiable(); var markService = new MarkService(mockedDbContext.Object); // Act var result = markService.Save(); // Assert Assert.IsTrue(result == 1); mockedDbContext.Verify(c => c.Save(), Times.Once); }
public void AllMarks_ConnectionStringValid_DataReturned() { //Arrange var context = new ApplicationDbContext(ConnectionString); var repository = new MarkRepository(context); var service = new MarkService(repository); var controller = new MarkController(service, null, null); //Act var result = controller.AllMarks(); result.Wait(); //Assert result.Should().NotBeNull(); result.Result.Should().ContainSingle(x => x.IDMark == 1 && x.Name == "Daewoo" && x.Value == 3); }
public async Task Create_WhenMarkWasCreated_NewMarkIsInRepository() { // Arrange var fakeMarkRepository = new FakeRepository <Mark>(); var markService = new MarkService(fakeMarkRepository); var expectedMark = new Mark { SubjectID = 123, StudentID = 1234 }; // Act await markService.Create(expectedMark.StudentID, expectedMark.SubjectID); var allMarks = await markService.GetAll(); var mark = allMarks.FirstOrDefault(); // Assert Assert.Equal(1, allMarks.Count); Assert.Equal(mark.SubjectID, expectedMark.SubjectID); Assert.Equal(mark.StudentID, expectedMark.StudentID); }
public MainTui( TaskService taskService, StudentService studentService, MarkService markService, ReportsService reportsService, FiltersService filtersService) { var taskTui = new TaskTui(taskService); var studentTui = new StudentTui(studentService); var markTui = new MarkTui(markService); var reportsTui = new ReportsTui(reportsService); var filtersTui = new FiltersTui(filtersService); Initialize("Main TUI", new Dictionary <string, Action> { { "Tasks", taskTui.Run }, { "Students", studentTui.Run }, { "Marks", markTui.Run }, { "Reports", reportsTui.Run }, { "Filters", filtersTui.Run } }); }
public EventsController(MarkService markService) { this.markService = markService; }
public DiarySettingsModel(DataContext dc) { _userService = new UserService(dc); _markService = new MarkService(dc); }
public SubjectController(MarkService markService, SubjectService subjectService, StudentService studentService) { _markService = markService; _subjectService = subjectService; _studentService = studentService; }
public StudentController(StudentService studentService, MarkService markService) { _studentService = studentService; _markService = markService; }
public MarkController(MarkService markService) => this.markService = markService;
public TeacherProfileController() { _teacherService = new TeacherService(); _schoolClassService = new SchoolClassService(); _markService = new MarkService(); }
public MarksController(MarkService markService) { this.markService = markService; }
static void Main(string[] args) { if (args is null) { throw new ArgumentNullException(nameof(args)); } using var context = new MovieDiaryDbContextFactory().CreateDbContext(); var userService = new UserService(context); object res; if (userService.LoginUser("admin", "admin") == null) { userService.SignupUser("admin", "admin", true); } userService.DeleteUser("2"); userService.DeleteUser("3"); userService.DeleteUser("4"); userService.SignupUser("User1", "Pass1"); userService.SignupUser("User2", "Pass2"); userService.SignupUser("User3", "Pass3"); res = userService.LoginUser("User1", "Pass1"); res = userService.LoginUser("User2", "Pass2"); res = userService.LoginUser("User2", "Pass3"); res = userService.LoginUser("User1", "Pass4"); res = userService.GetUserNames(); userService.DeleteUser("2"); userService.DeleteUser("3"); userService.DeleteUser("4"); var markService = new MarkService(context); var userId1 = userService.SignupUser("User1", "Pass1"); var settings = markService.GetUserSettings(userId1); settings.ShowCountry = false; settings.AdditionalFieldNames.AddRange(new[] { "Field1", "Field2" }); markService.EditUserSettings(userId1, settings); res = markService.FindLikelyMovies("Pulp Fict"); res = markService.GetMovieInfo(settings, (res as List <MovieApiRecord>)[0].Id); (res as FilmRow).AdditionalFields["Field1"] = "Value1"; (res as FilmRow).AdditionalFields["Field2"] = "Value2"; markService.AddUserMark(userId1, res as FilmRow); res = markService.FindLikelyMovies("Interstellar"); res = markService.GetMovieInfo(settings, (res as List <MovieApiRecord>)[0].Id); (res as FilmRow).AdditionalFields["Field1"] = "Value3"; (res as FilmRow).AdditionalFields["Field2"] = "Value4"; (res as FilmRow).Mark = 4; markService.AddUserMark(userId1, res as FilmRow); var row1 = markService.GetUserMarks(userId1)[0]; var row2 = markService.GetUserMarks(userId1)[1]; row1.Mark = 5; row1.AdditionalFields["Field1"] = "Aboba"; markService.EditUserMark(row1); row2.AdditionalFields["Field1"] = "Aboba2"; markService.EditUserMark(row2); var userId2 = userService.SignupUser("User2", "Pass2"); settings = markService.GetUserSettings(userId2); settings.ShowDirector = false; settings.AdditionalFieldNames.AddRange(new[] { "Field3", "Field4", "Field5" }); markService.EditUserSettings(userId2, settings); res = markService.FindLikelyMovies("Interstellar"); res = markService.GetMovieInfo(settings, (res as List <MovieApiRecord>)[0].Id); (res as FilmRow).AdditionalFields["Field3"] = "Value1"; (res as FilmRow).AdditionalFields["Field4"] = "Value2"; (res as FilmRow).AdditionalFields["Field5"] = "Value3"; markService.AddUserMark(userId2, res as FilmRow); res = markService.FindLikelyMovies("Borat"); res = markService.GetMovieInfo(settings, (res as List <MovieApiRecord>)[0].Id); (res as FilmRow).AdditionalFields["Field3"] = "Value3"; (res as FilmRow).AdditionalFields["Field4"] = "Value4"; (res as FilmRow).AdditionalFields["Field5"] = "Value5"; (res as FilmRow).Mark = 4; markService.AddUserMark(userId2, res as FilmRow); var row3 = markService.GetUserMarks(userId2)[0]; var row4 = markService.GetUserMarks(userId2)[1]; row3.Mark = 5; row3.AdditionalFields["Field5"] = "Aboba"; markService.EditUserMark(row3); row4.AdditionalFields["Field5"] = "Aboba2"; markService.EditUserMark(row4); //markService.DeleteUserMark(row1.MarkId); //markService.DeleteUserMark(row2.MarkId); //markService.DeleteUserMark(row3.MarkId); //markService.DeleteUserMark(row4.MarkId); }
public DiaryTableModel(DataContext dc) { _userService = new UserService(dc); _markService = new MarkService(dc); }