示例#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 async Task GetAllOrdersAcceptedByUser_WhenCalled_ShouldReturnCountOfOrdersAcceptedByGivenUser(Guid userGuid1, Guid userGuid2)
        {
            var sut    = new GetAllOrdersCreatedUserQueryHandler(_context);
            var orders = new List <Domain.Entities.Order>()
            {
                new Domain.Entities.Order {
                    CreatedBy = CreatedByUserIdToTest
                },
                new Domain.Entities.Order {
                    CreatedBy = userGuid1
                },
                new Domain.Entities.Order {
                    CreatedBy = userGuid2
                }
            };

            _context.Order.AddRange(orders);
            _context.SaveChanges();
            var createdOrdersInDb = _context.Order.Count(x => x.CreatedBy == CreatedByUserIdToTest);

            var result = await sut.Handle(new GetAllOrdersCreatedByUserQuery()
            {
                UserId = CreatedByUserIdToTest
            }, CancellationToken.None);

            var resultCount = result.Orders.Count();

            resultCount.ShouldBe(createdOrdersInDb);
        }
示例#3
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();
        }
示例#4
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();
        }
示例#5
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();
        }