Esempio n. 1
0
        public void FlattenTest_ネストオブジェクトnull()
        {
            var input = new ConfigJsonStructure();

            input.Niconico         = null;
            input.Background       = null;
            input.PersistentObject = null;
            input.Item             = null;
            input.Studio           = null;
            input.Humanoid         = null;
            input.EmbeddedScript   = null;
            var result = input.Flatten();

            Assert.IsFalse(result.CharacterModels.Any());
            Assert.IsFalse(result.BackgroundModels.Any());
            Assert.IsFalse(result.MylistIds.Any());
            Assert.IsFalse(result.BroadcasterComments.Any());
            Assert.IsNull(result.NgScoreThreshold);
            Assert.IsFalse(result.BackgroundUrls.Any());
            Assert.IsFalse(result.ImageUrls.Any());
            Assert.IsFalse(result.DoubleSidedImageUrls.Any());
            Assert.IsFalse(result.HiddenImageUrls.Any());
            Assert.IsFalse(result.HiddenDoubleSidedImageUrls.Any());
            Assert.IsFalse(result.NicovideoIds.Any());
            Assert.IsFalse(result.WhiteboardUrls.Any());
            Assert.IsFalse(result.CueCardUrls.Any());
            Assert.IsFalse(result.HideCameraFromViewers);
            Assert.IsFalse(result.NicovideoChromaky);
            Assert.IsFalse(result.DisplaycaptureChromaky);
            Assert.IsFalse(result.PngCaptureFormat);
            Assert.AreEqual(CaptureResolution.FHD, result.CaptureResolution);
            Assert.IsFalse(result.AllowDirectView);
            Assert.IsFalse(result.UseFastSpringBone);
            Assert.IsFalse(result.DirectViewMode);
            Assert.IsFalse(result.DirectViewTalk);
            Assert.IsFalse(result.LookingGlass);
            Assert.IsFalse(result.VivesranipalEye);
            Assert.IsFalse(result.VivesranipalBlink);
            Assert.IsNull(result.VivesranipalX);
            Assert.IsNull(result.VivesranipalY);
            Assert.IsFalse(result.VivesranipalEyeWithEmothion);
            Assert.IsFalse(result.VivesranipalLip);
            Assert.IsNull(result.ScriptWebSocketConsolePort);
            Assert.IsFalse(result.ScriptVrDebug);
            Assert.IsNull(result.ScriptMoonsharpDebuggerPort);
        }
Esempio n. 2
0
 public bool SaveConfig(bool verbose)
 {
     if (verbose)
     {
         _log.Info("Saving config.json...");
     }
     try
     {
         if (TotalShards < 1)
         {
             _log.Warn($"TotalShards was at an invalid value! ({TotalShards}) Resetting to 1...");
             TotalShards = 1;
         }
         ConfigJsonStructure cfg = new ConfigJsonStructure
         {
             Token                 = BotToken,
             CommandPrefix         = DefaultPrefix,
             DefaultPlayingString  = DefaultPlayingString,
             OwnerID               = BotOwnerID,
             BotName               = BotName,
             VerboseErrors         = VerboseErrors,
             EightBallResponses    = EightBallResponses,
             EnableCustomReactions = EnableCustomReactions,
             CustomReactions       = CustomReactions,
             RotatePlaying         = RotatePlayingStatuses,
             PlayingStatuses       = PlayingStatuses,
             TotalShards           = TotalShards,
             GoogleAPIKey          = GoogleAPIKey,
             CleverbotChannels     = CleverbotChannels
         };
         string json = JsonConvert.SerializeObject(cfg, Formatting.Indented);
         File.WriteAllText("config.json", json);
         if (verbose)
         {
             _log.Info("Save complete!");
         }
         return(true);
     }
     catch (Exception e)
     {
         _log.Error("Couldn't save config.json!");
         _log.Error(e);
         return(false);
     }
 }
Esempio n. 3
0
        public void FlattenTest_ScriptVrDebug()
        {
            var input = new ConfigJsonStructure();

            input.EmbeddedScript.VrDebug = true;
            var result = input.Flatten();

            Assert.IsFalse(result.HideCameraFromViewers);
            Assert.IsFalse(result.NicovideoChromaky);
            Assert.IsFalse(result.DisplaycaptureChromaky);
            Assert.IsFalse(result.PngCaptureFormat);
            Assert.IsFalse(result.AllowDirectView);
            Assert.IsFalse(result.UseFastSpringBone);
            Assert.IsFalse(result.DirectViewMode);
            Assert.IsFalse(result.DirectViewTalk);
            Assert.IsFalse(result.LookingGlass);
            Assert.IsFalse(result.VivesranipalEye);
            Assert.IsFalse(result.VivesranipalBlink);
            Assert.IsFalse(result.VivesranipalEyeWithEmothion);
            Assert.IsFalse(result.VivesranipalLip);
            Assert.IsTrue(result.ScriptVrDebug);
        }
