public void ArgumentChecks() { Assert.Throws <ArgumentNullException>("source", () => GreenJsonBackgroundListSyntax.Create(null)); Assert.Throws <ArgumentOutOfRangeException>("length", () => GreenJsonCommentSyntax.Create(-1)); Assert.Throws <ArgumentOutOfRangeException>("length", () => GreenJsonCommentSyntax.Create(0)); Assert.Throws <ArgumentOutOfRangeException>("length", () => new GreenJsonErrorStringSyntax(0)); Assert.Throws <ArgumentOutOfRangeException>("length", () => new GreenJsonIntegerLiteralSyntax(0, -1)); Assert.Throws <ArgumentNullException>("validKey", () => new GreenJsonKeyValueSyntax(null, EmptyEnumerable <GreenJsonMultiValueSyntax> .Instance)); Assert.Throws <ArgumentNullException>("source", () => new GreenJsonKeyValueSyntax(Maybe <GreenJsonStringLiteralSyntax> .Nothing, null)); Assert.Throws <ArgumentException>("valueSectionNodes", () => new GreenJsonKeyValueSyntax(Maybe <GreenJsonStringLiteralSyntax> .Nothing, EmptyEnumerable <GreenJsonMultiValueSyntax> .Instance)); Assert.Throws <ArgumentNullException>("source", () => new GreenJsonListSyntax(null, false)); Assert.Throws <ArgumentException>("listItemNodes", () => new GreenJsonListSyntax(EmptyEnumerable <GreenJsonMultiValueSyntax> .Instance, false)); Assert.Throws <ArgumentNullException>("source", () => new GreenJsonMapSyntax(null, false)); Assert.Throws <ArgumentException>("keyValueNodes", () => new GreenJsonMapSyntax(EmptyEnumerable <GreenJsonKeyValueSyntax> .Instance, false)); Assert.Throws <ArgumentNullException>("source", () => new GreenJsonMultiValueSyntax(null, GreenJsonBackgroundListSyntax.Empty)); Assert.Throws <ArgumentException>("valueNodes", () => new GreenJsonMultiValueSyntax(EmptyEnumerable <GreenJsonValueWithBackgroundSyntax> .Instance, GreenJsonBackgroundListSyntax.Empty)); Assert.Throws <ArgumentNullException>("backgroundAfter", () => new GreenJsonMultiValueSyntax( new SingleElementEnumerable <GreenJsonValueWithBackgroundSyntax>(new GreenJsonValueWithBackgroundSyntax( GreenJsonBackgroundListSyntax.Empty, GreenJsonMissingValueSyntax.Value)), null)); Assert.Throws <ArgumentNullException>("valueDelimiter", () => new GreenJsonRootLevelValueDelimiterSyntax((GreenJsonCurlyCloseSyntax)null)); Assert.Throws <ArgumentNullException>("valueDelimiter", () => new GreenJsonRootLevelValueDelimiterSyntax((GreenJsonSquareBracketCloseSyntax)null)); Assert.Throws <ArgumentNullException>("value", () => new GreenJsonStringLiteralSyntax(null, 2)); Assert.Throws <ArgumentOutOfRangeException>("length", () => new GreenJsonStringLiteralSyntax(string.Empty, -1)); Assert.Throws <ArgumentOutOfRangeException>("length", () => new GreenJsonUndefinedValueSyntax(0)); Assert.Throws <ArgumentOutOfRangeException>("length", () => new GreenJsonUnterminatedMultiLineCommentSyntax(-1)); Assert.Throws <ArgumentOutOfRangeException>("length", () => new GreenJsonUnterminatedMultiLineCommentSyntax(0)); Assert.Throws <ArgumentNullException>("backgroundBefore", () => new GreenJsonValueWithBackgroundSyntax(null, GreenJsonBooleanLiteralSyntax.False.Instance)); Assert.Throws <ArgumentNullException>("contentNode", () => new GreenJsonValueWithBackgroundSyntax(GreenJsonBackgroundListSyntax.Empty, null)); Assert.Throws <ArgumentOutOfRangeException>("length", () => GreenJsonWhitespaceSyntax.Create(-1)); Assert.Throws <ArgumentOutOfRangeException>("length", () => GreenJsonWhitespaceSyntax.Create(0)); Assert.Throws <ArgumentNullException>("value", () => JsonValue.TryCreate((string)null)); Assert.Throws <ArgumentException>("value", () => JsonValue.TryCreate(string.Empty)); Assert.Throws <ArgumentNullException>("syntax", () => new RootJsonSyntax( null, EmptyEnumerable <JsonErrorInfo> .Instance)); Assert.Throws <ArgumentNullException>("errors", () => new RootJsonSyntax( CreateMultiValue(new GreenJsonIntegerLiteralSyntax(0, 1)), null)); // Both GreenJsonStringLiteralSyntax instances should be the same, and in below test they are not. Assert.Throws <ArgumentException>("validKey", () => new GreenJsonKeyValueSyntax( new GreenJsonStringLiteralSyntax("x", 1), new SingleElementEnumerable <GreenJsonMultiValueSyntax>(CreateMultiValue(new GreenJsonStringLiteralSyntax("x", 1))))); }
public void SharedInstanceHasCorrectLength(int length) { Assert.Equal(length, GreenJsonWhitespaceSyntax.Create(length).Length); Assert.Equal(length, GreenJsonCommentSyntax.Create(length).Length); }
internal JsonCommentSyntax(JsonBackgroundListSyntax parent, int backgroundNodeIndex, GreenJsonCommentSyntax green) : base(parent, backgroundNodeIndex) => Green = green;