/// <summary> /// Initializes a new instance of the <see cref="RoleplayService"/> class. /// </summary> /// <param name="entityService">The application's owned entity service.</param> /// <param name="database">The database.</param> public RoleplayService ( OwnedEntityService entityService, RoleplayingDatabaseContext database ) { _ownedEntities = entityService; _database = database; }
public void ReturnsTrueForEmptySet() { var entityMock = new Mock <IOwnedNamedEntity>(); entityMock.Setup(e => e.Name).Returns("Test"); var result = OwnedEntityService.IsEntityNameUniqueForUser(new List <IOwnedNamedEntity>(), "Test2"); Assert.True(result); }
/// <summary> /// Initializes a new instance of the <see cref="CharacterService"/> class. /// </summary> /// <param name="entityService">The application's owned entity service.</param> /// <param name="content">The content service.</param> /// <param name="database">The core database.</param> /// <param name="pronouns">The pronoun service.</param> public CharacterService ( OwnedEntityService entityService, ContentService content, CharactersDatabaseContext database, PronounService pronouns ) { _ownedEntities = entityService; _content = content; _database = database; _pronouns = pronouns; }
public void ReturnsFalseForNonUniqueNameAndIsCaseInsensitive() { var entityMock = new Mock <IOwnedNamedEntity>(); entityMock.Setup(e => e.Name).Returns("Test"); var collection = new List <IOwnedNamedEntity> { entityMock.Object }; var result = OwnedEntityService.IsEntityNameUniqueForUser(collection, "TEST"); Assert.False(result); }
public void ReturnsTrueForUniqueName() { var entityMock = new Mock <IOwnedNamedEntity>(); entityMock.Setup(e => e.Name).Returns("Test"); var collection = new List <IOwnedNamedEntity> { entityMock.Object }; var result = OwnedEntityService.IsEntityNameUniqueForUser(collection, "Test2"); Assert.True(result); }
/// <summary> /// Initializes a new instance of the <see cref="RoleplayService"/> class. /// </summary> /// <param name="commands">The application's command service.</param> /// <param name="entityService">The application's owned entity service.</param> /// <param name="users">The user service.</param> /// <param name="servers">The server service.</param> /// <param name="database">The database.</param> public RoleplayService ( [NotNull] CommandService commands, [NotNull] OwnedEntityService entityService, [NotNull] UserService users, [NotNull] ServerService servers, [NotNull] RoleplayingDatabaseContext database ) { _commands = commands; _ownedEntities = entityService; _users = users; _servers = servers; _database = database; }
/// <summary> /// Initializes a new instance of the <see cref="RoleplayDiscordService"/> class. /// </summary> /// <param name="client">The Discord client.</param> /// <param name="roleplays">The roleplay service.</param> /// <param name="dedicatedChannels">The dedicated channel service.</param> /// <param name="users">The user service.</param> /// <param name="servers">The server service.</param> /// <param name="commands">The command service.</param> /// <param name="ownedEntities">The owned entity service.</param> public RoleplayDiscordService ( IDiscordClient client, RoleplayService roleplays, DedicatedChannelService dedicatedChannels, UserService users, ServerService servers, CommandService commands, OwnedEntityService ownedEntities ) { _client = client; _roleplays = roleplays; _dedicatedChannels = dedicatedChannels; _users = users; _servers = servers; _commands = commands; _ownedEntities = ownedEntities; }
/// <summary> /// Initializes a new instance of the <see cref="CharacterDiscordService"/> class. /// </summary> /// <param name="characters">The character service.</param> /// <param name="users">The user service.</param> /// <param name="servers">The server service.</param> /// <param name="commands">The command service.</param> /// <param name="ownedEntities">The owned entity service.</param> /// <param name="discord">The Discord service.</param> /// <param name="characterRoles">The character role service.</param> public CharacterDiscordService ( CharacterService characters, UserService users, ServerService servers, CommandService commands, OwnedEntityService ownedEntities, DiscordService discord, CharacterRoleService characterRoles ) { _characters = characters; _users = users; _servers = servers; _commands = commands; _ownedEntities = ownedEntities; _discord = discord; _characterRoles = characterRoles; }
/// <summary> /// Initializes a new instance of the <see cref="CharacterService"/> class. /// </summary> /// <param name="commands">The application's command service.</param> /// <param name="entityService">The application's owned entity service.</param> /// <param name="content">The content service.</param> /// <param name="users">The user service.</param> /// <param name="servers">The server service.</param> /// <param name="database">The core database.</param> /// <param name="pronouns">The pronoun service.</param> public CharacterService ( [NotNull] CommandService commands, [NotNull] OwnedEntityService entityService, [NotNull] ContentService content, [NotNull] UserService users, [NotNull] ServerService servers, [NotNull] CharactersDatabaseContext database, [NotNull] PronounService pronouns ) { _commands = commands; _ownedEntities = entityService; _content = content; _users = users; _servers = servers; _database = database; _pronouns = pronouns; }
public async Task <bool> IsRoleplayNameUniqueForUserAsync ( Snowflake userID, string roleplayName, Snowflake serverID, CancellationToken ct = default ) { roleplayName = roleplayName.Trim(); var userRoleplays = await QueryDatabaseAsync ( q => q .Where(rp => rp.Owner.DiscordID == userID) .Where(rp => rp.Server.DiscordID == serverID), ct ); return(OwnedEntityService.IsEntityNameUniqueForUser(userRoleplays.ToList(), roleplayName)); }
/// <inheritdoc /> public async Task <bool> IsNameUniqueForUserAsync ( User user, Server server, string characterName, CancellationToken ct = default ) { characterName = characterName.Trim(); user = _database.NormalizeReference(user); server = _database.NormalizeReference(server); var userCharacters = await _database.Characters.ServersideQueryAsync ( c => c .Where(ch => ch.Owner == user) .Where(ch => ch.Server == server), ct ); return(OwnedEntityService.IsEntityNameUniqueForUser(userCharacters, characterName)); }
/// <summary> /// Initializes a new instance of the <see cref="OwnedEntityServiceTestBase"/> class. /// </summary> protected OwnedEntityServiceTestBase() { this.Entities = new OwnedEntityService(); }
// ReSharper restore PrivateFieldCanBeConvertedToLocalVariable /// <summary> /// Initializes a new instance of the <see cref="AmbassadorClient"/> class. /// </summary> /// <param name="content">The content service.</param> public AmbassadorClient([NotNull] ContentService content) { this.Client = Type.GetType("Mono.Runtime") is null ? new DiscordSocketClient() : new DiscordSocketClient(new DiscordSocketConfig { WebSocketProvider = () => new WebSocketSharpProvider() }); this.Client.Log += OnDiscordLogEvent; this.Commands = new CommandService(); this.Commands.Log += OnDiscordLogEvent; this.DiscordIntegration = new DiscordService(); this.Content = content; this.Commands = new CommandService(); this.OwnedEntities = new OwnedEntityService(); this.Roleplays = new RoleplayService(this.Commands, this.OwnedEntities); this.Transformation = new TransformationService(this.Content); this.Characters = new CharacterService(this.Commands, this.OwnedEntities, this.Content, this.Transformation); this.Characters.DiscoverPronounProviders(); this.Feedback = new UserFeedbackService(); this.Dossiers = new DossierService(this.Content); this.Interactive = new InteractiveService(this.Client); this.Lua = new LuaService(this.Content); this.Kinks = new KinkService(this.Feedback); this.Permissions = new PermissionService(); this.Privacy = new PrivacyService(); this.Services = new ServiceCollection() .AddSingleton(this.Client) .AddSingleton(this.DiscordIntegration) .AddSingleton(this.Content) .AddSingleton(this.Commands) .AddSingleton(this.Roleplays) .AddSingleton(this.Characters) .AddSingleton(this.Feedback) .AddSingleton(this.Dossiers) .AddSingleton(this.Interactive) .AddSingleton(this.Transformation) .AddSingleton(this.Lua) .AddSingleton(this.Kinks) .AddSingleton(this.Permissions) .AddSingleton(this.Privacy) .AddDbContextPool <GlobalInfoContext>(builder => GlobalInfoContext.ConfigureOptions(builder)) .BuildServiceProvider(); this.Transformation = this.Transformation .WithDescriptionBuilder ( ActivatorUtilities.CreateInstance <TransformationDescriptionBuilder>(this.Services) ); this.Client.MessageReceived += OnMessageReceived; this.Client.MessageUpdated += OnMessageUpdated; }