public void Execute()
        {
            var document = Session.Load<Document>(_request.Id);

            var subscriber = new Subscriber(_request.ConnectionId);
            document.AddSubscriber(subscriber);

            subscriber.SubscriberNotifiedOfUpdate +=
                (o, e) => _request.Connection.Send(_request.ConnectionId, e);
        }
Ejemplo n.º 2
0
        public void Given_We_Have_Added_A_Subscriber_To_A_Document_Ensure_That_When_The_Document_Merges_Two_Revisions_The_Subscriber_Is_Notified_With_The_Merging_Revision()
        {
            var document = new Document("I went to the store");
            var subscriber = new Subscriber(Guid.NewGuid().ToString());
            document.AddSubscriber(subscriber);

            var revision1 = new BasicRevision(document.CurrentRevision, Patches.Make(document.Contents, "I went to the store to get some milk"));
            var revision2 = new BasicRevision(document.CurrentRevision, Patches.Make(document.Contents, "I went to the corner store"));
            IList<Patch> notifiedPatch = null;
            subscriber.SubscriberNotifiedOfUpdate +=
                (o, e) => notifiedPatch = e.patches;
            document.Edit(revision1);
            document.Edit(revision2);
            var patch = document.CurrentRevision.BuildPatch();

            Assert.That(notifiedPatch.Select(p=> p.ToString()), Is.EquivalentTo(patch.Select(p=> p.ToString())));
        }
Ejemplo n.º 3
0
 public void AddSubscriber(Subscriber subscriber)
 {
     Subcribers.Add(subscriber);
 }
Ejemplo n.º 4
0
        public void Given_We_Have_Added_A_Subscriber_To_A_Document_Ensure_That_When_A_Document_Is_Edited_The_Subscriber_Is_Notified()
        {
            var document = new Document("Test");
            var subscriber = new Subscriber(Guid.NewGuid().ToString());
            document.AddSubscriber(subscriber);

            var revision = new BasicRevision(document.CurrentRevision, Patches.Make(document.Contents, "Test 2"));
            var eventFired = false;
            subscriber.SubscriberNotifiedOfUpdate += (o, e) => eventFired = true;
            document.Edit(revision);

            Assert.That(eventFired);
        }