public void SetUp()
 {
     // Cleanup after other test runs
     // Using setup rather than teardown to make it easier to inspect the database after running a test.
     using (var context = new MagicContext())
     {
         context.Database.Delete();
     }
 }
Exemplo n.º 2
0
 public void DoesStuff()
 {
     using (var context = new MagicContext())
     {
         var actual = context.PeskyWabbits.First();
         Assert.AreEqual("Roger", actual.Name);
         Assert.AreEqual(Ears.Pointy, actual.TehEars);
         Assert.AreEqual(1, context.PeskyWabbits.Count()); // spot unwanted re-use of db
     }
 }
Exemplo n.º 3
0
 public void UsesDescriptionAttribute()
 {
     using (var context = new MagicContext())
     {
         const string sql = "select @desciption = name from Enum_Importance where id = @id";
         var idParam = new SqlParameter("id", (int)Importance.NotBovverd);
         var outParam = new SqlParameter("desciption", SqlDbType.NVarChar, 255) { Direction = ParameterDirection.Output };
         context.Database.ExecuteSqlCommand(sql, idParam, outParam);
         var actualName = outParam.Value;
         Assert.AreEqual(Constants.BovveredDisplay, actualName);
     }
 }
Exemplo n.º 4
0
 public void IgnoresRuntimeValues()
 {
     using (var context = new MagicContext())
     {
         const int prototypeId = (int)Ears.Prototype;
         const string sql = "select @count = count(*) from Enum_Ears where id = @id";
         var idParam = new SqlParameter("id", prototypeId);
         var outParam = new SqlParameter("count", SqlDbType.Int) { Direction = ParameterDirection.Output };
         context.Database.ExecuteSqlCommand(sql, idParam, outParam);
         var matches = outParam.Value;
         Assert.AreEqual(0, matches, string.Format("Runtime only value '{1}' shouldn't be in db. Enum_Ears id {0}", prototypeId, Ears.Prototype));
     }
 }
		private static void TestConfig(string testSql, EnumToLookup enumToLookup)
		{
			Database.SetInitializer(new TestInitializer(enumToLookup));
			using (var context = new MagicContext())
			{
				var roger = new Rabbit { Name = "Roger", TehEars = Ears.Pointy };
				context.PeskyWabbits.Add(roger);
				context.SaveChanges();

				// assert
				context.Database.ExecuteSqlCommand(testSql); // should explode if anything is wrong
			}
		}
Exemplo n.º 6
0
        public void SetUp()
        {
            // Cleanup after other test runs
            // Using setup rather than teardown to make it easier to inspect the database after running a test.
            using (var context = new MagicContext())
            {
                context.Database.Delete();
            }

            Database.SetInitializer(new TestInitializer(new EnumToLookup()));
            using (var context = new MagicContext())
            {
                var roger = new Rabbit { Name = "Roger", TehEars = Ears.Pointy };
                context.PeskyWabbits.Add(roger);
                context.SaveChanges();
            }
        }
		public void FindsReferences()
		{
			IList<EnumReference> references;
			using (var context = new MagicContext())
			{
				references = _enumToLookup.FindEnumReferences(context);
			}
			var legs = references.SingleOrDefault(r => r.ReferencingField == "SpeedyLegs");
			Assert.IsNotNull(legs, "SpeedyLegs ref not found");
			var ears = references.SingleOrDefault(r => r.ReferencingField == "TehEars");
			Assert.IsNotNull(ears, "TehEars ref not found");
			var echos = references.SingleOrDefault(r => r.ReferencingField == "EchoType");
			Assert.IsNotNull(echos, "EchoType ref not found");
			var eons = references.Count(r => r.EnumType == typeof(Eon));
			Assert.AreEqual(2, eons, "Wrong number of Eon refs found");
			Assert.IsTrue(references.All(r => r.EnumType.IsEnum), "Non-enum type found");
			Assert.AreEqual(13, references.Count);
		}