public async Task ParticipationService_Add_ShouldExecuteWithSuccess() { // Arrange var participation = participationValid; var participationRepo = new Mock <IParticipationRepository>(); var notificationRepo = new Mock <INotificator>(); var participationService = new ParticipationService(participationRepo.Object, notificationRepo.Object); // Act await participationService.Add(participation); // Assert Assert.True(participation.IsValid()); participationRepo.Verify(r => r.Add(participation), Times.Once); }
public async Task ParticipationService_Add_ShouldExecuteWithFailAsync() { // Arrange var participation = participationInvalid; var participationRepo = new Mock <IParticipationRepository>(); var notificationRepo = new Mock <INotificator>(); var participationService = new ParticipationService(participationRepo.Object, notificationRepo.Object); // Act await participationService.Add(participation); // Assert Assert.False(participation.IsValid()); participationRepo.Verify(r => r.Add(participation), Times.Never); notificationRepo.Verify(r => r.Handle(It.IsAny <Notification>()), Times.AtLeastOnce); }
public ActionResult Paricipate1(int IdEnfant, int IdFormation) { Formation f = MyFormationService.GetById((int)IdFormation); f.Reserved++; Participation p = new Participation() { EnfantId = IdEnfant, FormationID = IdFormation }; MyFormationService.Update(f); MyFormationService.Commit(); MyParticipationService.Add(p); MyParticipationService.Commit(); return(RedirectToAction("Paricipate", new { IdFormation = IdFormation })); }
public async Task Criate() { if (IDUser != 0 && IDCompitention != 0 && Autentification_CheckBox.IsChecked) { bool verifi = false; if (Autentification_CheckBox.IsChecked) { verifi = true; } else { verifi = false; } Participation participation = new Participation { IdCompetentions = IDCompitention, IdUser = IDUser, IdStatusVerification = verifi }; await participationService.Add(participation); if (!await DisplayAlert("", "Добавить еще одну запись", "Да", "Нет")) { await Navigation.PopModalAsync(); } } else { if (!await DisplayAlert("Ошибка", "Вы заполнили не все поля", "Заполнить", "Выйти")) { await Navigation.PopModalAsync(); } } }
public async Task Criate() { InfoUser loginUsers = await loginUsersService.Get(App.Current.Properties["token"].ToString()); IEnumerable <InfoUser> infoUsers = await registrationUsersService.Get_user(); IEnumerable <Participation> participations = await participationService.Get(); IEnumerable <Distantion> distantions = await distantionsServise.Get(); IEnumerable <Competentions> competentions = await competentionsServise.Get(); var info = from p in participations join k in competentions on p.IdCompetentions equals k.IdCompetentions join d in distantions on k.IdDistantion equals d.IdDistantion join i in infoUsers on p.IdUser equals i.IdUsers select new { p.IdUser, i.Login, k.Date, p.IdStatusVerification, d.NameDistantion, }; DateTime selectd_date = Convert.ToDateTime(SelectDate.Items[SelectDate.SelectedIndex]); var picker_list = info.FirstOrDefault(x => x.IdUser == loginUsers.IdUsers && x.NameDistantion == CompetentionsPicer.Items[CompetentionsPicer.SelectedIndex] && x.Date == selectd_date); if (picker_list == null) { if (await Date_TestAsync()) { if (IDUser != 0 && IDCompitention != 0) { Participation participation = new Participation { IdCompetentions = IDCompitention, IdUser = IDUser, IdStatusVerification = true }; await participationService.Add(participation); await DownloadBage(); await Navigation.PopModalAsync(); } else { if (!await DisplayAlert("Ошибка", "Вы заполнили не все поля", "Заполнить", "Выйти")) { await Navigation.PopModalAsync(); } } } } else { if (!await DisplayAlert("Предупреждение", "Вы уже зарегистрированы на эту дисциплину", "Зарегистрироваться на другую", "Выйти")) { await Navigation.PopModalAsync(); } } }