public void SmFile_LightsChart_Throws_If_LightChart_Already_Exists(string smFilePath) { var smFileCopy = $"{smFilePath}.test.sm"; string backupFilePath = $"{smFileCopy}.backup"; File.Copy(smFilePath, smFileCopy, true); Assert.Throws <InvalidOperationException>(() => { var smFile = new SmFile(smFileCopy); var chart = StepChartBuilder.GenerateLightsChart(smFile); smFile.WriteLightsChart(chart); }); try { if (File.Exists(smFileCopy)) { File.Delete(smFileCopy); } if (File.Exists(backupFilePath)) { File.Delete(backupFilePath); } } catch { /* intentionally left empty */ } }
private static LastTimingDataEntry ConvertLastBpm(SmFile smFile) { var lastBpm = smFile.bpms.bpms.LastOrDefault(); var displayBpm = smFile.displayBpm; return(new LastTimingDataEntryConverter().Convert(lastBpm.bpm, displayBpm)); }
public void SmFile_LightsChart_Creates_Backup_File(string smFilePath) { // We create a copy of each .sm file since this test writes data to the files under test // and we do not want this data to conflict with other tests var smFileCopy = $"{smFilePath}.test.sm"; string backupFilePath = $"{smFileCopy}.backup"; File.Copy(smFilePath, smFileCopy, true); var smFile = new SmFile(smFileCopy); var chart = StepChartBuilder.GenerateLightsChart(smFile); smFile.WriteLightsChart(chart); var backupFileExists = File.Exists(backupFilePath); Assert.True(backupFileExists, $".sm backup file was not created.\n{smFileCopy}"); try { if (File.Exists(smFileCopy)) { File.Delete(smFileCopy); } if (File.Exists(backupFilePath)) { File.Delete(backupFilePath); } } catch { /* intentionally left empty */ } }
public void SmFile_LightsChart_Saves_Data_To_File(string smFilePath) { // We create a copy of each .sm file since this test writes data to the files under test // and we do not want this data to conflict with other tests var smFileCopy = $"{smFilePath}.test.sm"; string backupFilePath = $"{smFileCopy}.backup"; File.Copy(smFilePath, smFileCopy, true); var smFile = new SmFile(smFileCopy); bool hasLightsBeforeSave = smFile.ChartMetadata.GetSteps(PlayStyle.Lights, SongDifficulty.Easy) != null; var chart = StepChartBuilder.GenerateLightsChart(smFile); smFile.WriteLightsChart(chart); bool hasLightsAfterSave = smFile.ChartMetadata.GetSteps(PlayStyle.Lights, SongDifficulty.Easy) != null; Assert.False(hasLightsBeforeSave, $".sm file under test already has a lights chart defined.\n{smFileCopy}"); Assert.True(hasLightsAfterSave, $".sm file did not have lights chart after save.\n{smFileCopy}"); try { if (File.Exists(smFileCopy)) { File.Delete(smFileCopy); } if (File.Exists(backupFilePath)) { File.Delete(backupFilePath); } } catch { /* intentionally left empty */ } }
public void SmFile_Throws_Exception_When_File_Does_Not_Exist() { Assert.Throws <ArgumentException>(() => { var smFile = new SmFile("TestData/wrongFile.sm"); }); }
public void SmFile_LightsChart_Does_Not_Leave_Unended_Holds(string smFilePath) { // We create a copy of each .sm file since this test writes data to the files under test // and we do not want this data to conflict with other tests var smFileCopy = $"{smFilePath}.test.sm"; string backupFilePath = $"{smFileCopy}.backup"; File.Copy(smFilePath, smFileCopy, true); var smFile = new SmFile(smFileCopy); var chart = StepChartBuilder.GenerateLightsChart(smFile); smFile.WriteLightsChart(chart); var endHoldState = LightsChartHelper.VerifyLightChartHolds(smFileCopy); Assert.Equal(LightsChartHelper.LightChartHoldState.HoldingNone, endHoldState); try { if (File.Exists(smFileCopy)) { File.Delete(smFileCopy); } if (File.Exists(backupFilePath)) { File.Delete(backupFilePath); } } catch { /* intentionally left empty */ } }
public void SmFile_Banner_Attribute_Is_Populated(string smFilePath, string expectedBanner) { var smFile = new SmFile(smFilePath); string actualBanner = smFile.BannerPath; Assert.Equal(expectedBanner, actualBanner); }
public void SmFile_Group_Attribute_Is_Populated(string smFilePath, string expectedGroup) { var smFile = new SmFile(smFilePath); string actualGroup = smFile.Group; Assert.Equal(expectedGroup, actualGroup); }
public void SmFile_ChartMetadata_Populates_All_Stepcharts(string smFilePath, int expectedChartCount) { var smFile = new SmFile(smFilePath); int actualChartCount = smFile.ChartMetadata.StepCharts.Count; Assert.Equal(expectedChartCount, actualChartCount); }
public void SmFile_GetHighestChartedDifficulty_Returns_The_Highest_Difficulty(string smFilePath, SongDifficulty expectedDifficulty) { var smFile = new SmFile(smFilePath); var actualDifficulty = smFile.ChartMetadata.GetHighestChartedDifficulty(PlayStyle.Single); Assert.Equal(expectedDifficulty, actualDifficulty); }
public void SmFile_Artist_Attribute_Is_Populated(string smFilePath, string expectedArtist) { var smFile = new SmFile(smFilePath); string actualArtist = smFile.Artist; Assert.Equal(expectedArtist, actualArtist); }
public void SscFile_Parses_Difficulty_Meter(string sscFilePath, int expectedMeter) { var sscFile = new SmFile(sscFilePath); var actualMeter = sscFile.ChartMetadata.StepCharts.Single().DifficultyRating; Assert.Equal(expectedMeter, actualMeter); }
public void SscFile_Parses_Difficulty(string sscFilePath, SongDifficulty expecteDifficulty) { var sscFile = new SmFile(sscFilePath); var actualDifficulty = sscFile.ChartMetadata.StepCharts.Single().Difficulty; Assert.Equal(expecteDifficulty, actualDifficulty); }
public void SscFile_Parses_Steps_Type(string sscFilePath, PlayStyle expectedPlayStyle) { var sscFile = new SmFile(sscFilePath); var actualPlayStyle = sscFile.ChartMetadata.StepCharts.Single().PlayStyle; Assert.Equal(expectedPlayStyle, actualPlayStyle); }
public void SscFile_Parses_Chart_Name(string sscFilePath, string expectedChartName) { var sscFile = new SmFile(sscFilePath); var actualChartName = sscFile.ChartMetadata.StepCharts.Single().ChartName; Assert.Equal(expectedChartName, actualChartName); }
public void SmFile_With_No_DisplayBpm_Tag_Still_Shows_Correct_Bpm_Range(string smFilePath, string expectedBpm) { var smFile = new SmFile(smFilePath); var bpm = smFile.DisplayBpm; Assert.Equal(expectedBpm, bpm); }
[InlineData(TEST_DATA_ARABIAN_NIGHTS)] //Doubles Only chart public void SmFile_GenerateLightsChart_Generates_Lights_Data_Content(string smFilePath) { var smFile = new SmFile(smFilePath); var lightsData = StepChartBuilder.GenerateLightsChart(smFile); Assert.True(!string.IsNullOrEmpty(lightsData.Content)); }
public void SmFile_Returns_Empty_String_For_NonExistent_Attribute(string smFilePath) { var smFile = new SmFile(smFilePath); string value = smFile[SmFileAttribute.TIMESIGNATURES]; Assert.Equal(string.Empty, value); }
public void SmFile_Title_Attribute_Is_Populated(string smFileName, string expectedTitle) { var smFile = new SmFile(smFileName); string actualTitle = smFile.SongTitle; Assert.Equal(expectedTitle, actualTitle); }
[InlineData(TEST_DATA_GARGOYLE)] //Test case for missing semicolon in attribute tag public void SmFile_BannerPath_Points_To_Valid_File(string smFilePath) { var smFile = new SmFile(smFilePath); var fullBannerPath = Path.Combine(smFile.Directory, smFile.BannerPath); var bannerExists = File.Exists(fullBannerPath); Assert.True(bannerExists, $"Banner path could not be found: {fullBannerPath}"); }
public SmSongToRhConverter(string smSongDir, string rhDir, float songOffset = 0f) { this.smSongDir = smSongDir; this.rhDir = rhDir; this.songOffset = songOffset; var smFilePath = Directory.GetFiles(smSongDir, "*.sm").Single(); smFile = ITextSerializableExtensions.Deserialize(smFilePath, SmFile.Deserialize); }
[InlineData(TEST_DATA_ARABIAN_NIGHTS, PlayStyle.Double, SongDifficulty.Challenge)] //Doubles Only chart public void SmFile_GenerateLightsChart_Maintains_Reference_Chart_Data(string smFilePath, PlayStyle referenceChartStyle, SongDifficulty referenceChartDifficulty) { var smFile = new SmFile(smFilePath); var lightsData = StepChartBuilder.GenerateLightsChart(smFile); Assert.Equal(referenceChartStyle, lightsData.ReferenceChart.PlayStyle); Assert.Equal(referenceChartDifficulty, lightsData.ReferenceChart.Difficulty); }
public List <RhcFile> Convert(SmFile smFile, RhGuid rhsGuid, string artist) { var rhcFiles = new List <RhcFile>(); foreach (var chart in smFile.charts) { rhcFiles.Add(ConvertRhcFile(chart, rhsGuid, artist)); } return(rhcFiles); }
public float offsetConst = 44100f; // Uncertain if this is the exact value, but it matches a common music sampling rate public TimingData Convert(SmFile smFile, float songOffset) { var data = new TimingData(); data.unknown1 = 0; // Fake value var offset = -(smFile.offset + songOffset); // Might need to negate this data.offsetMultiplier = (long)(offset * offsetConst); data.entries = ConvertBpms(smFile, offset); data.lastEntry = ConvertLastBpm(smFile); return(data); }
public RhsFile Convert(SmFile smFile, RhGuid oggGuid, RhGuid pngGuid, float songOffset) { var rhsFile = new RhsFile(); rhsFile.rhsGuid = RhGuid.NewGuid(); rhsFile.internalGuid = new RhGuid(); rhsFile.oggGuid = oggGuid; rhsFile.songTitle = smFile.title; rhsFile.timingData = new TimingDataConverter().Convert(smFile, songOffset); rhsFile.previewStart = smFile.sampleStart; rhsFile.previewLength = smFile.sampleLength; rhsFile.songLengthOverride = -1f; // TODO: Consider using the beat of the last note (+ some padding) rhsFile.pngGuid = pngGuid; rhsFile.artists.Add(new Artist(smFile.artist, ArtistType.Artist)); return(rhsFile); }
public static LightsChart GenerateLightsChart(SmFile file) { var reference = file.ChartMetadata.GetSteps(PlayStyle.Single, SongDifficulty.Hard) ?? file.ChartMetadata.GetSteps(PlayStyle.Single, SongDifficulty.Challenge) ?? file.ChartMetadata.GetSteps(PlayStyle.Double, SongDifficulty.Hard) ?? file.ChartMetadata.GetSteps(PlayStyle.Double, SongDifficulty.Challenge) ?? file.ChartMetadata.GetSteps(PlayStyle.Single, file.ChartMetadata.GetHighestChartedDifficulty(PlayStyle.Single)) ?? file.ChartMetadata.GetSteps(PlayStyle.Double, file.ChartMetadata.GetHighestChartedDifficulty(PlayStyle.Double)); if (reference == null) { throw new ArgumentException("Could not find a reference chart.", nameof(file)); } var lightsData = GenerateLightsChart(file.FilePath, reference); return(new LightsChart(lightsData, reference)); }
/// <summary> /// Converts all BPMs except for the last BPM /// </summary> private static List <TimingDataEntry> ConvertBpms(SmFile smFile, float offset) { var entries = new List <TimingDataEntry>(); var prevTime = offset; for (var i = 1; i < smFile.bpms.bpms.Count; i++) { var prevBpm = smFile.bpms.bpms[i - 1]; var curBpm = smFile.bpms.bpms[i]; var curTime = 60 * ((curBpm.beat - prevBpm.beat) / prevBpm.bpm) + prevTime; entries.Add(new TimingDataEntryConverter().Convert(curBpm.beat, curTime)); prevTime = curTime; } return(entries); }
public void SmFile_With_DisplayBpm_Tag_Shows_Correct_Bpm(string smFilePath, string expectedDisplayBpm) { var smFile = new SmFile(smFilePath); Assert.Equal(expectedDisplayBpm, smFile.DisplayBpm); }