예제 #1
0
        public void Always_return_the_same_Instance_per_show_at_a_time()
        {
            var watcherPool = new ShowReservationsWatcherPool(Substitute.For <IProvideReservedSeats>());

            var reservationsWatcher             = watcherPool.GetWatcherForShow("3");
            var reservationsWatcher2            = watcherPool.GetWatcherForShow("3");
            var reservationsWatcherForOtherShow = watcherPool.GetWatcherForShow("4");

            Check.That(reservationsWatcher2).IsEqualTo(reservationsWatcher);
            Check.That(reservationsWatcherForOtherShow).IsNotEqualTo(reservationsWatcher);
        }
        Register_the_ClientProxy_as_an_observer_of_a_showReservationWatcher_when_Starting_a_subscription()
        {
            const string showId = "7";
            var          showReservationsWatcherPool =
                new ShowReservationsWatcherPool(InstantiateFakeReservationProvider(showId));
            var          proxyPool    = new ClientProxyPool(PublisherFactory.GetFakePublisher(), showReservationsWatcherPool);
            const string connectionId = "SignalRStuff-45";
            var          initialReservedSeatsAsViewedByTheClient = new List <string> {
                "Z1", "Z27"
            };

            var clientProxy = proxyPool.GetClientProxy(showId, connectionId);

            Check.That(clientProxy).IsNull();

            await proxyPool.StartSubscription(showId, connectionId, initialReservedSeatsAsViewedByTheClient);

            clientProxy = proxyPool.GetClientProxy(showId, connectionId);
            Check.That(clientProxy).IsNotNull();

            var watcherForShow7 = showReservationsWatcherPool.GetWatcherForShow(showId);

            Check.That(watcherForShow7.IsObservedBy(clientProxy)).IsTrue();
        }