Exemplo n.º 1
0
        public static TyreKlickerDbContext Create()
        {
            var options = new DbContextOptionsBuilder <TyreKlickerDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var context = new TyreKlickerDbContext(options);

            context.Database.EnsureCreated();

            var user = new Domain.Entities.User
            {
                Id       = Guid.Parse("2220d661-6a96-4537-a896-5014374d39f5"), Email = "*****@*****.**", FirstName = "Ryan",
                LastName = "Stuart"
            };

            context.User.Add(user);

            context.Address.AddRange(new Domain.Entities.Address
            {
                City   = "SEDGWICK", PrimaryAddress = true, PhoneNumber = "070 1639 2540", Postcode = "LA8 4HA",
                Street = "HOPE STREET", User = user
            });


            SeedOrders(context);

            context.SaveChanges();

            return(context);
        }
Exemplo n.º 2
0
        public CompleteOrderTestFixtures(QueryTestFixture fixture)
        {
            Context = fixture.Context;

            Order = new Domain.Entities.Order()
            {
                Id = Guid.NewGuid(),
                AcceptedByUserId = Guid.NewGuid(),
                Complete         = false
            };
            Context.Order.Add(Order);
            Context.SaveChanges();
        }
Exemplo n.º 3
0
        private static void SeedOrders(TyreKlickerDbContext context)
        {
            var orders = new[]
            {
                new  Domain.Entities.Order()
                {
                    Id               = Guid.Parse("f0470dc0-9f14-4152-8b81-82235a85edf7"),
                    Description      = "I have been accepted",
                    Registration     = "MW09 OEJ",
                    AcceptedByUserId = Guid.Parse("75a1e4c8-65d7-4f70-b8e8-216543e7462b"),
                }
            };

            context.Order.AddRange(orders);
            context.SaveChanges();
        }
Exemplo n.º 4
0
        public AcceptOrderTestsFixture(QueryTestFixture fixture)
        {
            Context = fixture.Context;

            AcceptedOrder = new Domain.Entities.Order()
            {
                Id = Guid.NewGuid(),
                AcceptedByUserId = Guid.NewGuid()
            };
            PendingOrder = new Domain.Entities.Order()
            {
                Id = Guid.NewGuid(),
            };

            Context.Order.Add(AcceptedOrder);
            Context.Order.Add(PendingOrder);
            Context.SaveChanges();
        }
Exemplo n.º 5
0
        public TyreKlickerDbContext GetDbContext(bool useSqlLite = false)
        {
            var builder = new DbContextOptionsBuilder <TyreKlickerDbContext>();

            builder.UseInMemoryDatabase(Guid.NewGuid().ToString());

            var dbContext = new TyreKlickerDbContext(builder.Options);

            if (useSqlLite)
            {
                // SQLite needs to open connection to the DB.
                // Not required for in-memory-database.
                dbContext.Database.OpenConnection();
            }

            dbContext.Database.EnsureCreated();

            return(dbContext);
        }
Exemplo n.º 6
0
 public GetOrderQueryHandler(TyreKlickerDbContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Exemplo n.º 7
0
        public static void Destroy(TyreKlickerDbContext context)
        {
            context.Database.EnsureDeleted();

            context.Dispose();
        }
 public CompleteOrderCommandHandler(TyreKlickerDbContext context)
 {
     _context = context;
 }
Exemplo n.º 9
0
 public GetAllOrdersCreatedByUserQueryHandlerTests(QueryTestFixture fixture)
 {
     _context = fixture.Context;
 }
Exemplo n.º 10
0
 public GetUserByIdQueryHandler(TyreKlickerDbContext context)
 {
     _context = context;
 }
 public CreatePaymentCommandHandler(TyreKlickerDbContext context, IPaymentService paymentService)
 {
     _context        = context;
     _paymentService = paymentService;
 }
 public GetOrderQueryHandlerTests(QueryTestFixture fixture)
 {
     _context = fixture.Context;
     _mapper  = fixture.Mapper;
 }
Exemplo n.º 13
0
 public GetCurrentOrdersQueryHandler(TyreKlickerDbContext context)
 {
     _context = context;
 }
Exemplo n.º 14
0
 public GetAddressesQueryHandler(TyreKlickerDbContext context)
 {
     _context = context;
 }
 public GetAllOrdersQueryHandlerTests(QueryTestFixture fixture)
 {
     _context = fixture.Context;
 }
Exemplo n.º 16
0
 public GetAllPendingOrdersQueryHandler(TyreKlickerDbContext context)
 {
     _context = context;
 }
Exemplo n.º 17
0
 public CreateAddressCommandHandler(TyreKlickerDbContext context)
 {
     _context = context;
 }
 public GetAllOrdersAcceptedByUserQueryHandler(TyreKlickerDbContext context)
 {
     _context = context;
 }
 public CreateUserCommandValidatorTests(QueryTestFixture fixture)
 {
     _context   = fixture.Context;
     _validator = new CreateUserCommandValidator();
 }
 public AcceptOrderCommandHandler(TyreKlickerDbContext context)
 {
     _context = context;
 }
Exemplo n.º 21
0
 public QueryTestFixture()
 {
     Context = TyreKlickerContextFactory.Create();
     Mapper  = AutoMapperFactory.Create();
 }
Exemplo n.º 22
0
 public CreateOrderCommandHandler(TyreKlickerDbContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Exemplo n.º 23
0
 public SetPrimaryAddressCommandHandler(TyreKlickerDbContext context)
 {
     _context = context;
 }
 public CreateUserCommandHandler(TyreKlickerDbContext context)
 {
     _context = context;
 }
 public GetPrimaryAddressQueryHandler(TyreKlickerDbContext context)
 {
     _context = context;
 }
Exemplo n.º 26
0
 public GetAllOrdersCreatedUserQueryHandler(TyreKlickerDbContext context)
 {
     _context = context;
 }