示例#1
0
        public void Get_All_API()
        {
            //Arrange
            activityServiceMock.Setup(x => x.GetAll()).Returns(items);

            //Act
            var actionResult  = controllerAPI.Get();
            var createdResult = actionResult as OkNegotiatedContentResult <IEnumerable <Activity> >;

            //Assert
            Assert.IsNotNull(createdResult);
            Assert.IsInstanceOfType(createdResult.Content, typeof(IEnumerable <Activity>));
            Assert.AreEqual(items, createdResult.Content);
        }
        public void ActivityController_Get()
        {
            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                Mock <IActivity> actionMock = new Mock <IActivity>();
                actionMock.Setup(a => a.GetById(It.IsAny <IUnitOfWork>(), It.IsAny <Guid>()));
                actionMock.Setup(x => x.Exists(It.IsAny <Guid>())).Returns(true);

                ActivityDO activityDO = new FixtureData(uow).TestActivity3();
                var        controller = new ActivitiesController(actionMock.Object, ObjectFactory.GetInstance <IActivityTemplate>(), ObjectFactory.GetInstance <IPlan>(), ObjectFactory.GetInstance <IUnitOfWorkFactory>());
                controller.Get(activityDO.Id);
                actionMock.Verify(a => a.GetById(It.IsAny <IUnitOfWork>(), activityDO.Id));
            }
        }