public void IsMatchTest_PossibleIssueWithAddressPatternWildcard5() { string addressPattern = "/?*test"; string address = "/1_test"; Assert.IsTrue(OscAddress.IsMatch(addressPattern, address)); }
public void IsMatchTest_PossibleIssueWithAddressPatternWildcard8() { string addressPattern = "/???test??"; string address = "/test"; Assert.IsFalse(OscAddress.IsMatch(addressPattern, address)); }
public void IsMatchTest_LiteralMatch() { string addressPattern = "/container_A/method_A"; string address = "/container_A/method_A"; Assert.True(OscAddress.IsMatch(addressPattern, address)); }
public void IsMatchTest_PossibleIssueWithAddressPatternWildcard10() { string addressPattern = "/???test*?"; string address = "/123test9"; Assert.IsTrue(OscAddress.IsMatch(addressPattern, address)); }
public string ReadAddress(bool validate) { OscSerializationToken token = ReadNextToken(out string value); if (token != OscSerializationToken.Literal) { throw new OscException(OscError.ErrorParsingOscAdress, $"Unexpected serialization token {token}"); } string address = value.Trim(); if (validate != true) { return(address); } if (string.IsNullOrWhiteSpace(address)) { throw new Exception("Address was empty"); } if (OscAddress.IsValidAddressPattern(address) == false) { throw new Exception("Invalid address"); } return(address); }
public void IsMatchTest_LiteralMissmatch2() { string addressPattern = "/container_A/method_A"; string address = "/container_B/method_A"; Assert.IsFalse(OscAddress.IsMatch(addressPattern, address)); }
public void Match_NonMatchingAddressAndPattern_False(string addressString, string patternString) { var sut = new Interpreter(new Lexer()); var address = new OscAddress(addressString); var pattern = new OscAddressPattern(patternString); Assert.False(sut.Match(address, pattern)); }
void Ctor_StringWithTrailingSlash_EmptySegment() { var sut = new OscAddress("/abc/"); Assert.Collection(sut.Segments, segment => Assert.Equal("abc", segment), segment => Assert.Equal("", segment)); }
public void IsValid_BasicAddress_True() { var sut = new OscAddress("/abc"); var result = sut.IsValid(out var messages); Assert.True(result); Assert.Empty(messages); }
void Ctor_StringWithConsecutiveSlashes_EmptySegments() { var sut = new OscAddress("/a//bc"); Assert.Collection(sut.Segments, segment => Assert.Equal("a", segment), segment => Assert.Equal("", segment), segment => Assert.Equal("bc", segment)); }
public static void CreateAddresses(int count) { int length = StaticObjects.Good_AddressPatterns.Length; for (int i = 0; i < count; i++) { OscAddress address = new OscAddress(StaticObjects.Good_AddressPatterns[i % length]); } }
void Ctor_StringWithMultipleSlashes_MultipleSegments() { var sut = new OscAddress("/a/b/c"); Assert.Collection(sut.Segments, segment => Assert.Equal("a", segment), segment => Assert.Equal("b", segment), segment => Assert.Equal("c", segment)); }
private void Button_Click(object sender, RoutedEventArgs e) { var controls = OscAddress.GetChildrenWithValue(this); this.Vm = new SynthViewModel(controls); this.DataContext = Vm; Vm.Parent = this.Parent as Window; Vm.Initialize(); }
public void IsValid_EmptySegment_False() { var sut = new OscAddress("/a//bc"); var result = sut.IsValid(out var messages); Assert.False(result); Assert.Collection(messages, m => Assert.Equal("1: Segment cannot be empty.", m)); }
public void OscAddress_Constructor_Good() { for (int i = 0; i < UnitTestHelper.Good_AddressPatterns.Length; i++) { string address = UnitTestHelper.Good_AddressPatterns[i]; OscAddress result = new OscAddress(address); Assert.AreEqual(address, result.ToString_Rebuild(), String.Format("Failed to parse address pattern {0} '{1}'", i, address)); } }
public void IsValidAddressPatternTest_Good() { for (int i = 0; i < UnitTestHelper.Good_AddressPatterns.Length; i++) { string address = UnitTestHelper.Good_AddressPatterns[i]; bool result = OscAddress.IsValidAddressPattern(address); Assert.True(result, $"Failed to validate address pattern {i} '{address}'"); } }
public void IsValidAddressPatternTest_Good() { for (int i = 0; i < UnitTestHelper.Good_AddressPatterns.Length; i++) { string address = UnitTestHelper.Good_AddressPatterns[i]; bool result = OscAddress.IsValidAddressPattern(address); Assert.IsTrue(result, String.Format("Failed to validate address pattern {0} '{1}'", i, address)); } }
public void IsValidAddressPatternTest_Bad() { for (int i = 0; i < UnitTestHelper.Bad_AddressPatterns.Length; i++) { string address = UnitTestHelper.Bad_AddressPatterns[i]; bool result = OscAddress.IsValidAddressPattern(address); Assert.False(result, $"Incorrectly validated address pattern {i} '{address}'"); } }
public void OscAddress_Constructor_Good() { for (int i = 0; i < UnitTestHelper.Good_AddressPatterns.Length; i++) { string address = UnitTestHelper.Good_AddressPatterns[i]; OscAddress result = new OscAddress(address); Assert.AreEqual(address, result.ToString(), $"Failed to parse address pattern {i} '{address}'"); } }
private void SetModuleAddress() { var children = OscAddress.GetChildrenWithValue(this); foreach (var child in children) { var currentVal = OscAddress.GetAddress(child.Key); var newVal = currentVal.Replace("*", moduleAddress); OscAddress.SetAddress(child.Key, newVal); } }
public void IsValidAddressPatternTest_Bad() { for (int i = 0; i < UnitTestHelper.Bad_AddressPatterns.Length; i++) { string address = UnitTestHelper.Bad_AddressPatterns[i]; bool result = OscAddress.IsValidAddressPattern(address); Assert.IsFalse(result, String.Format("Incorrectly validated address pattern {0} '{1}'", i, address)); } }
public static string RebuildOscAddress(OscAddress address) { StringBuilder sb = new StringBuilder(); foreach (OscAddressPart part in address) { sb.Append(part.Interpreted); } return(sb.ToString()); }
private void ListenerAddress_TextChanged(object sender, EventArgs e) { // try to parse the osc address literal if (OscAddress.IsValidAddressPattern(m_ListenerAddress.Text) == true) { // if it parsed ok then green m_ListenerAddress.BackColor = Color.LightGreen; } else { // if there was a problem parsing the address then red (pink) m_ListenerAddress.BackColor = Color.Pink; } }
static StaticObjects() { #region Parsed_Addresses Parsed_Addresses = new OscAddress[StaticObjects.Good_AddressPatterns.Length]; for (int i = 0; i < Parsed_Addresses.Length; i++) { Parsed_Addresses[i] = new OscAddress(StaticObjects.Good_AddressPatterns[i]); } #endregion #region Parsed_AddressPatternMatches Parsed_AddressPatternMatches = new OscAddress[StaticObjects.Good_AddressPatternMatches.Length]; for (int i = 0; i < Parsed_AddressPatternMatches.Length; i++) { Parsed_AddressPatternMatches[i] = new OscAddress(StaticObjects.Good_AddressPatternMatches[i]); } #endregion All_Addresses = new string[StaticObjects.Good_AddressPatterns.Length + StaticObjects.Good_AddressPatternMatches.Length]; for (int i = 0; i < Good_AddressPatterns.Length; i++) { All_Addresses[i] = StaticObjects.Good_AddressPatterns[i]; } for (int i = 0; i < Good_AddressPatternMatches.Length; i++) { All_Addresses[StaticObjects.Good_AddressPatterns.Length + i] = StaticObjects.Good_AddressPatternMatches[i]; } Parsed_Messages = new OscMessage[All_Addresses.Length]; for (int i = 0; i < All_Addresses.Length; i++) { Parsed_Messages[i] = new OscMessage(StaticObjects.All_Addresses[i]); } Mananger = new OscAddressManager(); for (int i = 0; i < Good_AddressPatterns.Length; i++) { Mananger.Attach(StaticObjects.Good_AddressPatterns[i], DummyMethod); } }
public void AddressPatternMatches() { for (int i = 0; i < UnitTestHelper.Good_AddressPatterns.Length; i++) { string pattern = UnitTestHelper.Good_AddressPatterns[i]; string address = UnitTestHelper.Good_AddressPatternMatches[i]; OscAddress target = new OscAddress(pattern); bool result = target.Match(address); Assert.IsTrue(result, String.Format("Failed to match address pattern {0} '{1}' to '{2}'", i, pattern, address)); } }
public void IsValid_IllegalCharsSegment_False() { var sut = new OscAddress("/a /b#*,?[]{}"); var result = sut.IsValid(out var messages); Assert.False(result); Assert.Collection(messages, m => Assert.Equal("0: Segment may not contain ' '.", m), m => Assert.Equal("1: Segment may not contain '#'.", m), m => Assert.Equal("1: Segment may not contain '*'.", m), m => Assert.Equal("1: Segment may not contain ','.", m), m => Assert.Equal("1: Segment may not contain '?'.", m), m => Assert.Equal("1: Segment may not contain '['.", m), m => Assert.Equal("1: Segment may not contain ']'.", m), m => Assert.Equal("1: Segment may not contain '{'.", m), m => Assert.Equal("1: Segment may not contain '}'.", m)); }
public bool Match(OscAddress oscAddress, OscAddressPattern pattern) { if (oscAddress.Segments.Length != pattern.Segments.Length) { return(false); } for (var i = 0; i < oscAddress.Segments.Length; i++) { var tokens = lexer.GetTokens(pattern.Segments[i]); var regex = GetRegex(tokens); if (!regex.IsMatch(oscAddress.Segments[i])) { return(false); } } return(true); }
/// <summary> /// Construct a OSC message /// </summary> /// <param name="origin">the origin of the OSC message</param> /// <param name="address">An OSC address that is the destination for this message</param> /// <param name="args"> /// Object array of OSC argument values. The type tag string will be created automatically according to /// each argument type /// </param> /// <example>OscMessage message = new OscMessage("/test/test", 1, 2, 3);</example> public OscMessage(Uri origin, string address, params object[] args) { Origin = origin; Address = address; arguments = args; if (string.IsNullOrWhiteSpace(Address)) { throw new ArgumentNullException(nameof(address)); } if (OscAddress.IsValidAddressPattern(address) == false) { throw new ArgumentException($"The address '{address}' is not a valid osc address", nameof(address)); } if (args == null) { throw new ArgumentNullException(nameof(args)); } CheckArguments(arguments); }
private void SetIndex() { int index = StartIndex; foreach (var childP in RoutesStackPanel.Children) { var childPanel = childP as StackPanel; if (childPanel == null) { continue; } var children = OscAddress.GetChildrenWithValue(childPanel); foreach (var child in children) { var currentVal = OscAddress.GetAddress(child.Key); var newVal = currentVal.Replace("*", index.ToString()); OscAddress.SetAddress(child.Key, newVal); } index++; } }
internal OscPatternEvent(OscAddress address) { Address = address; Event = null; }