public void CheckMashupFileContentInStorage(string fileName, string mashupName, string script) { var mashup = ScriptStorage.GetMashup(mashupName); mashup.Name.Should(Be.EqualTo(mashupName)); mashup.Files.First(x => x.FileName.EqualsIgnoreCase(fileName)).Content.Should(Be.EqualTo(script)); }
public void CheckMashupInStorage(string mashupName, string placeholders, string script) { var mashup = ScriptStorage.GetMashup(mashupName); mashup.Name.Should(Be.EqualTo(mashupName)); mashup.Placeholders.ToLower().Should(Be.EqualTo(placeholders.ToLower())); mashup.Files.First().Content.Should(Be.EqualTo(script)); MashupManagerProfile.MashupNames.Should(Contains.Item(mashupName)); }
public void CheckMashupFilesInStorage(string mashupName, string placeholders, string[] fileNames) { var mashup = ScriptStorage.GetMashup(mashupName); mashup.Name.Should(Be.EqualTo(mashupName)); mashup.Placeholders.ToLower().Should(Be.EqualTo(placeholders.ToLower())); mashup.Files.Select(x => x.FileName).ToArray().Should(Be.EquivalentTo(fileNames)); MashupManagerProfile.MashupNames.Should(Contains.Item(mashupName)); }
/// <inheritdoc /> public async ValueTask <IDictionary <string, JToken> > GetStorageAsync(long guildId) { var cacheKey = ScriptStorage.GetCacheKey(guildId); return((await cache.HashGetAllAsync <string>(cacheKey)) .ToDictionary( kv => kv.Key, kv => Result <JToken> .From(() => JToken.Parse(kv.Value)) .OrElse(JValue.CreateNull()) .Unwrap())); }
/// <summary> /// Create the storage for the server. /// </summary> private static async ValueTask <ScriptStorage> CreateStorageAsync(IContext e, bool?isDonator = null) { var cache = e.GetService <IExtendedCacheClient>(); var guild = e.GetGuild(); var guildId = (long)guild.Id; if (!isDonator.HasValue) { var userService = e.GetService <IUserService>(); isDonator = await userService.UserIsDonatorAsync((long)guild.OwnerId); } var keyLimit = isDonator.Value ? DonatorKeyLimit : KeyLimit; var storage = new ScriptStorage(cache, guildId, keyLimit, ValueLimit); return(storage); }
public void SetMashupNamesToProfile(string mashupName) { MashupManagerProfile.MashupNames.Add(mashupName); var mashupFiles = new List <MashupFile> { new MashupFile { FileName = mashupName + ".js", Content = DefaultScript }, new MashupFile { FileName = mashupName + ".config.js", Content = DefaultConfigScript } }; ScriptStorage.SaveMashup(new Mashup(mashupFiles) { Name = mashupName, Placeholders = DefaultPlaceholders }); }
public void SetMashupNamesToProfile(string[] mashups) { MashupManagerProfile.MashupNames.AddRange(mashups); foreach (var mashup in mashups) { var mashupFiles = new List <MashupFile> { new MashupFile { FileName = mashup + ".js", Content = DefaultScript } }; ScriptStorage.SaveMashup(new Mashup(mashupFiles) { Name = mashup, Placeholders = DefaultPlaceholders }); } }
protected Mashup GetMashupFromStorage(string mashupName) { return(ScriptStorage.GetMashup(mashupName)); }