public void Should_read_JSON_array_into_existing_ICollection_object()
        {
            // Arrange
            var faker = new Faker();

            var elements = faker.Random.WordsArray(10);

            var serializer = new JsonSerializer();

            var jsonBuffer = new StringWriter();

            serializer.Serialize(new JsonTextWriter(jsonBuffer), elements);

            var json = jsonBuffer.ToString();

            var sut = new ConverterImplementation <string>(typeof(AsyncEnumerableList <string>));

            var reader = new JsonTextReader(new StringReader(json));

            reader.Read().Should().BeTrue();
            reader.TokenType.Should().Be(JsonToken.StartArray);

            var existingValue = new AsyncEnumerableList <string>();

            // Act
            var result = sut.ReadJson(reader, existingValue, serializer);

            // Assert
            result.Should().BeSameAs(existingValue);
            existingValue.Should().BeEquivalentTo(elements);
        }
Exemplo n.º 2
0
        public void Should_be_IAsyncEnumerable_T()
        {
            // Arrange
            var sut_int    = new AsyncEnumerableList <int>();
            var sut_string = new AsyncEnumerableList <string>();

            // Assert
            sut_int.Should().BeAssignableTo <IAsyncEnumerable <int> >();
            sut_string.Should().BeAssignableTo <IAsyncEnumerable <string> >();
        }