Exemple #1
0
        public void SmsUsesNexmo()
        {
            _docSession.Expect(d => d.Load <SmsProviderConfiguration>("SmsProviderConfiguration")).Return(_nexmoProvider);

            var messageToSend = new SendOneMessageNow {
                SmsData = new SmsData("mobile", "message")
            };
            var nexmoWrapper = MockRepository.GenerateMock <INexmoWrapper>();
            var smsService   = new SmsService {
                NexmoWrapper = nexmoWrapper, RavenDocStore = _ravenDocStore
            };

            nexmoWrapper.Expect(t => t.SendSmsMessage(messageToSend.SmsData.Mobile, messageToSend.SmsData.Message));

            smsService.Send(messageToSend);
            nexmoWrapper.VerifyAllExpectations();
        }
        public void SetUp()
        {

            //Arrange
            parent = new Parent
            {
                Id = "vincent-1",
                Name = "Vincent from repository",
                Child = new Child
                {
                    Id = "jasper-6",
                    Name = "Jasper from repository"
                }
            };

            session = M<IDocumentSession>();
            session.Expect(r => r.Load<Parent>(parent.Id)).Return(parent);
            session.Expect(r => r.Load<Child>(parent.Child.Id)).Return(parent.Child);

            request = S<HttpRequestBase>();
            controllerContext = new ControllerContext
            {
                HttpContext = S<HttpContextBase>()
            };
            controllerContext.HttpContext.Stub(x => x.Request).Return(request);

            entityModelBinder = new EntityModelBinder<Parent>(session);
            entityModelBinder.SetModelBinderDictionary(new ModelBinderDictionary { DefaultBinder = entityModelBinder });

            var validatorProvider = M<ModelValidatorProvider>();

            var locator = M<IServiceLocator>();
            ServiceLocator.SetLocatorProvider(() => locator);
            locator.Expect(l => l.GetAllInstances(typeof(IModelBinderProvider))).Return(new List<IModelBinderProvider> { new ConventionModelBinderProvider() });
            locator.Expect(l => l.GetAllInstances(typeof(ModelValidatorProvider))).Return(new List<ModelValidatorProvider> { validatorProvider });

            ModelBinderProviders.BinderProviders.Add(new ConventionModelBinderProvider());

            DependencyResolver.SetResolver(new ServiceLocatorDependencyResolver());
        }