예제 #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);
        }
예제 #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();
        }
예제 #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();
        }
예제 #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();
        }
예제 #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);
        }
예제 #6
0
 public GetOrderQueryHandler(TyreKlickerDbContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
예제 #7
0
        public static void Destroy(TyreKlickerDbContext context)
        {
            context.Database.EnsureDeleted();

            context.Dispose();
        }
 public CompleteOrderCommandHandler(TyreKlickerDbContext context)
 {
     _context = context;
 }
예제 #9
0
 public GetAllOrdersCreatedByUserQueryHandlerTests(QueryTestFixture fixture)
 {
     _context = fixture.Context;
 }
예제 #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;
 }
예제 #13
0
 public GetCurrentOrdersQueryHandler(TyreKlickerDbContext context)
 {
     _context = context;
 }
예제 #14
0
 public GetAddressesQueryHandler(TyreKlickerDbContext context)
 {
     _context = context;
 }
 public GetAllOrdersQueryHandlerTests(QueryTestFixture fixture)
 {
     _context = fixture.Context;
 }
예제 #16
0
 public GetAllPendingOrdersQueryHandler(TyreKlickerDbContext context)
 {
     _context = context;
 }
예제 #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;
 }
예제 #21
0
 public QueryTestFixture()
 {
     Context = TyreKlickerContextFactory.Create();
     Mapper  = AutoMapperFactory.Create();
 }
예제 #22
0
 public CreateOrderCommandHandler(TyreKlickerDbContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
예제 #23
0
 public SetPrimaryAddressCommandHandler(TyreKlickerDbContext context)
 {
     _context = context;
 }
 public CreateUserCommandHandler(TyreKlickerDbContext context)
 {
     _context = context;
 }
 public GetPrimaryAddressQueryHandler(TyreKlickerDbContext context)
 {
     _context = context;
 }
예제 #26
0
 public GetAllOrdersCreatedUserQueryHandler(TyreKlickerDbContext context)
 {
     _context = context;
 }