Exemple #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);
        }
Exemple #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSignalR();

            services.AddSingleton <IPublishMessages, ClientPublisher>();

            var auditoriumSeatingProxy = new AuditoriumSeatingProxy(UriAuditoriumSeatingService);

            services.AddSingleton <IProvideAuditoriumSeating>(auditoriumSeatingProxy);

            var seatsReservationsProxy = new SeatReservationsProxy(UriSeatReservationService);

            services.AddSingleton <IProvideReservedSeats>(seatsReservationsProxy);
            services.AddSingleton <IProvidePrices>(seatsReservationsProxy);

            var seatSuggestionsProxy = new SeatSuggestionsProxy(UriSeatsSuggestionService);

            services.AddSingleton <ISuggestSeats>(seatSuggestionsProxy);

            var pollingInterval  = TimeSpan.FromSeconds(1);
            var watcherWarehouse = new ShowReservationsWatcherPool(seatsReservationsProxy, pollingInterval);

            services.AddSingleton <IOwnReservationsWatchers>(watcherWarehouse);

            services.AddSingleton <IHostClientProxies, ClientProxyPool>();

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.AddCors(options =>
            {
                options.AddPolicy(BffCorsOrigins,
                                  builder =>
                {
                    builder.WithOrigins("http://localhost:3000",
                                        "https://alexvictoor.github.io");
                    builder.AllowAnyHeader().AllowAnyMethod();
                });
            });


            // Register the Swagger generator, defining 1 or more Swagger documents
            services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info {
                    Title = "TicketOffice API", Version = "v1"
                }); });
        }
        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();
        }
Exemple #4
0
 public void Free_the_instance_of_a_show_when_the_last_consumer_released_it()
 {
     var watcherPool = new ShowReservationsWatcherPool(Substitute.For <IProvideReservedSeats>());
 }