public async void Can_send_activation_email() { _emailNotificationWorker.Start(); FakeBrandRepository.Brands.First().PlayerActivationMethod = PlayerActivationMethod.Email; FakeBrandRepository.SaveChanges(); await RegisterPlayer(false); var events = FakeEventRepository.GetEvents <NotificationSentEvent>().ToArray(); Assert.That(events.Length, Is.EqualTo(1)); Assert.That(events.First().Type, Is.EqualTo(NotificationType.Email)); }
public void Can_send_brand_message(MessageDeliveryMethod messageDeliveryMethod) { if (messageDeliveryMethod == MessageDeliveryMethod.Email) { _emailNotificationWorker.Start(); } else { _smsNotificationWorker.Start(); } if (messageDeliveryMethod == MessageDeliveryMethod.Email) { MessageTemplateService.TrySendBrandEmail( TestDataGenerator.GetRandomString(), TestDataGenerator.GetRandomEmail(), Brand.Id, MessageType.ReferFriends, new ReferFriendsModel()); } else { MessageTemplateService.TrySendBrandSms( TestDataGenerator.GetRandomString(), TestDataGenerator.GetRandomPhoneNumber(), Brand.Id, MessageType.ReferFriends, new ReferFriendsModel()); } var events = _eventRepository.GetEvents <NotificationSentEvent>().ToArray(); Assert.That(events.Length, Is.EqualTo(1)); var notificationType = messageDeliveryMethod == MessageDeliveryMethod.Email ? NotificationType.Email : NotificationType.Sms; Assert.That(events.First().Type, Is.EqualTo(notificationType)); Assert.That(events.First().Status, Is.EqualTo(NotificationStatus.Send)); }
public void Can_send_email_send_event() { // Arrange _emailNotificationWorker.Start(); var message = new EmailCommandMessage("*****@*****.**", "Fromy Fromerson", "*****@*****.**", "Toto Toterson", "subject", "message"); _serviceBus.PublishMessage(message); var events = _eventRepository.Events.Where(x => x.DataType == typeof(NotificationSentEvent).Name); Assert.IsNotEmpty(events); Assert.AreEqual(1, events.Count()); var notificationSendEvent = JsonConvert.DeserializeObject <NotificationSentEvent>(events.First().Data, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, ReferenceLoopHandling = ReferenceLoopHandling.Serialize }); Assert.AreEqual(notificationSendEvent.Message, message.Body); Assert.AreEqual(notificationSendEvent.Status, NotificationStatus.Send); Assert.AreEqual(notificationSendEvent.Type, NotificationType.Email); }