public void Create() { ParticipantService participantService = new ParticipantService(_context); Participant participant = participantService.GetAll().First(); QuestionService questionService = new QuestionService(_context); Question question = questionService.GetAll().First(); ActionService actionService = new ActionService(_context); int nActionBefore = actionService.GetAll().Count(); actionService.Create(participant, participant, "description", DateTimeOffset.UtcNow, "title", Priority.Low, question); int nActionsAfter = actionService.GetAll().Count(); Assert.Equal(nActionBefore + 1, nActionsAfter); }
// GET: Action public async Task <ActionResult> Index() { List <Entities.ActionModel> actions = new List <Entities.ActionModel>(); actions = await _actionService.GetAll(); return(View(actions)); }
public void GetQueryable() { ActionService actionService = new ActionService(_context); IQueryable <Action> actionQueryable = actionService.GetAll(); Assert.True(actionQueryable.Count() > 0); }
protected int NumberOfActions(Question question) { int actions = _actionService .GetAll() .Where(a => a.Question == question) .Count() ; return(actions); }
public void GetActions_GivenNothing_ExpectActions() { var environment = new ExecutionContext(); var actionsProvider = new ActionsProvider(environment); var sut = new ActionService(actionsProvider); var actions = sut.GetAll(); var actionNames = actions.Select(a => a.Name).ToList(); CollectionAssert.Contains(actionNames, "LaunchUrl"); }
public void VoidAction() { ActionService actionService = new ActionService(fixture.context); Action action = actionService.GetAll().First(); Action voidedAction = actionService.SetVoid(action, true); Assert.Equal(action.Id, voidedAction.Id); Assert.True(voidedAction.IsVoided); }
public void GetExists() { NoteService noteService = new NoteService(fixture.context); ParticipantService participantService = new ParticipantService(fixture.context); Participant participant = participantService.GetAll().First(); ActionService actionService = new ActionService(fixture.context); Action action = actionService.GetAll().First(); Note NoteCreate = noteService.Create(participant, "text", action); Note NoteGet = noteService.GetNote(NoteCreate.Id); Assert.Equal(NoteCreate, NoteGet); }
public void GetExists() { ClosingRemarkService closingRemarkService = new ClosingRemarkService(fixture.context); ParticipantService participantService = new ParticipantService(fixture.context); Participant participant = participantService.GetAll().First(); ActionService actionService = new ActionService(fixture.context); Action action = actionService.GetAll().First(); ClosingRemark ClosingRemarkCreate = closingRemarkService.Create(participant, "text", action); ClosingRemark ClosingRemarkGet = closingRemarkService.GetClosingRemark(ClosingRemarkCreate.Id); Assert.Equal(ClosingRemarkCreate, ClosingRemarkGet); }
public void Create() { ParticipantService participantService = new ParticipantService(fixture.context); Participant participant = participantService.GetAll().First(); ActionService actionService = new ActionService(fixture.context); Action action = actionService.GetAll().First(); NoteService noteService = new NoteService(fixture.context); int nNoteBefore = noteService.GetAll().Count(); noteService.Create(participant, "text", action); int nNotesAfter = noteService.GetAll().Count(); Assert.Equal(nNoteBefore + 1, nNotesAfter); }
public void Create() { ParticipantService participantService = new ParticipantService(fixture.context); Participant participant = participantService.GetAll().First(); ActionService actionService = new ActionService(fixture.context); Action action = actionService.GetAll().First(); ClosingRemarkService closingRemarkService = new ClosingRemarkService(fixture.context); int nClosingRemarksBefore = closingRemarkService.GetAll().Count(); closingRemarkService.Create(participant, "text", action); int nClosingRemarksAfter = closingRemarkService.GetAll().Count(); Assert.Equal(nClosingRemarksBefore + 1, nClosingRemarksAfter); }
public void EditNote() { ParticipantService participantService = new ParticipantService(fixture.context); Participant participant = participantService.GetAll().First(); ActionService actionService = new ActionService(fixture.context); Action action = actionService.GetAll().First(); NoteService noteService = new NoteService(fixture.context); string initialText = "initial text"; Note note = noteService.Create(participant, initialText, action); string noteId = note.Id; string newText = "new text"; noteService.EditNote(note, newText); Note resultingNote = noteService.GetNote(noteId); Assert.Equal(newText, resultingNote.Text); }
protected override BotCommandAction GetAction() { return(ActionService.GetAll().OfType <BotCommandAction>().FirstOrDefault(a => a.UserCommandProperties != null && a.UserCommandProperties.Name == Interaction.Data.Name)); }
public IQueryable <Action> GetActions() { return(_actionService.GetAll()); }
protected override void OnModuleBuilding(CommandService commandService, ModuleBuilder builder) { base.OnModuleBuilding(commandService, builder); using var scope = ServiceProvider.CreateScope(); ActionService = ServiceProvider.GetRequiredService <ActionService>(); //Get phrases from items as aliases for the referenced command. foreach (var action in ActionService.GetAll().OfType <BotCommandAction>() .Where(s => s.TextCommandProperties != null)) { foreach (var textProperties in action.TextCommandProperties) { builder.AddCommand(textProperties.Name, RunActionFromTextCommand, builder => { if (textProperties.Aliases != null) { builder.AddAliases(textProperties.Aliases.ToArray()); } builder.Summary = textProperties.Summary; if (action.GuildsOnly) { builder.AddPrecondition(new RequireContextAttribute(ContextType.Guild)); } if (action.RequiredPermissions.HasValue) { var requiredPermissions = action.RequiredPermissions.Value.ToList(); if (!requiredPermissions.Any()) { builder.AddPrecondition(new RequireOwnerAttribute()); } else { GuildPermission permissions = 0; foreach (var permission in requiredPermissions) { permissions |= permission; } builder.AddPrecondition(new RequireUserPermissionAttribute(permissions)); } } if (textProperties.Priority.HasValue) { builder.Priority = textProperties.Priority.Value; } var parameters = action.GetParameters <ActionParameterTextAttribute>() ?.Where(p => p.Attribute.FilterCommandNames == null || p.Attribute.FilterCommandNames.Contains(textProperties.Name)) .OrderBy(p => p.Attribute.Order); if (parameters != null) { foreach (var p in parameters) { builder.AddParameter(p.Attribute.Name, p.Attribute.ParameterType, pb => { pb.Summary = p.Attribute.Description; pb.IsMultiple = p.Attribute.IsMultiple; pb.IsRemainder = p.Attribute.IsRemainder; pb.DefaultValue = p.Attribute.DefaultValue; pb.IsOptional = !p.Attribute.Required; }); } } textProperties.ModifyBuilder?.Invoke(scope.ServiceProvider, builder); } ); } } }