Esempio n. 4
0
        public void FlattenTest_正常()
        {
            var input = new ConfigJsonStructure();

            input.Niconico.CharacterModels                   = new[] { 111, 222, 333 };
            input.Niconico.BackgroundModels                  = new[] { 123, 456 };
            input.Niconico.MylistIds                         = new[] { 1, 2, 3, 4 };
            input.Niconico.BroadcasterComments               = new[] { "放送者コメント", "Hogehoge" };
            input.Niconico.NgScoreThreshold                  = -100;
            input.Background.Panorama.SourceUrls             = new[] { "http://background.foo", "http://background.bar" };
            input.PersistentObject.ImageUrls                 = new[] { "http://image.foo", "http://image.bar" };
            input.PersistentObject.DoubleSidedImageUrls      = new[] { new[] { "http://dsfront.bar", "http://dsback.bar" } };
            input.PersistentObject.HiddenImageUrls           = new[] { "http://hiddenimage.bar" };
            input.PersistentObject.HiddenDoubleSideImageUrls = new[] { new[] { "http://hdsfront.bar", "http://hdsback.bar" } };
            input.PersistentObject.NicovideoIds              = new[] { "NicoVideo1", "NicoVideo2" };
            input.Item.Whiteboard.SourceUrls                 = new[] { "http://whiteboard.bar" };
            input.Item.CueCard.SourceUrls                    = new[] { "http://cuecard.bar" };
            input.Item.HideCameraFromViewrs                  = true;
            input.Item.EnableNicovideoChromakey              = true;
            input.Item.EnableDisplaycaptureChromarkey        = true;
            input.Item.CaptureFormat                         = "png";
            input.Item.CaptureResolution                     = "4KUHD";
            input.Studio.AllowDirectView                     = true;
            input.Humanoid.UseFastSpringBone                 = true;
            input.Mode                                 = "direct-view";
            input.DirectViewTalk                       = true;
            input.EnableLookingGlass                   = true;
            input.EnableVivesranipalEye                = true;
            input.EnableVivesranipalBlink              = true;
            input.VivesranipalEyeAdjustX               = (decimal)2.0;
            input.VivesranipalEyeAdjustY               = (decimal)1.0;
            input.EnableVivesranipalEyeWithEmothion    = true;
            input.EnableVivesranipalLip                = true;
            input.EmbeddedScript.WebsocketConsolePort  = 1111;
            input.EmbeddedScript.VrDebug               = true;
            input.EmbeddedScript.MoonsharpDebuggerPort = 2222;

            var result = input.Flatten();

            Assert.IsFalse(result.IsChanged);
            CollectionAssert.AreEqual(new[] { 111, 222, 333 }, result.CharacterModels);
            CollectionAssert.AreEqual(new[] { 123, 456 }, result.BackgroundModels);
            CollectionAssert.AreEqual(new[] { 1, 2, 3, 4 }, result.MylistIds);
            CollectionAssert.AreEqual(new[] { "放送者コメント", "Hogehoge" }, result.BroadcasterComments);
            Assert.AreEqual(-100, result.NgScoreThreshold);
            CollectionAssert.AreEqual(new[] { new Uri("http://background.foo"), new Uri("http://background.bar") }, result.BackgroundUrls);
            CollectionAssert.AreEqual(new[] { new Uri("http://image.foo"), new Uri("http://image.bar") }, result.ImageUrls);
            CollectionAssert.AreEqual(new[] { new Uri("http://dsfront.bar") }, result.DoubleSidedImageUrls.Select(e => e.FrontSide).ToArray());
            CollectionAssert.AreEqual(new[] { new Uri("http://dsback.bar") }, result.DoubleSidedImageUrls.Select(e => e.BackSide).ToArray());
            CollectionAssert.AreEqual(new[] { new Uri("http://hiddenimage.bar") }, result.HiddenImageUrls);
            CollectionAssert.AreEqual(new[] { new Uri("http://hdsfront.bar") }, result.HiddenDoubleSidedImageUrls.Select(e => e.FrontSide).ToArray());
            CollectionAssert.AreEqual(new[] { new Uri("http://hdsback.bar") }, result.HiddenDoubleSidedImageUrls.Select(e => e.BackSide).ToArray());
            CollectionAssert.AreEqual(new[] { "NicoVideo1", "NicoVideo2" }, result.NicovideoIds);
            CollectionAssert.AreEqual(new[] { new Uri("http://whiteboard.bar") }, result.WhiteboardUrls);
            CollectionAssert.AreEqual(new[] { new Uri("http://cuecard.bar") }, result.CueCardUrls);
            Assert.IsTrue(result.HideCameraFromViewers);
            Assert.IsTrue(result.NicovideoChromaky);
            Assert.IsTrue(result.DisplaycaptureChromaky);
            Assert.IsTrue(result.PngCaptureFormat);
            Assert.AreEqual(CaptureResolution.UHD4K, result.CaptureResolution);
            Assert.IsTrue(result.AllowDirectView);
            Assert.IsTrue(result.UseFastSpringBone);
            Assert.IsTrue(result.DirectViewMode);
            Assert.IsTrue(result.DirectViewTalk);
            Assert.IsTrue(result.LookingGlass);
            Assert.IsTrue(result.VivesranipalEye);
            Assert.IsTrue(result.VivesranipalBlink);
            Assert.AreEqual((decimal)2.0, result.VivesranipalX);
            Assert.AreEqual((decimal)1.0, result.VivesranipalY);
            Assert.IsTrue(result.VivesranipalEyeWithEmothion);
            Assert.IsTrue(result.VivesranipalLip);
            Assert.AreEqual(1111, result.ScriptWebSocketConsolePort);
            Assert.IsTrue(result.ScriptVrDebug);
            Assert.AreEqual(2222, result.ScriptMoonsharpDebuggerPort);
        }