コード例 #1
0
        public void Setup()
        {
            _sut = new EventSourcingTestHelper <Account>();

            _smsSenderMock = new Mock <ISmsService>();

            _orderDaoMock   = new Mock <IOrderDao>();
            _serverSettings = new TestServerSettings();
            _serverSettings.SetSetting("TaxiHail.ApplicationName", ApplicationName);
            _serverSettings.SetSetting("SMSConfirmationEnabled", "true");
            _serverSettings.SetSetting("SMSAccountSid", "AC081ad5bacfad6c50e0598052fc062693");
            _serverSettings.SetSetting("SMSAuthToken", "9b142e2d163a5688ada040d8c71e3fb1");
            _serverSettings.SetSetting("SMSFromNumber", "15147002781");

            _sut.Setup(new SmsCommandHandler(new NotificationService(null,
                                                                     null,
                                                                     null,
                                                                     null,
                                                                     _serverSettings,
                                                                     null,
                                                                     _orderDaoMock.Object,
                                                                     null,
                                                                     new StaticMap(),
                                                                     _smsSenderMock.Object,
                                                                     null,
                                                                     null,
                                                                     null,
                                                                     new CryptographyService(WinRTCrypto.CryptographicEngine, WinRTCrypto.SymmetricKeyAlgorithmProvider, WinRTCrypto.HashAlgorithmProvider, new Logger()))));
        }
コード例 #2
0
        public void Setup()
        {
            sut = new EventSourcingTestHelper <Order>();

            _emailSenderMock = new Mock <IEmailSender>();
            _orderDaoMock    = new Mock <IOrderDao>();
            _accountDaoMock  = new Mock <IAccountDao>();
            _serverSettings  = new TestServerSettings();
            _geocodingMock   = new Mock <IGeocoding>();
            var taxihailNetworkServiceClientMock = new Mock <ITaxiHailNetworkServiceClient>();

            taxihailNetworkServiceClientMock
            .Setup(x => x.GetCompanyMarketSettings(It.IsAny <double>(), It.IsAny <double>()))
            .Returns(new CompanyMarketSettingsResponse());
            _serverSettings.SetSetting("TaxiHail.ApplicationName", ApplicationName);

            var notificationService = new NotificationService(() => new BookingDbContext(DbName),
                                                              null,
                                                              new TemplateService(_serverSettings),
                                                              _emailSenderMock.Object,
                                                              _serverSettings,
                                                              new ConfigurationDao(() => new ConfigurationDbContext(DbName)),
                                                              _orderDaoMock.Object,
                                                              _accountDaoMock.Object,
                                                              new StaticMap(),
                                                              null,
                                                              _geocodingMock.Object,
                                                              taxihailNetworkServiceClientMock.Object,
                                                              new Logger(),
                                                              new CryptographyService(WinRTCrypto.CryptographicEngine, WinRTCrypto.SymmetricKeyAlgorithmProvider, WinRTCrypto.HashAlgorithmProvider, new Logger()));

            notificationService.SetBaseUrl(new Uri("http://www.example.net"));

            sut.Setup(new EmailCommandHandler(notificationService));
        }
コード例 #3
0
        public void when_account_registered_then_account_settings_populated()
        {
            var accountId = Guid.NewGuid();

            var accountRegistered = new AccountRegistered
            {
                SourceId = accountId,
                Name     = "Bob",
                Email    = "*****@*****.**",
                Country  = CountryCode.GetCountryCodeByIndex(CountryCode.GetCountryCodeIndexByCountryISOCode("CA")).CountryISOCode,
                Phone    = "555.555.2525",
                Password = new byte[] { 1 }
            };

            Sut.Handle(accountRegistered);

            using (var context = new BookingDbContext(DbName))
            {
                var dto = context.Find <AccountDetail>(accountId);

                Assert.NotNull(dto);
                Assert.AreEqual(dto.Settings.Name, dto.Name);
                Assert.AreEqual(CountryCode.GetCountryCodeByIndex(CountryCode.GetCountryCodeIndexByCountryISOCode("CA")).CountryISOCode.Code, dto.Settings.Country.Code);
                Assert.AreEqual(accountRegistered.Phone, dto.Settings.Phone);


                var config = new TestServerSettings();
                Assert.IsNull(dto.Settings.ChargeTypeId);
                Assert.AreEqual(dto.Settings.Passengers, config.ServerData.DefaultBookingSettings.NbPassenger);
                Assert.IsNull(dto.Settings.VehicleTypeId);
                Assert.IsNull(dto.Settings.ProviderId);
            }
        }
コード例 #4
0
        public void Setup()
        {
            _sut = new EventSourcingTestHelper <Account>();

            _emailSenderMock = new Mock <IEmailSender>();
            _orderDaoMock    = new Mock <IOrderDao>();
            _accountDaoMock  = new Mock <IAccountDao>();
            _serverSettings  = new TestServerSettings();
            _serverSettings.SetSetting("TaxiHail.ApplicationName", ApplicationName);

            var notificationService = new NotificationService(
                () => new BookingDbContext(DbName),
                null,
                new TemplateService(_serverSettings),
                _emailSenderMock.Object,
                _serverSettings,
                new ConfigurationDao(() => new ConfigurationDbContext(DbName)),
                _orderDaoMock.Object,
                _accountDaoMock.Object,
                new StaticMap(),
                null,
                null,
                null,
                new Logger(),
                new CryptographyService(WinRTCrypto.CryptographicEngine, WinRTCrypto.SymmetricKeyAlgorithmProvider, WinRTCrypto.HashAlgorithmProvider, new Logger()));

            notificationService.SetBaseUrl(new Uri("http://www.example.net"));
            _sut.Setup(new EmailCommandHandler(notificationService));
        }
