AirTNG.Web.Domain.Reservations.Notifier.SendNotificationAsync C# (CSharp) Метод

SendNotificationAsync() публичный Метод

public SendNotificationAsync ( Reservation reservation ) : Task
reservation AirTNG.Web.Models.Reservation
Результат Task
        public async Task<Message> SendNotificationAsync(Reservation reservation)
        {
            var pendingReservations = await _repository.FindPendingReservationsAsync();
            if (pendingReservations.Count() > 1) return null;

            var notification = BuildNotification(reservation);
            return _client.SendMessage(notification.From, notification.To, notification.Messsage);
        }

Usage Example

Пример #1
0
        public async void WhenThereAreMoreThanOneReservation_ThenAnyMessageIsSent()
        {
            var mockClient = new Mock<TwilioRestClient>(null, null);
            mockClient
                .Setup(c => c.SendMessage(
                    It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()));
            var mockRepository = new Mock<IReservationsRepository>();
            mockRepository
                .Setup(r => r.FindPendingReservationsAsync())
                .ReturnsAsync(new List<Reservation>
                {
                    new Reservation(),
                    new Reservation()
                });

            var notifier = new Notifier(
                mockClient.Object, mockRepository.Object);

            await notifier.SendNotificationAsync(new Reservation());

            mockClient.Verify(c => c.SendMessage(
                It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()), Times.Never);
        }
All Usage Examples Of AirTNG.Web.Domain.Reservations.Notifier::SendNotificationAsync