Fixed ColorBlock parsing to respect comments, preventing overflow errors when numbers are present in comments on these lines.
This commit is contained in:
parent
72e9caec29
commit
692269ddb3
|
@ -472,6 +472,27 @@ namespace Filtration.Tests.Translators
|
|||
Assert.AreEqual(100, blockItem.Color.B);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterBlock_SetBorderColor_CommentWithLargeNumber_DoesNotThrow()
|
||||
{
|
||||
// Arrange
|
||||
var inputString = "Show" + Environment.NewLine +
|
||||
" SetBorderColor 255 20 100 # Some stuff 8504 with a number in a comment";
|
||||
|
||||
// Act
|
||||
|
||||
Assert.DoesNotThrow(() => _testUtility.Translator.TranslateStringToItemFilterBlock(inputString));
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem));
|
||||
var blockItem = result.BlockItems.OfType<BorderColorBlockItem>().First();
|
||||
Assert.AreEqual(255, blockItem.Color.R);
|
||||
Assert.AreEqual(20, blockItem.Color.G);
|
||||
Assert.AreEqual(100, blockItem.Color.B);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterBlock_SetFontSize_ReturnsCorrectObject()
|
||||
{
|
||||
|
|
|
@ -260,7 +260,10 @@ namespace Filtration.Translators
|
|||
private static void AddColorItemToBlockItems<T>(ItemFilterBlock block, string inputString) where T : ColorBlockItem
|
||||
{
|
||||
var blockItem = Activator.CreateInstance<T>();
|
||||
blockItem.Color = GetColorFromString(inputString);
|
||||
var result = Regex.Matches(inputString, @"([\w\s]*)[#]?(.*)");
|
||||
|
||||
// When Theme support is added result[0].Groups[2].Value will contain the ColorGroup in the comment if it exists.
|
||||
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
|
||||
block.BlockItems.Add(blockItem);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace Filtration.ViewModels
|
|||
ItemFilterScript Script { get; }
|
||||
IItemFilterBlockViewModel SelectedBlockViewModel { get; set; }
|
||||
IItemFilterBlockViewModel SectionBrowserSelectedBlockViewModel { get; set; }
|
||||
ObservableCollection<ItemFilterBlockGroup> BlockGroups { get; }
|
||||
IEnumerable<IItemFilterBlockViewModel> ItemFilterSectionViewModels { get; }
|
||||
Predicate<IItemFilterBlockViewModel> BlockFilterPredicate { get; set; }
|
||||
bool IsDirty { get; }
|
||||
|
@ -183,11 +182,6 @@ namespace Filtration.ViewModels
|
|||
|
||||
public ItemFilterScript Script { get; private set; }
|
||||
|
||||
public ObservableCollection<ItemFilterBlockGroup> BlockGroups
|
||||
{
|
||||
get { return Script.ItemFilterBlockGroups; }
|
||||
}
|
||||
|
||||
public bool IsDirty
|
||||
{
|
||||
get { return _isDirty || HasDirtyChildren; }
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using Filtration.Models;
|
||||
using Filtration.Repositories;
|
||||
using Filtration.Services;
|
||||
using Filtration.Translators;
|
||||
using Filtration.Views;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
using Clipboard = System.Windows.Clipboard;
|
||||
using MessageBox = System.Windows.Forms.MessageBox;
|
||||
using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
|
||||
|
||||
namespace Filtration.ViewModels
|
||||
|
|
Loading…
Reference in New Issue