Exemplo n.º 1
0
        public void DeserializeTypes_ReturnsNullIfTypeNotFound()
        {
            string expectedFormat = @"<?xml version=""1.0"" encoding=""utf-16""?>
<!--This file is automatically generated. Please do not modify the contents of this file.-->
<typeCache lastModified=""__IGNORED__"" mvcVersionId=""{0}"">
  <assembly name=""{1}"">
    <module versionId=""{2}"">
      <type>System.String</type>
      <type>This.Type.Does.Not.Exist</type>
    </module>
  </assembly>
</typeCache>";

            // Arrange
            string expected = String.Format(expectedFormat,
                                            GetMvidForType(typeof(TypeCacheSerializer)) /* mvcVersionId */,
                                            _mscorlibAsmFullName /* assembly.name */,
                                            GetMvidForType(typeof(object)) /* module.versionId */
                                            );

            TypeCacheSerializer serializer = new TypeCacheSerializer();
            StringReader        input      = new StringReader(expected);

            // Act
            List <Type> deserializedTypes = serializer.DeserializeTypes(input);

            // Assert
            Assert.IsNull(deserializedTypes);
        }
Exemplo n.º 2
0
        public void DeserializeTypes_Success()
        {
            // Arrange
            string expected = String.Format(
                _expectedDeserializationFormat,
                GetMvidForType(
                    typeof(TypeCacheSerializer)
                    )                          /* mvcVersionId */
                ,
                _mscorlibAsmFullName           /* assembly.name */
                ,
                GetMvidForType(typeof(object)) /* module.versionId */
                );

            TypeCacheSerializer serializer = new TypeCacheSerializer();
            StringReader        input      = new StringReader(expected);

            Type[] expectedTypes = new Type[] { typeof(string), typeof(object) };

            // Act
            List <Type> deserializedTypes = serializer.DeserializeTypes(input);

            // Assert
            Assert.Equal(expectedTypes, deserializedTypes.ToArray());
        }
        public void DeserializeTypes_ReturnsNullIfMvcVersionIdDoesNotMatch()
        {
            // Arrange
            string expected = String.Format(_expectedDeserializationFormat,
                                            Guid.Empty /* mvcVersionId */,
                                            _mscorlibAsmFullName /* assembly.name */,
                                            GetMvidForType(typeof(object)) /* module.versionId */
                );

            TypeCacheSerializer serializer = new TypeCacheSerializer();
            StringReader input = new StringReader(expected);

            // Act
            List<Type> deserializedTypes = serializer.DeserializeTypes(input);

            // Assert
            Assert.Null(deserializedTypes);
        }
Exemplo n.º 4
0
        public void DeserializeTypes_ReturnsNullIfMvcVersionIdDoesNotMatch()
        {
            // Arrange
            string expected = String.Format(_expectedDeserializationFormat,
                                            Guid.Empty /* mvcVersionId */,
                                            _mscorlibAsmFullName /* assembly.name */,
                                            GetMvidForType(typeof(object)) /* module.versionId */
                                            );

            TypeCacheSerializer serializer = new TypeCacheSerializer();
            StringReader        input      = new StringReader(expected);

            // Act
            List <Type> deserializedTypes = serializer.DeserializeTypes(input);

            // Assert
            Assert.IsNull(deserializedTypes);
        }
        public void DeserializeTypes_Success()
        {
            // Arrange
            string expected = String.Format(_expectedDeserializationFormat,
                                            GetMvidForType(typeof(TypeCacheSerializer)) /* mvcVersionId */,
                                            _mscorlibAsmFullName /* assembly.name */,
                                            GetMvidForType(typeof(object)) /* module.versionId */
                );

            TypeCacheSerializer serializer = new TypeCacheSerializer();
            StringReader input = new StringReader(expected);

            Type[] expectedTypes = new Type[]
            {
                typeof(string),
                typeof(object)
            };

            // Act
            List<Type> deserializedTypes = serializer.DeserializeTypes(input);

            // Assert
            Assert.Equal(expectedTypes, deserializedTypes.ToArray());
        }
        public void DeserializeTypes_ReturnsNullIfTypeNotFound()
        {
            string expectedFormat = @"<?xml version=""1.0"" encoding=""utf-16""?>
<!--This file is automatically generated. Please do not modify the contents of this file.-->
<typeCache lastModified=""__IGNORED__"" mvcVersionId=""{0}"">
  <assembly name=""{1}"">
    <module versionId=""{2}"">
      <type>System.String</type>
      <type>This.Type.Does.Not.Exist</type>
    </module>
  </assembly>
</typeCache>";

            // Arrange
            string expected = String.Format(expectedFormat,
                                            GetMvidForType(typeof(TypeCacheSerializer)) /* mvcVersionId */,
                                            _mscorlibAsmFullName /* assembly.name */,
                                            GetMvidForType(typeof(object)) /* module.versionId */
                );

            TypeCacheSerializer serializer = new TypeCacheSerializer();
            StringReader input = new StringReader(expected);

            // Act
            List<Type> deserializedTypes = serializer.DeserializeTypes(input);

            // Assert
            Assert.Null(deserializedTypes);
        }