Beispiel #1
0
        public void CreateInstance_Return_Valid_Result()
        {
            Exception obj = null;

            Assert.That(() => obj = ClassUtil.CreateInstance <Exception>(), Throws.Nothing);
            Assert.That(obj, Is.Not.Null);
            Assert.That(obj, Is.TypeOf <Exception>());
        }
Beispiel #2
0
        public void CreateInstance_By_Type_Return_Valid_Result()
        {
            Type      type = typeof(Exception);
            Exception obj  = null;

            Assert.That(() => obj = (Exception)ClassUtil.CreateInstance(type), Throws.Nothing);
            Assert.That(obj, Is.Not.Null);
            Assert.That(obj, Is.TypeOf(type));
        }
Beispiel #3
0
        public ActionResult Create(BuildingVM vm)
        {
            if (ModelState.IsValid)
            {
                var concretBuilding = ClassUtil.CreateInstance(ClassUtil.CONCRET_BUILDINGS + vm.BuildingType) as Building;
                concretBuilding.Id    = vm.Building.Id;
                concretBuilding.Name  = vm.Building.Name;
                concretBuilding.Level = vm.Building.Level;

                db.Buildings.Add(concretBuilding);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(vm));
        }
Beispiel #4
0
 public void CreateInstance_Throws_ArgumentNullException()
 {
     AssertThrowsException <ArgumentNullException>(() => ClassUtil.CreateInstance(null), "type");
 }