public AggregateCommunicationRequest(Guid requestId, string requestType, DeliveryFrequency frequency, DateTime requestDateTime, DateTime fromDateTime, DateTime toDateTime) // end time { RequestId = requestId; RequestType = requestType; Frequency = frequency; RequestDateTime = requestDateTime; FromDateTime = fromDateTime; ToDateTime = toDateTime; }
public async Task ReturnRespectiveTemplateId(string requestType, DeliveryFrequency frequency, string expectedTemplateId) { var plugin = new TemplateIdProviderPlugin(); var message = new CommunicationMessage() { RequestType = requestType, Frequency = frequency }; var templateId = await plugin.GetTemplateIdAsync(message); templateId.Should().Be(expectedTemplateId); }
public override PagedData ProcessRequest(HttpContext context, CookDBDataContext db) { if (context.Request.Params.Count == 0) { return(new PagedData("Can't call RemoveDeliveryFrequency.ashx without parameters")); } if (context.Request.Params.Get("frequency") == null) { return(new PagedData("Frequency is null")); } DeliveryFrequency frequency = db.DeliveryFrequencies.Single(a => a.frequency.Equals(context.Request.Params.Get("frequency"))); db.DeliveryFrequencies.DeleteOnSubmit(frequency); db.SubmitChanges(); return(new PagedData("")); }
public override PagedData ProcessRequest(HttpContext context, CookDBDataContext db) { if (context.Request.Params.Count == 0) { return(new PagedData("Can't call AddDeliveryFrequency.ashx without parameters")); } if (context.Request.Params.Get("frequency") == null) { return(new PagedData("Frequency is null")); } DeliveryFrequency frequency = new DeliveryFrequency(); frequency.frequency = context.Request.Params.Get("frequency"); db.DeliveryFrequencies.InsertOnSubmit(frequency); db.SubmitChanges(); return(new PagedData("")); }
public async Task <IEnumerable <CommunicationMessage> > GetScheduledMessagesSinceAsync(string requestType, DeliveryFrequency frequency, DateTime from, DateTime to) { var builder = Builders <CommunicationMessage> .Filter; var filter = builder.Eq(cm => cm.RequestType, requestType) & builder.Eq(cm => cm.Frequency, frequency) & builder.Eq(cm => cm.Status, CommunicationMessageStatus.Pending) & builder.Gte(cm => cm.RequestDateTime, from) & builder.Lte(cm => cm.RequestDateTime, to); var collection = GetCollection <CommunicationMessage>(); var result = await RetryPolicy.Execute(_ => collection.FindAsync(filter), new Context(nameof(GetScheduledMessagesSinceAsync))); return(await result.ToListAsync()); }
public async Task GivenMatchingMessageIds_UserPreferenceIsNotDaily_ThenShouldReturnNullAggregateMessage(DeliveryFrequency userFrequencyPreference) { var commPref = new CommunicationUserPreference { Frequency = userFrequencyPreference, Channels = DeliveryChannelPreferences.EmailOnly, Scope = NotificationScope.Individual }; var from = DateTime.UtcNow.AddDays(-1); var to = DateTime.UtcNow; var acr = new AggregateCommunicationRequest(Guid.NewGuid(), TestRequestType, DeliveryFrequency.Daily, DateTime.UtcNow, from, to); var messages = Enumerable.Repeat <CommunicationMessage>(GetTestTemplateMessage(), 10); _mockUserPreferenceProvider.Setup(x => x.GetUserPreferenceAsync(TestRequestType, It.IsAny <CommunicationUser>())) .ReturnsAsync(commPref); var aggregateMessage = await _sut.CreateAggregateMessageAsync(acr, messages); aggregateMessage.Should().BeNull(); }
public async Task GivenNonImmediateFrequencyCommunicationMessages_ShouldNotQueueMessagesForDispatchImmediately(DeliveryFrequency argFrequency) { const int SampleCommunicationMessagesCount = 3; var sampleCommunicationMessages = Enumerable.Repeat(new CommunicationMessage { Frequency = argFrequency }, SampleCommunicationMessagesCount); _mockProcessor.Setup(p => p.CreateMessagesAsync(_arbitraryCommRequest)) .ReturnsAsync(sampleCommunicationMessages); await _sut.ProcessCommunicationRequestAsync(_arbitraryCommRequest); _mockRepository.Verify(r => r.InsertAsync(It.IsIn(sampleCommunicationMessages)), Times.Exactly(SampleCommunicationMessagesCount)); _mockDispatchQueuePublisher.Verify(d => d.AddMessageAsync(It.IsAny <CommunicationMessageIdentifier>()), Times.Never); }
public async Task WhenUserPreferenceIsNotSet(string requestType, DeliveryChannelPreferences channel, DeliveryFrequency frequency) { _repositoryMock .Setup(u => u.GetAsync(It.IsAny <string>())) .ReturnsAsync((UserNotificationPreferences)null); var sut = GetSut(); var user = _fixture.Create <CommunicationUser>(); var pref = await sut.GetUserPreferenceAsync(requestType, user); pref.Channels.Should().Be(channel); pref.Frequency.Should().Be(frequency); }