Ejemplo n.º 1
0
        public async Task It_notifies_about_removing_an_entry()
        {
            var fakeSchedule   = new FakeSchedule();
            var entries        = new List <Entry>();
            var fakeBackplane  = new FakeBackplane("A", entries);
            var otherBackplane = new FakeBackplane("B", entries);

            var client = new DataBackplaneClient(fakeBackplane, fakeSchedule);
            await client.Start();

            var readValues   = new List <string>();
            var subscription = await client.GetAllAndSubscribeToChanges("T1", entry =>
            {
                readValues.Add(entry.Data);
                return(Task.FromResult(0));
            }, entry =>
            {
                readValues.Remove(entry.Data);
                return(Task.FromResult(0));
            });

            await otherBackplane.Publish("T1", "B");

            await fakeSchedule.TriggerQuery();

            CollectionAssert.Contains(readValues, "B");

            await otherBackplane.Revoke("T1");

            await fakeSchedule.TriggerQuery();

            CollectionAssert.DoesNotContain(readValues, "B");
            subscription.Unsubscribe();
        }
        public async Task It_notifies_about_removing_an_entry()
        {
            var fakeSchedule = new FakeSchedule();
            var entries = new List<Entry>();
            var fakeBackplane = new FakeBackplane("A", entries);
            var otherBackplane = new FakeBackplane("B", entries);

            var client = new DataBackplaneClient(fakeBackplane, fakeSchedule);
            await client.Start();
            var readValues = new List<string>();
            var subscription = await client.GetAllAndSubscribeToChanges("T1", entry =>
            {
                readValues.Add(entry.Data);
                return Task.FromResult(0);
            }, entry =>
            {
                readValues.Remove(entry.Data);
                return Task.FromResult(0);
            });

            await otherBackplane.Publish("T1", "B");
            await fakeSchedule.TriggerQuery();
            CollectionAssert.Contains(readValues, "B");

            await otherBackplane.Revoke("T1");
            await fakeSchedule.TriggerQuery();
            CollectionAssert.DoesNotContain(readValues, "B");
            subscription.Unsubscribe();
        }
        public async Task It_notifies_about_all_relevant_entries_right_after_subscribing()
        {
            var fakeSchedule = new FakeSchedule();
            var entries = new List<Entry>();
            entries.Add(new Entry("B", "T1", "B"));
            entries.Add(new Entry("C", "T1", "C"));
            var fakeBackplane = new FakeBackplane("A", entries);

            var client = new DataBackplaneClient(fakeBackplane, fakeSchedule);
            await client.Start();
            await fakeSchedule.TriggerQuery();
            var readValues = new List<string>();
            var subscription = await client.GetAllAndSubscribeToChanges("T1", entry =>
            {
                readValues.Add(entry.Data);
                return Task.FromResult(0);
            }, entry => Task.FromResult(0));
            CollectionAssert.AreEqual(new [] {"B", "C"}, readValues);
            subscription.Unsubscribe();
        }
Ejemplo n.º 4
0
        public async Task It_notifies_about_all_relevant_entries_right_after_subscribing()
        {
            var fakeSchedule = new FakeSchedule();
            var entries      = new List <Entry>();

            entries.Add(new Entry("B", "T1", "B"));
            entries.Add(new Entry("C", "T1", "C"));
            var fakeBackplane = new FakeBackplane("A", entries);

            var client = new DataBackplaneClient(fakeBackplane, fakeSchedule);
            await client.Start();

            await fakeSchedule.TriggerQuery();

            var readValues   = new List <string>();
            var subscription = await client.GetAllAndSubscribeToChanges("T1", entry =>
            {
                readValues.Add(entry.Data);
                return(Task.FromResult(0));
            }, entry => Task.FromResult(0));

            CollectionAssert.AreEqual(new [] { "B", "C" }, readValues);
            subscription.Unsubscribe();
        }