예제 #1
0
            public void CanConvert_Generic_Collection_Of_Strings(Type collectionType)
            {
                // Arrange
                var converter = new ProjectVersionConverter();

                // Act
                var result = converter.CanConvert(collectionType);

                // Assert
                Assert.True(result);
            }
예제 #2
0
            public void Writes_Null_To_String()
            {
                // Arrange
                var result    = new StringBuilder();
                var converter = new ProjectVersionConverter();

                using (var writer = new JsonTextWriter(new StringWriter(result)))
                {
                    // Act
                    converter.WriteJson(writer, null, new JsonSerializer());
                }

                // Assert
                Assert.Equal("\"[]\"", result.ToString());
            }
예제 #3
0
            public void Writes_Collection_To_String()
            {
                // Arrange
                var result    = new StringBuilder();
                var converter = new ProjectVersionConverter();

                using (var writer = new JsonTextWriter(new StringWriter(result)))
                {
                    // Act
                    converter.WriteJson(writer, new List <string> {
                        "0.0.1", "0.0.2"
                    }, new JsonSerializer());
                }

                // Assert
                Assert.Equal("\"[0.0.1, 0.0.2]\"", result.ToString());
            }
예제 #4
0
            public void Reads_Empty_String_To_Collection()
            {
                // Arrange
                List <string> result;
                var           converter = new ProjectVersionConverter();

                using (var reader = new JsonTextReader(new StringReader("\"\"")))
                {
                    reader.Read();

                    // Act
                    result = converter.ReadJson(reader, typeof(ICollection <string>),
                                                new List <string>(), new JsonSerializer()) as List <string>;
                }

                // Assert
                Assert.NotNull(result);
                Assert.Empty(result);
            }
예제 #5
0
            public void Reads_String_To_Collection()
            {
                // Arrange
                List <string> result;
                var           converter = new ProjectVersionConverter();

                using (var reader = new JsonTextReader(new StringReader("\"[0.0.1, 0.0.2  ]\"")))
                {
                    reader.Read();

                    // Act
                    result = converter.ReadJson(reader, typeof(ICollection <string>),
                                                new List <string>(), new JsonSerializer()) as List <string>;
                }

                // Assert
                Assert.NotNull(result);
                Assert.Equal(2, result.Count);
                Assert.Equal("0.0.1", result[0]);
                Assert.Equal("0.0.2", result[1]);
            }