Exemplo n.º 1
0
        public ShowControllerTests()
        {
            var ctx = TestDbUtilities <ShowContext> .BuildInMemoryContext();

            var repo = new ShowRepository(ctx);

            var configuration = new MapperConfiguration(cfg => cfg.AddProfile <ShowMaps>());
            var mapper        = new Mapper(configuration);

            _controller = new ShowsController(repo, mapper);
        }
        public SalesControllerTests()
        {
            var ctx = TestDbUtilities <SalesContext> .BuildInMemoryContext();

            var repo = new SalesRepository(ctx);

            var configuration = new MapperConfiguration(cfg => cfg.AddProfile <SalesMaps>());
            var mapper        = new Mapper(configuration);

            var serviceProvider = new ServiceCollection()
                                  .AddLogging()
                                  .BuildServiceProvider();

            var factory = serviceProvider.GetService <ILoggerFactory>();

            var logger = factory.CreateLogger <SalesController>();

            var ticketServiceMock = new Mock <ITicketService>();

            ticketServiceMock.Setup(s => s.ReserveTickets(It.IsAny <int[]>())).ReturnsAsync(() =>
            {
                return(true);
            });
            ticketServiceMock.Setup(s => s.FinalizeTickets(It.IsAny <int[]>())).ReturnsAsync(() =>
            {
                var result = new FinalizedTicketResponse()
                {
                    Success = true,
                    Tickets = new TicketInfo[]
                    {
                        new TicketInfo()
                        {
                            Price = 49.99m
                        },
                        new TicketInfo()
                        {
                            Price = 49.99m
                        },
                        new TicketInfo()
                        {
                            Price = 49.99m
                        },
                        new TicketInfo()
                        {
                            Price = 49.99m
                        },
                    }
                };
                return(result);
            });


            _controller = new SalesController(logger, mapper, repo, ticketServiceMock.Object);
        }
Exemplo n.º 3
0
        public CustomerControllerTests()
        {
            var ctx = TestDbUtilities <SalesContext> .BuildInMemoryContext();

            var repo = new SalesRepository(ctx);

            var configuration = new MapperConfiguration(cfg => cfg.AddProfile <SalesMaps>());
            var mapper        = new Mapper(configuration);

            var serviceProvider = new ServiceCollection()
                                  .AddLogging()
                                  .BuildServiceProvider();

            var factory = serviceProvider.GetService <ILoggerFactory>();

            var logger = factory.CreateLogger <CustomersController>();

            _controller = new CustomersController(logger, mapper, repo);
        }
 public SalesRepositoryTests()
 {
     _repository = new SalesRepository(TestDbUtilities <SalesContext> .BuildInMemoryContext());
 }
 public ShowsRepositoryTests()
 {
     _repo = new ShowRepository(TestDbUtilities <ShowContext> .BuildInMemoryContext());
 }