/// <summary> /// Creates gauge indicator view model /// </summary> /// <param name="creationInfo"><see cref="HudToolCreationInfo"/></param> /// <returns>Gauge indicator view model</returns> private HudBaseToolViewModel CreateGaugeIndicatorTool(HudToolCreationInfo creationInfo) { Check.Require(creationInfo.Layout != null, "Layout isn't defined. Gauge indicator has not been created."); var statInfo = creationInfo.Source as StatInfo; if (statInfo == null) { return(null); } statInfo.IsSelected = false; var layoutTool = new HudLayoutGaugeIndicator { BaseStat = statInfo.Clone(), Text = statInfo.ToolTip }; var toolViewModel = layoutTool.CreateViewModel(creationInfo.HudElement); toolViewModel.Position = creationInfo.Position; creationInfo.Layout.LayoutTools.Add(layoutTool); return(toolViewModel); }
public void HudGaugeIndicatorViewModelToolCanBeSerializedDeserializedWithProtobuf() { var hudLayoutToolExpected = new HudLayoutGaugeIndicator { BaseStat = new StatInfo { Stat = Stat.CBet }, Stats = new ReactiveList <StatInfo> { new StatInfo { Stat = Stat.VPIP }, new StatInfo { Stat = Stat.PFR }, new StatInfo { Stat = Stat.S3Bet }, new StatInfo { Stat = Stat.ColdCall } }, Text = "test", IsVertical = true, HeaderText = "HeaderText", Tools = new ReactiveList <HudLayoutTool> { new HudLayoutHeatMapTool { BaseStat = new StatInfo { Stat = Stat.PFR } } } }; var hudElement = new HudElementViewModel { Seat = 1, }; var hudToolViewModelExpected = hudLayoutToolExpected.CreateViewModel(hudElement) as HudGaugeIndicatorViewModel; hudToolViewModelExpected.IsGraphIndicatorsDisabled = true; Assert.IsNotNull(hudToolViewModelExpected.GroupedStats); var hudToolViewModelActual = SerializerHelper.GetSerializedDeserializedObject(hudToolViewModelExpected); Assert.That(hudToolViewModelActual.Id, Is.EqualTo(hudToolViewModelExpected.Id)); Assert.That(hudToolViewModelActual.ToolType, Is.EqualTo(hudToolViewModelExpected.ToolType)); Assert.That(hudToolViewModelActual.Stats.Count, Is.EqualTo(hudToolViewModelExpected.Stats.Count)); Assert.That(hudToolViewModelActual.BaseStat.Stat, Is.EqualTo(hudToolViewModelExpected.BaseStat.Stat)); Assert.That(hudToolViewModelActual.Width, Is.EqualTo(hudToolViewModelExpected.Width)); Assert.That(hudToolViewModelActual.Text, Is.EqualTo(hudToolViewModelExpected.Text)); Assert.That(hudToolViewModelActual.HeaderText, Is.EqualTo(hudToolViewModelExpected.HeaderText)); Assert.That(hudToolViewModelActual.Height, Is.EqualTo(hudToolViewModelExpected.Height)); Assert.That(hudToolViewModelActual.Position, Is.EqualTo(hudToolViewModelExpected.Position)); Assert.That(hudToolViewModelActual.IsGraphIndicatorsDisabled, Is.EqualTo(hudToolViewModelExpected.IsGraphIndicatorsDisabled)); Assert.That(hudToolViewModelActual.GroupedStats.Count, Is.EqualTo(hudToolViewModelExpected.GroupedStats.Count)); var hudGaugeIndicatorStats = hudToolViewModelActual.GroupedStats.SelectMany(x => x.Stats).ToArray(); foreach (var groupedStat in hudToolViewModelExpected.GroupedStats) { foreach (var expectedHudGaugeIndicatorStat in groupedStat.Stats) { var actualHudGaugeIndicatorStat = hudGaugeIndicatorStats.FirstOrDefault(x => x.Stat.Stat == expectedHudGaugeIndicatorStat.Stat.Stat); Assert.IsNotNull(actualHudGaugeIndicatorStat); if (expectedHudGaugeIndicatorStat.IsHeatMapVisible) { Assert.That(actualHudGaugeIndicatorStat.IsHeatMapVisible, Is.EqualTo(expectedHudGaugeIndicatorStat.IsHeatMapVisible)); Assert.That(actualHudGaugeIndicatorStat.HeatMapViewModel.BaseStat.Stat, Is.EqualTo(expectedHudGaugeIndicatorStat.HeatMapViewModel.BaseStat.Stat)); } } } }