コード例 #5
0
        public void Setup()
        {
            Sut = new EventSourcingTestHelper <Order>();

            EmailSenderMock      = new Mock <IEmailSender>();
            ConfigurationManager = new TestServerSettings();
            TemplateServiceMock  = new Mock <ITemplateService>();

            TemplateServiceMock.Setup(x => x.Render(It.IsAny <string>(), It.IsAny <object>())).Returns("");
            TemplateServiceMock.Setup(x => x.Find(It.IsAny <string>(), It.IsAny <string>())).Returns("");
        }
コード例 #6
0
        public void Setup()
        {
            Commands = new List <ICommand>();

            ConfigurationManager = new TestServerSettings();

            PaymentServiceMock = new Mock <IPaymentService>();
            PaymentServiceMock
            .Setup(x => x.IsPayPal(It.IsAny <Guid?>(), It.IsAny <Guid?>(), It.Is <bool>(o => false)))
            .Returns <Guid?, Guid?, bool>(IsPayPal);
            PaymentServiceMock
            .Setup(x => x.ProviderType(It.IsAny <string>(), It.IsAny <Guid?>()))
            .Returns <string, Guid?>(ProviderType);

            var bus = new Mock <ICommandBus>();

            bus.Setup(x => x.Send(It.IsAny <Envelope <ICommand> >()))
            .Callback <Envelope <ICommand> >(x => Commands.Add(x.Body));
            bus.Setup(x => x.Send(It.IsAny <IEnumerable <Envelope <ICommand> > >()))
            .Callback <IEnumerable <Envelope <ICommand> > >(x => Commands.AddRange(x.Select(e => e.Body)));

            IbsOrderServiceMock = new Mock <IIbsOrderService>();

            NotificationServiceMock = new Mock <INotificationService>();

            LoggerMock = new Mock <ILogger>();
            LoggerMock.Setup(x => x.LogError(It.IsAny <Exception>())).Callback <Exception>(x => Console.WriteLine(x.ToString()));
            LoggerMock.Setup(x => x.LogMessage(It.IsAny <string>(), It.IsAny <object[]>())).Callback <string, object[]>((s, paramobjects) => Console.WriteLine(paramobjects != null ? string.Format(s, paramobjects) : s));

            var accountDao      = new AccountDao(() => new BookingDbContext(DbName));
            var orderDao        = new OrderDao(() => new BookingDbContext(DbName), new TestServerSettings());
            var orderPaymentDao = new OrderPaymentDao(() => new BookingDbContext(DbName));

            var notificationDetailsDaoMock = new Mock <IOrderNotificationsDetailDao>(MockBehavior.Loose);

            Sut = new Jobs.OrderStatusUpdater(ConfigurationManager,
                                              bus.Object,
                                              orderPaymentDao,
                                              orderDao,
                                              NotificationServiceMock.Object,
                                              null,
                                              accountDao,
                                              IbsOrderServiceMock.Object,
                                              new PromotionDao(() => new BookingDbContext(DbName), new SystemClock(), ConfigurationManager, null),
                                              null,
                                              PaymentServiceMock.Object,
                                              new CreditCardDao(() => new BookingDbContext(DbName)),
                                              new FeeService(PaymentServiceMock.Object, accountDao, new FeesDao(() => new BookingDbContext(DbName)), orderDao, orderPaymentDao, bus.Object, ConfigurationManager, LoggerMock.Object),
                                              notificationDetailsDaoMock.Object,
                                              new CmtGeoServiceClient(ConfigurationManager, LoggerMock.Object),
                                              new TaxiHailNetworkServiceClient(new DummyServerSettings()),
                                              LoggerMock.Object);
        }
コード例 #7
0
        public given_a_promotion_view_model_generator()
        {
            var bus = new Mock <ICommandBus>();

            bus.Setup(x => x.Send(It.IsAny <Envelope <ICommand> >()))
            .Callback <Envelope <ICommand> >(x => Commands.Add(x.Body));
            bus.Setup(x => x.Send(It.IsAny <IEnumerable <Envelope <ICommand> > >()))
            .Callback <IEnumerable <Envelope <ICommand> > >(x => Commands.AddRange(x.Select(e => e.Body)));

            var smsSenderMock  = new Mock <ISmsService>();
            var orderDaoMock   = new Mock <IOrderDao>();
            var accountDaoMock = new Mock <IAccountDao>();
            var serverSettings = new TestServerSettings();

            PromoGenerator      = new PromotionDetailGenerator(() => new BookingDbContext(DbName));
            OrderGenerator      = new OrderGenerator(() => new BookingDbContext(DbName), new Logger(), new TestServerSettings());
            CreditCardGenerator = new CreditCardPaymentDetailsGenerator(() => new BookingDbContext(DbName), new TestServerSettings());

            TriggerSut = new PromotionTriggerGenerator(() => new BookingDbContext(DbName), bus.Object,
                                                       new PromotionDao(() => new BookingDbContext(DbName), new SystemClock(), new TestServerSettings(), null), new AccountDao(() => new BookingDbContext(DbName)), new OrderDao(() => new BookingDbContext(DbName), new TestServerSettings()));
        }