Beispiel #1
0
        public void CopyCtorTest()
        {
            MethodTest tmp = new MethodTest();
            SerializationMethodMetadata sut = new SerializationMethodMetadata(tmp);

            Assert.IsTrue(tmp.Name.Equals(sut.Name));
            Assert.AreEqual(tmp.SavedHash, sut.SavedHash);
            Assert.AreEqual(tmp.Parameters.Count(), sut.Parameters.Count());
            Assert.IsNull(sut.GenericArguments);
            Assert.IsNull(sut.Modifiers);
            Assert.IsFalse(sut.IsExtension);
            Assert.IsTrue(tmp.ReturnType.Name.Equals(sut.ReturnType.Name));
        }
Beispiel #2
0
        public void DeepMappingTest()
        {
            AssemblyTest assemblyMetadata = new AssemblyTest {
                Name = "test0", SavedHash = 0
            };
            NamespaceTest namespaceMeta1 = new NamespaceTest {
                Name = "test1", SavedHash = 1
            };
            NamespaceTest namespaceMeta2 = new NamespaceTest {
                Name = "test2", SavedHash = 2
            };
            TypeTest type1 = new TypeTest {
                Name = "Type1", SavedHash = 3
            };

            type1.Properties = new[] { new PropertyTest {
                                           Name = "prop", MyType = type1, SavedHash = 4
                                       } };
            type1.Attributes = new[] { new AttributeTest {
                                           Name = "attr", SavedHash = 5
                                       } };
            MethodTest method1 = new MethodTest
            {
                Name       = "method1",
                SavedHash  = 6,
                Parameters = new[] { new ParameterTest {
                                         Name = "param1", MyType = type1, SavedHash = 7
                                     } }
            };

            type1.Methods               = new[] { method1 };
            namespaceMeta1.Types        = new[] { type1 };
            assemblyMetadata.Namespaces = new[] { namespaceMeta1, namespaceMeta2 };
            SerializationAssemblyMetadata sut = new SerializationAssemblyMetadata(assemblyMetadata);

            Assert.AreEqual(2, sut.Namespaces.Count());
            Assert.AreEqual(1, sut.Namespaces.First().Types.Count());
            Assert.AreEqual(1, sut.Namespaces.First().Types.First().Methods.Count());
            Assert.AreEqual(1, sut.Namespaces.First().Types.First().Properties.Count());
            Assert.AreEqual(1, sut.Namespaces.First().Types.First().Attributes.Count());
            Assert.AreEqual(1, sut.Namespaces.First().Types.First().Methods.First().Parameters.Count());
        }