Exemplo n.º 1
0
        public static void Init(TestContext tc)
        {
            Contract.ContractFailed += (sender, e) =>
            {
                e.SetUnwind();
                Assert.Fail(e.FailureKind.ToString() + ":" + e.Message);
            };

            Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0");
            Database.SetInitializer(new DropCreateDatabaseAlways <CSharpStructure>());

            using (var cx = new CSharpStructure())
            {
                var types = new[]
                {
                    new Type {
                        Name = "Int32"
                    },
                    new Type {
                        Name = "String"
                    },
                    new Type {
                        Name = "ListOfT"
                    },
                    new Type {
                        Name = "DictionaryOfTOfT"
                    },
                };
                foreach (var item in types)
                {
                    cx.Types.Add(item);
                }

                var methods = new[]
                {
                    new Method {
                        Name = "CompareTo", Type = types[0]
                    },
                    new Method {
                        Name = "StartsWith", Type = types[1]
                    },
                    new Method {
                        Name = "EndsWith", Type = types[1]
                    },
                    new Method {
                        Name = "Contains", Type = types[1]
                    },
                    new Method {
                        Name = "TrueForAll", Type = types[2]
                    },
                    new Method {
                        Name = "ForEach", Type = types[2]
                    },
                    new Method {
                        Name = "ContainsKey", Type = types[3]
                    },
                    new Method {
                        Name = "TryGetValue", Type = types[3]
                    },
                };
                foreach (var item in methods)
                {
                    cx.Methods.Add(item);
                }

                cx.SaveChanges();
            }
        }
Exemplo n.º 2
0
        public static void Setup(TestContext tc)
        {
            var connStr = new CSharpStructure().Database.Connection.ConnectionString;

            connectionFactory = () => new SqlCeConnection(connStr);
        }