Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @SuppressWarnings("unchecked") public void shouldDeserializeMultipleStatements()
        public virtual void ShouldDeserializeMultipleStatements()
        {
            // Given
            string json = createJsonFrom(map("statements", asList(map("statement", "Blah blah", "parameters", map("one", 12)), map("statement", "Blah bluh", "parameters", map("asd", asList("one, two"))))));

            // When
            StatementDeserializer de = new StatementDeserializer(new MemoryStream(UTF8.encode(json)));

            // Then
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertThat(de.HasNext(), equalTo(true));
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            Statement stmt = de.Next();

            assertThat(stmt.StatementConflict(), equalTo("Blah blah"));
            assertThat(stmt.Parameters(), equalTo(map("one", 12)));

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertThat(de.HasNext(), equalTo(true));
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            Statement stmt2 = de.Next();

            assertThat(stmt2.StatementConflict(), equalTo("Blah bluh"));
            assertThat(stmt2.Parameters(), equalTo(map("asd", asList("one, two"))));

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertThat(de.HasNext(), equalTo(false));
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldIgnoreUnknownFields()
        public virtual void ShouldIgnoreUnknownFields()
        {
            // Given
            string json = "{ \"statements\" : [ { \"a\" : \"\", \"b\" : { \"k\":1 }, \"statement\" : \"blah\" } ] }";

            // When
            StatementDeserializer de = new StatementDeserializer(new MemoryStream(UTF8.encode(json)));

            // Then
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertThat(de.HasNext(), equalTo(true));

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertThat(de.Next().statement(), equalTo("blah"));
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertThat(de.HasNext(), equalTo(false));
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldTakeParametersBeforeStatement()
        public virtual void ShouldTakeParametersBeforeStatement()
        {
            // Given
            string json = "{ \"statements\" : [ { \"a\" : \"\", \"parameters\" : { \"k\":1 }, \"statement\" : \"blah\"}]}";

            // When
            StatementDeserializer de = new StatementDeserializer(new MemoryStream(UTF8.encode(json)));

            // Then
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertThat(de.HasNext(), equalTo(true));

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            Statement stmt = de.Next();

            assertThat(stmt.StatementConflict(), equalTo("blah"));
            assertThat(stmt.Parameters(), equalTo(map("k", 1)));

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertThat(de.HasNext(), equalTo(false));
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldTotallyIgnoreInvalidJsonAfterStatementArrayHasFinished()
        public virtual void ShouldTotallyIgnoreInvalidJsonAfterStatementArrayHasFinished()
        {
            // NOTE: We don't really want this behaviour, but it's a symptom of keeping
            // streaming behaviour while moving the statement list into a map.

            // Given
            string json = "{ \"statements\" : [ { \"statement\" : \"Blah blah\", \"parameters\" : {\"one\" : 12}} ] " +
                          "totally invalid json is totally ignored";

            // When
            StatementDeserializer de = new StatementDeserializer(new MemoryStream(UTF8.encode(json)));

            // Then
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertThat(de.HasNext(), equalTo(true));
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            Statement stmt = de.Next();

            assertThat(stmt.StatementConflict(), equalTo("Blah blah"));

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertThat(de.HasNext(), equalTo(false));
        }