示例#1
0
 public void SimpleTypesWrittenCorrectly() {
     var ts = new TypeScriber(new[] { "System" });
     
     Assert.AreEqual("Int32", ts.WriteFullTypeName<int>());
     Assert.AreEqual("Brigita.DtoGen.Test.TypeScriberTests", ts.WriteFullTypeName<TypeScriberTests>());
     Assert.AreEqual("Reflection.Assembly", ts.WriteFullTypeName<System.Reflection.Assembly>());
 }
示例#2
0
        public void NamespacesElided() 
        {
            var types = new[] { 
                                typeof(int),
                                typeof(TypeScriberTests),
                                typeof(System.Reflection.Assembly)
                            };

            var typeScriber = new TypeScriber(types.Select(t => t.Namespace));

            var namespaceHash = new HashSet<string>(types.Select(t => t.Namespace));

            foreach(var @namespace in typeScriber.Namespaces) {
                Assert.IsTrue(namespaceHash.Contains(@namespace));
            }
        }
示例#3
0
        public void ComplexTypesWrittenCorrectly() {
            var namespaces = new[] { 
                                "System",
                                "System.Collections.Generic",
                                "Brigita.Dom"
                            };
            
            var scriber = new TypeScriber(namespaces);

            var tests = new Dictionary<Type, string> { 
                                { typeof(int?), "Nullable<Int32>" }, 
                                { typeof(List<TypeScriberTests>), "List<Brigita.DtoGen.Test.TypeScriberTests>" },
                                { typeof(SortedDictionary<string, float>), "SortedDictionary<String, Single>" },
                                { typeof(byte[]), "Byte[]" },
                                { typeof(float?[]), "Nullable<Single>[]" },
                                { typeof(TypeScriberTests[][][]), "Brigita.DtoGen.Test.TypeScriberTests[][][]" }
                            };
            
            foreach(var test in tests) {
                Assert.AreEqual(test.Value, scriber.WriteFullTypeName(test.Key));
            }
        }