示例#1
0
        public ActionResult Create(SessionTopicViewModel sessionTopicViewModel)
        {
            if (ModelState.IsValid)
            {
                var result = Mapper.Map <SessionTopicViewModel, SessionTopic>(sessionTopicViewModel);
                _SessionTopicService.Create(result);

                return(RedirectToAction("Index"));
            }

            return(View(sessionTopicViewModel));
        }
示例#2
0
        public void CanAddSessionTopic()
        {
            //Arrange
            int          id  = 1;
            SessionTopic emp = new SessionTopic()
            {
                Name = "UK"
            };

            _mockRepository.Setup(m => m.Add(emp)).Returns((SessionTopic e) =>
            {
                e.Id = id;
                return(e);
            });


            //Act
            _service.Create(emp);

            //Assert
            Assert.AreEqual(id, emp.Id);
            _mockUnitWork.Verify(m => m.Commit(), Times.Once);
        }