Пример #1
0
        public void SetUp()
        {
            theInitializer = new DefaultChannelInitializer <FakeTopic>();
            theWriter      = new RecordingServerEventWriter();

            theCache = MockRepository.GenerateMock <ITopicChannelCache>();
            ITopicChannel <FakeTopic> channel = new TopicChannel <FakeTopic>(new EventQueue <FakeTopic>());

            theChannel = channel.Channel;
            theTopic   = new FakeTopic();

            theCache.Stub(x => x.TryGetChannelFor(theTopic, out channel)).Return(true).OutRef(channel);

            theChannelWriter = new ChannelWriter <FakeTopic>(theWriter, theWriter, theCache, theInitializer);

            e1 = new ServerEvent("1", "data-1");
            e2 = new ServerEvent("2", "data-2");
            e3 = new ServerEvent("3", "data-3");
            e4 = new ServerEvent("4", "data-4");
            e5 = new ServerEvent("5", "data-5");

            ie1 = new ServerEvent("random1", "initialization data-1");
            ie2 = new ServerEvent("random2", "initialization data-2");
            ie3 = new ServerEvent("3", "initialization data-3");
        }
Пример #2
0
        public void failure_to_acquire_channel_terminates_without_errors()
        {
            theWriter = new RecordingServerEventWriter();

            var cache = MockRepository.GenerateMock <ITopicChannelCache>();
            ITopicChannel <FakeTopic> channel = new TopicChannel <FakeTopic>(new EventQueue <FakeTopic>());

            theChannel = channel.Channel;
            theTopic   = new FakeTopic();

            cache.Stub(x => x.TryGetChannelFor(theTopic, out channel)).Return(false);

            theChannelWriter = new ChannelWriter <FakeTopic>(theWriter, theWriter, cache, theInitializer);
            var task = theChannelWriter.Write(theTopic);

            task.Wait(150).ShouldBeTrue();
        }