コード例 #1
0
        private void buscarReservas()
        {
            var reservasAux   = reservas.Where(x => x.FechaSalida >= fechaDesde.Date && x.FechaSalida <= fechaHasta.Date).ToList();
            var ventasAdapter = new ReservaAdapter(this, reservasAux);

            listViewReservas.Adapter = ventasAdapter;
            ventasAdapter.NotifyDataSetChanged();
        }
コード例 #2
0
        public static ReadModelFacade BuildTheReadModelHexagon(IProveerPizzas pizzasAdapter, IProveerPizzeria pizzeriaAdapter, IProveerPedido pedidoAdapter = null, ISubscribeToEvents bus = null)
        {
            if (bus == null)
            {
                bus = new FakeBus();
            }

            if (pedidoAdapter == null)
            {
                pedidoAdapter = new ReservaAdapter(bus);
            }

            return(new ReadModelFacade(pizzasAdapter, pizzeriaAdapter, pedidoAdapter, bus));
        }
コード例 #3
0
        public void Debe_actualizar_buscar_pizza_cuando_cancelaPedidoCommand_es_enviado()
        {
            // Initialize Read-model side
            var bus = new FakeBus(synchronousPublication: true);
            var pizzeriasAdapter = new PizzeriasYPizzasAdapter(Constants.RelativePathForPizzaIntegrationFiles, bus);
            var pedidoAdapter    = new ReservaAdapter(bus);

            pizzeriasAdapter.LoadPizzaFile("Malcriada-availabilities.json");

            // Initialize Write-model side
            var bookingRepository = new PedidoYClientesRepository();

            CompositionRootHelper.BuildTheWriteModelHexagon(bookingRepository, bookingRepository, bus, bus);

            var readFacade = CompositionRootHelper.BuildTheReadModelHexagon(pizzeriasAdapter, pizzeriasAdapter, pedidoAdapter, bus);

            // Search Pizzas availabilities
            var fechaEntrega = Constants.MyFavoriteSaturdayIn2019;

            var searchQuery    = new BuscarPedidoOpciones(fechaEntrega, direccion: "Cercado", nombrePizza: "peperoni", cantidad: 2);
            var pedidoOpciones = readFacade.BuscarPedidoOpciones(searchQuery);

            // We should get 1 pedido option with 13 available pizzas in it.
            Check.That(pedidoOpciones).HasSize(1);

            var pedidoOpcion        = pedidoOpciones.First();
            var initialPizzaNumbers = 13;

            Check.That(pedidoOpcion.DisponiblesPizzasConPrecios).HasSize(initialPizzaNumbers);

            // Now, let's request that pizza!
            var firstPizzaOfThisPedidoOption = pedidoOpcion.DisponiblesPizzasConPrecios.First();
            var clientId      = "*****@*****.**";
            var pedidoCommand = new PedidoCommand(clienteId: clientId, pizzeriaId: pedidoOpcion.Pizzeria.Identificador, pizzaNombre: "MalcriadaC", cantidad: firstPizzaOfThisPedidoOption.Cantidad, fechaDeEntrega: fechaEntrega);

            // We send the PedirPizza command
            bus.Send(pedidoCommand);

            // We check that both the PedidoRepository (Write model) and the available pizzas (Read model) have been updated.
            Check.That(bookingRepository.GetPedidoDe(clientId).Count()).IsEqualTo(1);
            var pedidoId = bookingRepository.GetPedidoDe(clientId).First().PedidoId;

            // Fetch pizzas availabilities now. One pizza should have disappeared from the search result
            pedidoOpciones = readFacade.BuscarPedidoOpciones(searchQuery);
            Check.That(pedidoOpciones).HasSize(1);
            Check.That(pedidoOpcion.DisponiblesPizzasConPrecios).As("available matching pizzas").HasSize(initialPizzaNumbers - 1);
        }
コード例 #4
0
        public void DebeActualizar_readmodel_usuario_reservacion_cuando_CancelarPedidoCommand_is_enviadot()
        {
            var pedidoEngine = new PedidoYClientesRepository();
            var bus          = new FakeBus(synchronousPublication: true);

            CompositionRootHelper.BuildTheWriteModelHexagon(pedidoEngine, pedidoEngine, bus, bus);

            var pizzeriasYPizzasAdapter = new PizzeriasYPizzasAdapter(Constants.RelativePathForPizzaIntegrationFiles, bus);

            pizzeriasYPizzasAdapter.LoadAllPizzaFiles();
            var reservationAdapter = new ReservaAdapter(bus);

            CompositionRootHelper.BuildTheReadModelHexagon(pizzeriasYPizzasAdapter, pizzeriasYPizzasAdapter, reservationAdapter, bus);

            var clienteId = "*****@*****.**";

            Check.That(reservationAdapter.GetReservacionesDe(clienteId)).IsEmpty();

            var pizzeriaId    = 2;
            var cantidad      = 2;
            var pedidoCommand = new PedidoCommand(clienteId: clienteId, pizzeriaId: pizzeriaId, pizzaNombre: "Peperoni", cantidad: 2, fechaDeEntrega: Constants.MyFavoriteSaturdayIn2019);

            bus.Send(pedidoCommand);

            var pedidoGuid = pedidoEngine.GetPedidoDe(clienteId).First().PedidoId;

            Check.That(reservationAdapter.GetReservacionesDe(clienteId)).HasSize(1);

            var reservation = reservationAdapter.GetReservacionesDe(clienteId).First();

            Check.That(reservation.Cantidad).IsEqualTo(cantidad);
            Check.That(reservation.PizzeriaId).IsEqualTo(pizzeriaId);

            var cancelCommand = new CancelarPedidoCommand(pedidoGuid, clienteId);

            bus.Send(cancelCommand);

            Check.That(reservationAdapter.GetReservacionesDe(pedidoGuid, clienteId)).HasSize(0);
        }