Ejemplo n.º 1
0
        public DistributionPolicy Merge(DistributionPolicy policy)
        {
            var mergingIds = policy.ReceiverIds;
            var newIdsArr  = ReceiverIds.Union(mergingIds).ToArray();

            return(new DistributionPolicy(newIdsArr));
        }
Ejemplo n.º 2
0
        public void DistrubuteEvent(Event @event, DistributionPolicy distributionPolicy)
        {
            var session = _sessionProvider.GetCurrentSession();

            var eventId = (int) session.Save(@event);
            foreach (var receiverId in distributionPolicy.ReceiverIds)
            {
                var id = session.Save(new Delivery(receiverId, eventId));
            }
        }
        public void EventIsStoredSuccessfully()
        {
            var provider = new DatabaseSessionProvider();
            var repository = new EventRepository(provider);
            var eventInfo = new NewEmailConfirmedDeveloper(1);
            var @event = new Event(eventInfo);
            var receivers = new[] {30, 31, 32};
            var distributionPolicy = new DistributionPolicy(receivers);

            repository.DistrubuteEvent(@event, distributionPolicy);
            var receivedEvent = repository.GetEventsByUser(receivers[0], false).Single();

            Assert.AreEqual(@event.EventInfo, receivedEvent.EventInfo);
            Assert.AreEqual(@event.EventType, receivedEvent.EventType);
        }
 public DistributionPolicy Merge(DistributionPolicy policy)
 {
     var mergingIds = policy.ReceiverIds;
     var newIdsArr = ReceiverIds.Union(mergingIds).ToArray();
     return new DistributionPolicy(newIdsArr);
 }