public void TestPlayDataOuterPlayLogInnerStageData() { StageData[] stageDataArray = new StageData[] { new StageData { Id = 0, Name = "Stage0" }, new StageData { Id = 1, Name = "Stage1" }, new StageData { Id = 2, Name = "Stage2" }, }; PlayLog[] playLogArray = new PlayLog[] { new PlayLog { StageId = 0, Score = 1 }, new PlayLog { StageId = 1, Score = 2 }, new PlayLog { StageId = 2, Score = 3 }, new PlayLog { StageId = 0, Score = 4 }, new PlayLog { StageId = 1, Score = 5 }, new PlayLog { StageId = 1, Score = 6 }, new PlayLog { StageId = 2, Score = 7 }, }; IEnumerable <PlayData> playDataEnumerable = playLogArray.Join <PlayLog, StageData, int, PlayData> ( inner: stageDataArray, outerKeySelector: (PlayLog playLog) => playLog.StageId, innerKeySelector: (StageData stageData) => stageData.Id, resultSelector: (PlayLog playLog, StageData stageData) => new PlayData { StageName = stageData.Name, Score = playLog.Score }); Assert.That(playDataEnumerable.Count(), Is.EqualTo(7)); Assert.That(playDataEnumerable.ElementAt(0).StageName, Is.EqualTo("Stage0")); Assert.That(playDataEnumerable.ElementAt(0).Score, Is.EqualTo(1)); Assert.That(playDataEnumerable.ElementAt(1).StageName, Is.EqualTo("Stage1")); Assert.That(playDataEnumerable.ElementAt(1).Score, Is.EqualTo(2)); Assert.That(playDataEnumerable.ElementAt(2).StageName, Is.EqualTo("Stage2")); Assert.That(playDataEnumerable.ElementAt(2).Score, Is.EqualTo(3)); Assert.That(playDataEnumerable.ElementAt(3).StageName, Is.EqualTo("Stage0")); Assert.That(playDataEnumerable.ElementAt(3).Score, Is.EqualTo(4)); Assert.That(playDataEnumerable.ElementAt(4).StageName, Is.EqualTo("Stage1")); Assert.That(playDataEnumerable.ElementAt(4).Score, Is.EqualTo(5)); Assert.That(playDataEnumerable.ElementAt(5).StageName, Is.EqualTo("Stage1")); Assert.That(playDataEnumerable.ElementAt(5).Score, Is.EqualTo(6)); Assert.That(playDataEnumerable.ElementAt(6).StageName, Is.EqualTo("Stage2")); Assert.That(playDataEnumerable.ElementAt(6).Score, Is.EqualTo(7)); }
public void TestPlayDataOuterStageDataInnerPlayLog() { StageData[] stageDataArray = new StageData[] { new StageData { Id = 0, Name = "Stage0"}, new StageData { Id = 1, Name = "Stage1"}, new StageData { Id = 2, Name = "Stage2"}, }; PlayLog[] playLogArray = new PlayLog[]{ new PlayLog { StageId = 0, Score = 1}, new PlayLog { StageId = 1, Score = 2}, new PlayLog { StageId = 2, Score = 3}, new PlayLog { StageId = 0, Score = 4}, new PlayLog { StageId = 1, Score = 5}, new PlayLog { StageId = 1, Score = 6}, new PlayLog { StageId = 2, Score = 7}, }; IEnumerable<StagePlayData> stagePlayDataEnumerable = stageDataArray.GroupJoin<StageData, PlayLog, int, StagePlayData> ( inner: playLogArray, outerKeySelector: (StageData stageData) => stageData.Id, innerKeySelector: (PlayLog playLog) => playLog.StageId, resultSelector: (StageData stageData, IEnumerable<PlayLog> playLogs) => new StagePlayData { StageName = stageData.Name, ScoreList = playLogs.Select (it => it.Score).ToList () } ); Assert.That (stagePlayDataEnumerable.Count (), Is.EqualTo (3)); Assert.That (stagePlayDataEnumerable.ElementAt (0).StageName, Is.EqualTo ("Stage0")); Assert.That (SL.Enumerable.SequenceEqual (stagePlayDataEnumerable.ElementAt (0).ScoreList, new [] { 1, 4 })); Assert.That (stagePlayDataEnumerable.ElementAt (1).StageName, Is.EqualTo ("Stage1")); Assert.That (SL.Enumerable.SequenceEqual (stagePlayDataEnumerable.ElementAt (1).ScoreList, new [] { 2, 5, 6 })); Assert.That (stagePlayDataEnumerable.ElementAt (2).StageName, Is.EqualTo ("Stage2")); Assert.That (SL.Enumerable.SequenceEqual (stagePlayDataEnumerable.ElementAt (2).ScoreList, new [] { 3, 7 })); }
public void TestPlayDataOuterStageDataInnerPlayLog() { StageData[] stageDataArray = new StageData[] { new StageData { Id = 0, Name = "Stage0" }, new StageData { Id = 1, Name = "Stage1" }, new StageData { Id = 2, Name = "Stage2" }, }; PlayLog[] playLogArray = new PlayLog[] { new PlayLog { StageId = 0, Score = 1 }, new PlayLog { StageId = 1, Score = 2 }, new PlayLog { StageId = 2, Score = 3 }, new PlayLog { StageId = 0, Score = 4 }, new PlayLog { StageId = 1, Score = 5 }, new PlayLog { StageId = 1, Score = 6 }, new PlayLog { StageId = 2, Score = 7 }, }; IEnumerable <StagePlayData> stagePlayDataEnumerable = stageDataArray.GroupJoin <StageData, PlayLog, int, StagePlayData> ( inner: playLogArray, outerKeySelector: (StageData stageData) => stageData.Id, innerKeySelector: (PlayLog playLog) => playLog.StageId, resultSelector: (StageData stageData, IEnumerable <PlayLog> playLogs) => new StagePlayData { StageName = stageData.Name, ScoreList = playLogs.Select(it => it.Score).ToList() } ); Assert.That(stagePlayDataEnumerable.Count(), Is.EqualTo(3)); Assert.That(stagePlayDataEnumerable.ElementAt(0).StageName, Is.EqualTo("Stage0")); Assert.That(SL.Enumerable.SequenceEqual(stagePlayDataEnumerable.ElementAt(0).ScoreList, new [] { 1, 4 })); Assert.That(stagePlayDataEnumerable.ElementAt(1).StageName, Is.EqualTo("Stage1")); Assert.That(SL.Enumerable.SequenceEqual(stagePlayDataEnumerable.ElementAt(1).ScoreList, new [] { 2, 5, 6 })); Assert.That(stagePlayDataEnumerable.ElementAt(2).StageName, Is.EqualTo("Stage2")); Assert.That(SL.Enumerable.SequenceEqual(stagePlayDataEnumerable.ElementAt(2).ScoreList, new [] { 3, 7 })); }
public void TestPlayDataOuterStageDataInnerPlayLog() { StageData[] stageDataArray = new StageData[] { new StageData { Id = 0, Name = "Stage0"}, new StageData { Id = 1, Name = "Stage1"}, new StageData { Id = 2, Name = "Stage2"}, }; PlayLog[] playLogArray = new PlayLog[]{ new PlayLog { StageId = 0, Score = 1}, new PlayLog { StageId = 1, Score = 2}, new PlayLog { StageId = 2, Score = 3}, new PlayLog { StageId = 0, Score = 4}, new PlayLog { StageId = 1, Score = 5}, new PlayLog { StageId = 1, Score = 6}, new PlayLog { StageId = 2, Score = 7}, }; IEnumerable<PlayData> playDataEnumerable = stageDataArray.Join<StageData, PlayLog, int, PlayData> ( inner: playLogArray, outerKeySelector: (StageData stageData) => stageData.Id, innerKeySelector: (PlayLog playLog) => playLog.StageId, resultSelector: (StageData stageData, PlayLog playLog) => new PlayData { StageName = stageData.Name, Score = playLog.Score}); Assert.That (playDataEnumerable.Count (), Is.EqualTo (7)); Assert.That (playDataEnumerable.ElementAt (0).StageName, Is.EqualTo ("Stage0")); Assert.That (playDataEnumerable.ElementAt (0).Score, Is.EqualTo (1)); Assert.That (playDataEnumerable.ElementAt (1).StageName, Is.EqualTo ("Stage0")); Assert.That (playDataEnumerable.ElementAt (1).Score, Is.EqualTo (4)); Assert.That (playDataEnumerable.ElementAt (2).StageName, Is.EqualTo ("Stage1")); Assert.That (playDataEnumerable.ElementAt (2).Score, Is.EqualTo (2)); Assert.That (playDataEnumerable.ElementAt (3).StageName, Is.EqualTo ("Stage1")); Assert.That (playDataEnumerable.ElementAt (3).Score, Is.EqualTo (5)); Assert.That (playDataEnumerable.ElementAt (4).StageName, Is.EqualTo ("Stage1")); Assert.That (playDataEnumerable.ElementAt (4).Score, Is.EqualTo (6)); Assert.That (playDataEnumerable.ElementAt (5).StageName, Is.EqualTo ("Stage2")); Assert.That (playDataEnumerable.ElementAt (5).Score, Is.EqualTo (3)); Assert.That (playDataEnumerable.ElementAt (6).StageName, Is.EqualTo ("Stage2")); Assert.That (playDataEnumerable.ElementAt (6).Score, Is.EqualTo (7)); }