Beispiel #1
0
        public void ChartParse_Successful(
            string d, float constant,
            string song, string img, string bg,
            string name, string namer, string artist, string artistr,
            string bpm, string charter, string illust,
            string chartpath, string style
            )
        {
            (Chart actual, string json) = JsonHelper.GenerateChart(
                JsonUserInput.Past, d, constant, song, img, bg,
                name, namer, artist, artistr,
                bpm, charter, illust, chartpath, style
                );
            JObject jobj  = JObject.Parse(json);
            Chart   chart = JsonUserInput.ReadChartJson(jobj.CreateReader());

            Assert.That(
                actual.DifficultyGroup == chart.DifficultyGroup &&
                actual.Difficulty.Name == chart.Difficulty.Name &&
                actual.Difficulty.IsPlus == chart.Difficulty.IsPlus &&
                actual.SongPath == chart.SongPath &&
                actual.ImagePath == chart.ImagePath &&
                actual.Name == chart.Name &&
                actual.NameRomanized == chart.NameRomanized &&
                actual.Artist == chart.Artist &&
                actual.ArtistRomanized == chart.ArtistRomanized &&
                actual.Bpm == chart.Bpm &&
                actual.Constant == chart.Constant &&
                actual.Charter == chart.Charter &&
                actual.Illustrator == chart.Illustrator &&
                actual.Background == chart.Background &&
                actual.Style == chart.Style &&
                actual.ChartPath == chart.ChartPath
                , json + "\n" + JsonHelper.GetJson(chart));
        }
Beispiel #2
0
 public void PackParse_WithMissingValue_ThrowsError(string name, string img)
 {
     (Pack actual, string json) = JsonHelper.GeneratePack(name, img);
     Assert.Throws <JsonReaderException>(() => {
         JObject jobj = JObject.Parse(json);
         Pack pack    = JsonUserInput.ReadPackJson(jobj.CreateReader());
     });
 }
Beispiel #3
0
        public void LevelParse_NoPacks_Success()
        {
            (Level actual, string json) = JsonHelper.GenerateLevel(null, new Chart[] { getDummyChart() });

            JObject jobj  = JObject.Parse(json);
            Level   level = JsonUserInput.ReadLevelJson(jobj.CreateReader());

            Assert.IsNull(level.PackExternalId);
        }
Beispiel #4
0
        public void LevelParse_NoCharts_ThrowsError()
        {
            (Level actual, string json) = JsonHelper.GenerateLevel("testpack", new Chart[0]);

            Assert.Throws <JsonReaderException>(() => {
                JObject jobj = JObject.Parse(json);
                Level level  = JsonUserInput.ReadLevelJson(jobj.CreateReader());
            });
        }
Beispiel #5
0
        public void PackParse_Success()
        {
            (Pack actual, string json) = JsonHelper.GeneratePack("testpack", "testimg");

            JObject jobj = JObject.Parse(json);
            Pack    pack = JsonUserInput.ReadPackJson(jobj.CreateReader());

            Assert.That(
                pack.Name == "testpack" &&
                pack.ImagePath == "testimg",
                json
                );
        }
Beispiel #6
0
        private void CreateLevel(Level level, string exid, string path)
        {
            string settingsJson = JsonHelper.GenerateSettingsJson(level, exid);

            CreateFile(Path.Combine(path, FileStatics.SettingsJson), settingsJson);
            foreach (Chart chart in level.Charts)
            {
                CreateFile(Path.Combine(path, chart.SongPath ?? "base.ogg"));
                CreateFile(Path.Combine(path, chart.ImagePath ?? "base.jpg"));
                CreateFile(Path.Combine(path, chart.ChartPath ?? JsonUserInput.GetChartPathFromPresetGroup(chart.DifficultyGroup)));
                CreateFile(Path.Combine(path, chart.Background));
            }
        }
Beispiel #7
0
        public void LevelParse_Success(int chartCount)
        {
            Chart[] charts = new Chart[chartCount];
            for (int i = 0; i < chartCount; i++)
            {
                charts[i] = getDummyChart();
            }

            (Level actual, string json) = JsonHelper.GenerateLevel("testpack", charts);
            JObject jobj  = JObject.Parse(json);
            Level   level = JsonUserInput.ReadLevelJson(jobj.CreateReader());

            Assert.That(
                level.PackExternalId == "testpack" && level.Charts.Length == chartCount,
                json
                );
        }
Beispiel #8
0
 public void ChartParse_WithMissingValues_ThrowsError(
     string d, float constant,
     string song, string img, string bg,
     string name, string namer, string artist, string artistr,
     string bpm, string charter, string illust,
     string chartpath, string style
     )
 {
     (Chart actual, string json) = JsonHelper.GenerateChart(
         JsonUserInput.Future, d, constant, song, img, bg,
         name, namer, artist, artistr,
         bpm, charter, illust, chartpath, style
         );
     Assert.Throws <JsonReaderException>(() => {
         JObject jobj = JObject.Parse(json);
         Chart chart  = JsonUserInput.ReadChartJson(jobj.CreateReader());
     });
 }
Beispiel #9
0
        public void ChartParse_WithCustomDifficulty_Success(string diff, string expectedChartPath)
        {
            DifficultyGroup dg = JsonUserInput.FromPreset(diff);

            Chart actual = getDummyChart();

            actual.DifficultyGroup = dg;
            actual.ChartPath       = expectedChartPath;
            string json = JsonHelper.GetJson(actual);

            JObject jobj  = JObject.Parse(json);
            Chart   chart = JsonUserInput.ReadChartJson(jobj.CreateReader());

            Assert.That(
                chart.DifficultyGroup == dg &&
                chart.ChartPath == expectedChartPath,
                json
                );
        }
Beispiel #10
0
        public static (Chart chart, string json) GenerateChart(
            DifficultyGroup dg, string d, float constant,
            string song, string img, string bg,
            string name, string namer, string artist, string artistr,
            string bpm, string charter, string illust,
            string chartpath, string style
            )
        {
            Style s;

            switch (style.ToLower())
            {
            case "conflict":
                s = Style.Conflict;
                break;

            case "light":
            default:
                s = Style.Light;
                break;
            }

            Chart chart = new Chart
            {
                DifficultyGroup = dg,
                Difficulty      = new Difficulty(d),
                Constant        = constant,
                SongPath        = song ?? "base.ogg",
                ImagePath       = img ?? "base.jpg",
                Background      = bg ?? "bg.jpg",
                Name            = name,
                NameRomanized   = namer ?? name,
                Artist          = artist,
                ArtistRomanized = artistr ?? artist,
                Bpm             = bpm,
                Charter         = charter,
                Illustrator     = illust,
                ChartPath       = chartpath ?? JsonUserInput.GetChartPathFromPresetGroup(dg),
                Style           = s
            };

            return(chart, GetJson(chart));
        }