public void TestThatGetFilteredStringPathRemovedIllegalCharacters() { string sTestString = "`~!@#$%^&*()=+[{]}|;'\",<>?\a\b\t\r\v\f\n\u001B/opt/SpeechBridge`~!@#$%^&*()=+[{]}|;'\",<>?\a\b\t\r\v\f\n\u001B/Voice Doc_Store/AAMain.xml.vxml`~!@#$%^&*()=+[{]}|;'\",<>?\a\b\t\r\v\f\n\u001B"; string sExpectedString = "/opt/SpeechBridge/Voice Doc_Store/AAMain.xml.vxml"; Assert.That(StringFilter.GetFilteredStringPath(sTestString), Is.EqualTo(sExpectedString)); }
public LocalizationFilter(int?id = null, DictionaryFilter dictionary = null, CultureFilter culture = null, StringFilter value = null) { Id = id; Dictionary = dictionary; Culture = culture; Value = value; }
public void PassesFilter_DoesNotContain_ReturnsTrue(string argument, bool caseInvariant, bool expected) { var filter = new StringFilter(argument, StringFilter.StringFilterMethod.DoesNotContain, caseInvariant); var result = filter.PassesFilter("This is a string for TESTING."); Assert.Equal(expected, result); }
public void TestThatGetFilteredStringPathCanHandleAnEmptyString() { string sTestString = ""; string sExpectedString = sTestString; Assert.That(StringFilter.GetFilteredStringPath(sTestString), Is.EqualTo(sExpectedString)); }
public void TestThatGetFilteredStringPathLeavesAValidWindowsPathUnchanged() { string sTestString = @"C:\Program Files\SpeechBridge\VoiceDoc Store\AAMain.xml.vxml"; string sExpectedString = sTestString; Assert.That(StringFilter.GetFilteredStringPath(sTestString), Is.EqualTo(sExpectedString)); }
public void TestThatGetFilteredStringPathLeavesAValidLinuxPathUnchanged() { string sTestString = "/opt/SpeechBridge/Voice DocStore/AAMain.xml.vxml"; string sExpectedString = sTestString; Assert.That(StringFilter.GetFilteredStringPath(sTestString), Is.EqualTo(sExpectedString)); }
public void TestReplacementOfMultipleAnd() { string sTestString = "Going on & on & on"; string sExpectedString = "Going on and on and on"; Assert.That(StringFilter.GetFilteredString(sTestString), Is.EqualTo(sExpectedString)); }
public void TestThatGetFilteredStringDialOnlyAllowsDigits() { string sTestString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ (123) 456-7890 abcdefghijklpmnopqrstuvwxyz ~`!@#$%^&*()_-+={[}}\\|:;\"'<,>.?/"; string sExpectedString = "1234567890"; Assert.That(StringFilter.GetFilteredStringDial(sTestString), Is.EqualTo(sExpectedString)); }
public void TestThatGetFilteredStringRemovesLeadingAndTrailingUnderscores() { string sTestSting = "_I use underscore instead of spaces __ "; string sExpectedString = "I use underscore instead of spaces"; Assert.That(StringFilter.GetFilteredString(sTestSting), Is.EqualTo(sExpectedString)); }
public void TestReplacementOfAnd() { string sTestString = "Adam & Eve"; string sExpectedString = "Adam and Eve"; Assert.That(StringFilter.GetFilteredString(sTestString), Is.EqualTo(sExpectedString)); }
public void TestThatGetFilteredStringReplacesUnderscoreWithSpace() { string sTestSting = "I_use_underscore_instead_of_spaces"; string sExpectedString = "I use underscore instead of spaces"; Assert.That(StringFilter.GetFilteredString(sTestSting), Is.EqualTo(sExpectedString)); }
public void TestThatGetFilteredStringReplacesMultipleConsecutiveUnderscoresWithASingleSpace() { string sTestSting = "I__use__underscore__instead____of_________spaces"; string sExpectedString = "I use underscore instead of spaces"; Assert.That(StringFilter.GetFilteredString(sTestSting), Is.EqualTo(sExpectedString)); }
public void TestThatRemoveApostrophesCanHandleAnEmptyString() { string sTestString = ""; string sExpectedString = sTestString; Assert.That(StringFilter.RemoveApostrophes(sTestString), Is.EqualTo(sExpectedString)); }
public void TestThatRemoveApostrophesWorks() { string sTestString = "I'd like to help but can't."; string sExpectedString = "Id like to help but cant."; Assert.That(StringFilter.RemoveApostrophes(sTestString), Is.EqualTo(sExpectedString)); }
public void TestThatMultipleHtmlNbspAreRemoved() { string sTestString = " "; string sExpectedString = ""; Assert.That(StringFilter.GetFilteredString(sTestString), Is.EqualTo(sExpectedString)); }
public void TestThatRemoveSpacesWorks() { string sTestString = "This is a test."; string sExpectedString = "Thisisatest."; Assert.That(StringFilter.RemoveSpaces(sTestString), Is.EqualTo(sExpectedString)); }
public void TestThatGetFilteredStringReducesConsecutiveSpacesToASingleSpace() { string sTestString = "Jane Doe"; string sExpectedString = "Jane Doe"; Assert.That(StringFilter.GetFilteredString(sTestString), Is.EqualTo(sExpectedString)); }
public void PassesFilter_DoesNotMatch_ReturnsTrue(string toTest, bool caseInvariant, bool expected) { var filter = new StringFilter("This is a string for TESTING.", StringFilter.StringFilterMethod.DoesNotMatch, caseInvariant); var result = filter.PassesFilter(toTest); Assert.Equal(expected, result); }
/// <summary> /// /// </summary> /// <param name="sendType">1:添加,2:编辑,3:删除</param> /// <param name="DataType">1:Excel批量导入,2:单条数据</param> /// <param name="DeviceList"></param> public void PostSend(int sendType, int DataType, string DeviceList) { HttpContext context = HttpContext.Current; Random rand = new Random(); int Num = rand.Next(1000, 9999); string Token = StringFilter.RefKeyMd5(key + Num); string tempDeviceList = DeviceList; DeviceList = context.Server.UrlEncode(DesModel.RefDesStr(DeviceList, 1)); System.Net.WebClient WebClientObj = new System.Net.WebClient(); System.Collections.Specialized.NameValueCollection PostVars = new System.Collections.Specialized.NameValueCollection(); PostVars.Add("Token", Token); PostVars.Add("Num", Num.ToString()); PostVars.Add("DeviceList", DeviceList); PostVars.Add("DataType", DataType.ToString()); try { byte[] byRemoteInfo = WebClientObj.UploadValues(SynUrl + DevSendType(sendType), "POST", PostVars); //下面都没用啦,就上面一句话就可以了 string sRemoteInfo = System.Text.Encoding.Default.GetString(byRemoteInfo); Logger.writeLog("同步AP数据:" + tempDeviceList + ",处理结果:" + sRemoteInfo); //这是获取返回信息 } catch (Exception e) { Logger.ErrorLog(e, new Dictionary <string, string>() { { "sendMessage", tempDeviceList } }); } }
public UserFilter(int?id = null, StringFilter name = null, DateTimeFilter created = null, CredentialFilter credential = null) { Id = id; Name = name; Created = created; Credential = credential; }
public DataTypeParameterValueFilter(int?id = null, DataTypeParameterFilter dataTypeParameter = null, MemberFilter member = null, StringFilter value = null) { Id = id; DataTypeParameter = dataTypeParameter; Member = member; Value = value; }
private void OkClick() { string s = _InputField.text.Trim(); if (s.Equals(null) || s.Equals("")) { Warning.text = "字符串为空!"; return; } if (null != FilterRegularStr) { bool b = StringFilter.StrMatchRegex(s, FilterRegularStr); if (!b) { //不符合过滤规则,输出错误提示 Warning.text = WarningStr; return; } } if (null != Callback) { IoBuffer ib = new IoBuffer(); if (!s.Equals(null)) { ib.PutString(_InputField.text); Callback(ib.ToArray()); } } Close(); }
public void ShouldRemoveXsOfStringMaintainingFirstAndLastX() { StringFilter firstString = new StringFilter("xxHxix"); firstString.removeXs(); StringFilter secondString = new StringFilter("abcd"); secondString.removeXs(); StringFilter thirdString = new StringFilter("xabcdx"); thirdString.removeXs(); StringFilter fourthString = new StringFilter(""); fourthString.removeXs(); StringFilter fiftyString = new StringFilter("x"); fiftyString.removeXs(); Assert.Equal("abcd", secondString.GetString()); Assert.Equal("xabcdx", thirdString.GetString()); Assert.Equal("", fourthString.GetString()); Assert.Equal("x", fiftyString.GetString()); Assert.Equal("xHix", firstString.GetString()); }
protected override void ReadHeader(StreamReader sr) { base.ReadHeader(sr); string filterType; while ((filterType = sr.ReadLine()) != null) { Filter filter = null; switch (filterType) { case "StringFilter": filter = new StringFilter(sr); break; case "RatingFilter": filter = new RatingFilter(sr); break; case "DateFilter": filter = new DateFilter(sr); break; default: throw new FileLoadException(); } Filters.Add(filter); } }
#pragma warning restore CA1051 // Do not declare visible instance fields public VisualizationSettings() { PlayMode = PlayModeOption.History; DateFrom = new DateTime(1900, 1, 1); DateTo = new DateTime(2099, 1, 1); UsersFilter = new StringFilter("*", ""); FilesFilter = new StringFilter("*", ""); ViewFileNames = false; ViewDirNames = true; ViewUserNames = true; ViewAvatars = true; TimeScale = TimeScaleOption.None; SecondsPerDay = 5; MaxFiles = 10000; ResolutionWidth = Screen.PrimaryScreen.Bounds.Width; ResolutionHeight = Screen.PrimaryScreen.Bounds.Height; ViewLogo = CheckState.Indeterminate; LogoFileName = null; }
public void EditStringFilter(StringFilter filter) { old = new StringFilter(filter); SetStringFilterParams(); if (filter.Field == "title") { filterType_combobox.SelectedIndex = 0; } else if (filter.Field == "artist") { filterType_combobox.SelectedIndex = 1; } else if (filter.Field == "album") { filterType_combobox.SelectedIndex = 2; } else if (filter.Field == "genre") { filterType_combobox.SelectedIndex = 3; } if (filter.Contains) { filterParams_combobox.SelectedIndex = 0; } else { filterParams_combobox.SelectedIndex = 1; } searchString_textbox.Text = filter.SearchTerm; }
public void NoAttributes() { //arrange Init(); var filter = new StringFilter { NoAttribute = "NoAttribute" }; //act var filtered = Context.StringTestItems .AutoFilter(filter) .OrderBy(x => x.NoAttribute) .ToList(); //assert Assert.Equal(2, filtered.Count); Assert.Equal("noattribute", filtered[0].NoAttribute); Assert.Equal("NoAttributeOk", filtered[1].NoAttribute); /* EF Core * SELECT [Id] * ,[NoAttribute] * ,LEFT(s.[NoAttribute], (LEN(N'NoAttribute'))) as L * FROM [dbo].[StringTestItems] s * where [NoAttribute] LIKE 'NoAttribute' + '%' AND (LEFT(s.[NoAttribute], (LEN(N'NoAttribute'))) = N'NoAttribute') * */ /* EF 6 * WHERE NoAttribute LIKE N'NoAttribute%' */ }
public void ContainsCase() { //arrange Init(); var filter = new StringFilter { ContainsCase = "ContainsCase" }; //act var filtered = Context.StringTestItems .AutoFilter(filter) .OrderBy(x => x.ContainsCase) .ToList(); //assert Assert.Equal(2, filtered.Count); Assert.Equal("containscase", filtered[0].ContainsCase); Assert.Equal("TestContainsCase", filtered[1].ContainsCase); /* EF Core * SELECT [Id], ContainsCase * FROM [dbo].[StringTestItems] s * where charindex('ContainsCase', s.ContainsCase) > 0 */ /* EF 6 * WHERE ContainsCase LIKE '%ContainsCase%' */ }
public async void OnDrop(IDataObject dropObject, IEnumerable dropTarget) { string[] filenames = (string[])dropObject.GetData(DataFormats.FileDrop, true); var list = StringFilter.FilterFiles(filenames); await LoadImages(list); }
public StringFilterViewModel( ICommandBus commandBus, StringFilter filter) : base(commandBus, filter) { _filter = filter; }
private static string BuildFilter(StringFilter Filter) { string FilterValue = ""; string Separator = ""; if (Filter.HasFlag(StringFilter.Alpha)) { FilterValue += Separator + "[a-zA-Z]"; Separator = "|"; } if (Filter.HasFlag(StringFilter.Numeric)) { FilterValue += Separator + "[0-9]"; Separator = "|"; } if (Filter.HasFlag(StringFilter.FloatNumeric)) { FilterValue += Separator + @"[0-9\.]"; Separator = "|"; } if (Filter.HasFlag(StringFilter.ExtraSpaces)) { FilterValue += Separator + @"[ ]{2,}"; Separator = "|"; } return FilterValue; }
public void Test1xItemFitCaseSensitive() { var result = new StringFilter(true).Filter(new List<string> { "AAaBBb", "AAa", "BBb" }); Assert.AreEqual(1, result.Count); Assert.IsTrue(result.Contains("AAaBBb")); }
public void Test0xItemFitCaseSensitive() { var result = new StringFilter(true).Filter(new List<string> { "aaabbb", "aAa", "Bbb" }); Assert.AreEqual(0, result.Count); }
protected Evaluator(StringFilter stringFilter) { Filter = stringFilter; }
/// <summary> /// Removes everything that is in the filter text from the input. /// </summary> /// <param name="Input">Input text</param> /// <param name="Filter">Predefined filter to use (can be combined as they are flags)</param> /// <returns>Everything not in the filter text.</returns> public static string Remove(this string Input, StringFilter Filter) { if (string.IsNullOrEmpty(Input)) return ""; string Value = BuildFilter(Filter); return Input.Remove(Value); }
public AlphanumericEvaluator(StringFilter stringFilter) : base(stringFilter) { }
/// <summary> /// Removes everything that is not in the filter text from the input. /// </summary> /// <param name="Input">Input text</param> /// <param name="Filter">Predefined filter to use (can be combined as they are flags)</param> /// <returns>The input text minus everything not in the filter text.</returns> public static string Keep(this string Input, StringFilter Filter) { if (string.IsNullOrEmpty(Input)) return ""; var Value = BuildFilter(Filter); return Input.Keep(Value); }
/// <summary> /// Replaces everything that is in the filter text with the value specified. /// </summary> /// <param name="Input">Input text</param> /// <param name="Value">Value to fill in</param> /// <param name="Filter">Predefined filter to use (can be combined as they are flags)</param> /// <returns>The input text with the various items replaced</returns> public static string Replace(this string Input, StringFilter Filter, string Value = "") { if (string.IsNullOrEmpty(Input)) return ""; string FilterValue = BuildFilter(Filter); return new Regex(FilterValue).Replace(Input, Value); }