Exemplo n.º 1
0
        public ActionResult EditNode(int id)
        {
            var dr     = new PhoneTypeService().GetOne(id);
            var enList = new PhoneTypeService().GetAll().Where(m => m.TypeId == null).ToList();

            ViewBag.list = new SelectList(enList, "Id", "TypeName");
            return(View(new PhoneTypeVM()
            {
                Id = id, TypeName = dr.TypeName, TypeId = dr.TypeId
            }));
        }
Exemplo n.º 2
0
        public void ConvertModelToEntity_Test()
        {
            // Arrange
            TestKolgraphEntities context = new TestKolgraphEntities();
            var            service       = new PhoneTypeService();
            PhoneTypeModel model         = GetTestModel();

            // Act
            phoneType entity = service.ConvertModelToEntity(model);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual(entity.name, model.Name);
        }
Exemplo n.º 3
0
        public void GetAll_Test()
        {
            // Arrange
            TestKolgraphEntities context = new TestKolgraphEntities();
            var repository = new PhoneTypeRepository(context);
            var service    = new PhoneTypeService(repository);

            // Act
            IEnumerable <PhoneTypeModel> result = service.GetAll();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(context.phoneType.Count(), result.Count());
        }
Exemplo n.º 4
0
        public void GetById_Test()
        {
            // Arrange
            TestKolgraphEntities context = new TestKolgraphEntities();
            var repository = new PhoneTypeRepository(context);
            var service    = new PhoneTypeService(repository);
            int id         = 1;

            // Act
            PhoneTypeModel result = service.GetById(id);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(id, result.Id);
        }
Exemplo n.º 5
0
        public void ConvertEntityToModel_Test()
        {
            // Arrange
            TestKolgraphEntities context = new TestKolgraphEntities();
            //var repository = new PhoneTypeRepository(context);
            var       service = new PhoneTypeService();
            phoneType entity  = context.phoneType.Where(x => x.id == 1).FirstOrDefault();

            // Act
            PhoneTypeModel model = service.ConvertEntityToModel(entity);

            // Assert
            Assert.IsNotNull(model);
            Assert.AreEqual(model.Id, entity.id);
            Assert.AreEqual(model.Name, entity.name);
        }