示例#1
0
        public void UpdateInvalid()
        {
            Request entity     = CreateEntity();
            Guid    entityGuid = GetId(entity);
            var     mock       = new Mock <IRequestRepository <Request, TypeEntity> >(MockBehavior.Strict);

            mock.Setup(m => m.Get(entityGuid)).Throws(new ExceptionController());

            var controller = new RequestLogic(mock.Object);

            Assert.ThrowsException <ExceptionController>(() => controller.Update(entity));
            mock.VerifyAll();
        }
示例#2
0
        public void UpdateCorrect()
        {
            Request entity = CreateEntity();
            var     mock   = new Mock <IRequestRepository <Request, TypeEntity> >(MockBehavior.Strict);

            mock.Setup(m => m.Get(GetId(entity))).Returns(entity);
            mock.Setup(m => m.Update(ModifyEntity(entity)));
            mock.Setup(m => m.Save());

            var controller = new RequestLogic(mock.Object);

            controller.Update(entity);
            mock.VerifyAll();
        }