/// <summary> /// Checks that parsing a string and then converting back to string gives the same string /// </summary> /// <param name="scopeName">String to be parsed and converted back</param> private void CheckRoundTrip(string scopeName) { TimedScopeName parsed; if (VerifyTrueAndReturn(TimedScopeName.TryParse(scopeName, out parsed))) { Assert.Equal(parsed.ToString(), scopeName); } }
public void Verify_MalformedScopeNames_NotParsed() { TimedScopeName scopeName; Assert.False(TimedScopeName.TryParse(null, out scopeName), "Malformed scope name should not be parsed"); Assert.False(TimedScopeName.TryParse("", out scopeName), "Malformed scope name should not be parsed"); Assert.False(TimedScopeName.TryParse("/x", out scopeName), "Malformed scope name should not be parsed"); Assert.False(TimedScopeName.TryParse("/x/y", out scopeName), "Malformed scope name should not be parsed"); Assert.False(TimedScopeName.TryParse("x/y/z/a", out scopeName), "Malformed scope name should not be parsed"); }
/// <summary> /// Verifies that parsing the same string (even with changed letter casing) gives equal TimedScopeName instances /// </summary> /// <param name="scopeName">The string to be parsed</param> private void CheckSingleScope(string scopeName) { TimedScopeName parsed1; TimedScopeName parsed2; if (VerifyTrueAndReturn(TimedScopeName.TryParse(scopeName, out parsed1)) && VerifyTrueAndReturn(TimedScopeName.TryParse(scopeName, out parsed2))) { CheckHashCodesAndEquality(parsed1, parsed2); } }
public void Verify_ValidScopeNames_Parsed() { TimedScopeName scopeName; if (VerifyTrueAndReturn(TimedScopeName.TryParse(OnlyScope, out scopeName))) { Assert.Equal(TestScope, scopeName.Scope); Assert.Equal(null, scopeName.SubType); Assert.Equal(null, scopeName.MetaData); } if (VerifyTrueAndReturn(TimedScopeName.TryParse(ScopeWithSubtype, out scopeName))) { Assert.Equal(TestScope, scopeName.Scope); Assert.Equal(TestSubtype, scopeName.SubType); Assert.Equal(null, scopeName.MetaData); } if (VerifyTrueAndReturn(TimedScopeName.TryParse(ScopeWithMetadata, out scopeName, preferMetaData: true))) { Assert.Equal(TestScope, scopeName.Scope); Assert.Equal(null, scopeName.SubType); Assert.Equal(TestMetadata, scopeName.MetaData); } if (VerifyTrueAndReturn(TimedScopeName.TryParse(ScopeWithSubtypeAndMetadata, out scopeName))) { Assert.Equal(TestScope, scopeName.Scope); Assert.Equal(TestSubtype, scopeName.SubType); Assert.Equal(TestMetadata, scopeName.MetaData); } if (VerifyTrueAndReturn(TimedScopeName.TryParse(ScopeWithEmptySubtype, out scopeName))) { Assert.Equal(TestScope, scopeName.Scope); Assert.Equal(string.Empty, scopeName.SubType); Assert.Equal(null, scopeName.MetaData); } if (VerifyTrueAndReturn(TimedScopeName.TryParse(ScopeWithEmptySubtypeAndMetadata, out scopeName))) { Assert.Equal(TestScope, scopeName.Scope); Assert.Equal(string.Empty, scopeName.SubType); Assert.Equal(TestMetadata, scopeName.MetaData); } }