示例#1
0
        public GetPictureDetailsQueryHandlerTests(QueryTestFixture fixture)
        {
            this.context = fixture.Context;
            this.mapper  = fixture.Mapper;

            this.handler = new GetPictureDetailsQueryHandler(this.context, this.mapper);
        }
示例#2
0
        private static async Task SeedCategories(IAuctionSystemDbContext dbContext, CancellationToken cancellationToken)
        {
            if (!dbContext.Categories.Any())
            {
                var categories =
                    await File.ReadAllTextAsync(Path.GetFullPath(AppConstants.CategoriesPath), cancellationToken);

                var deserializedCategoriesWithSubCategories =
                    JsonConvert.DeserializeObject <CategoryDto[]>(categories);

                var allCategories = deserializedCategoriesWithSubCategories.Select(deserializedCategory => new Category
                {
                    Name          = deserializedCategory.Name,
                    SubCategories = deserializedCategory.SubCategoryNames.Select(deserializedSubCategory =>
                                                                                 new SubCategory
                    {
                        Name = deserializedSubCategory.Name
                    }).ToList()
                }).ToList();

                await dbContext.Categories.AddRangeAsync(allCategories, cancellationToken);

                await dbContext.SaveChangesAsync(cancellationToken);
            }
        }
示例#3
0
 public SeedSampleDataCommandHandler(IAuctionSystemDbContext context,
                                     IDateTime dateTime,
                                     IUserManager userManager)
 {
     this.context     = context;
     this.dateTime    = dateTime;
     this.userManager = userManager;
 }
 public GenerateJwtTokenCommandHandler(
     IOptions <JwtSettings> options,
     IUserManager userManager,
     IAuctionSystemDbContext context,
     IDateTime dateTime)
     : base(options, userManager, context, dateTime)
 {
 }
示例#5
0
 public DeleteItemCommandHandler(IAuctionSystemDbContext context,
                                 ICurrentUserService currentUserService,
                                 IMediator mediator)
 {
     this.context            = context;
     this.currentUserService = currentUserService;
     this.mediator           = mediator;
 }
 public UserManagerService(
     UserManager <AuctionUser> userManager,
     RoleManager <IdentityRole> roleManager,
     IAuctionSystemDbContext context)
 {
     this.userManager = userManager;
     this.roleManager = roleManager;
     this.context     = context;
 }
示例#7
0
 public CreateBidCommandHandler(IAuctionSystemDbContext context,
                                ICurrentUserService currentUserService,
                                IDateTime dateTime,
                                IMapper mapper)
 {
     this.context            = context;
     this.currentUserService = currentUserService;
     this.dateTime           = dateTime;
     this.mapper             = mapper;
 }
 public JwtRefreshTokenCommandHandler(
     IOptions <JwtSettings> options,
     IUserManager userManager,
     IAuctionSystemDbContext context,
     IDateTime dateTime,
     TokenValidationParameters tokenValidationParameters)
     : base(options, userManager, context, dateTime)
 {
     this.tokenValidationParameters = tokenValidationParameters;
 }
示例#9
0
 public CreateItemCommandHandler(IAuctionSystemDbContext context,
                                 IMapper mapper,
                                 IMediator mediator,
                                 ICurrentUserService userService)
 {
     this.context     = context;
     this.mapper      = mapper;
     this.mediator    = mediator;
     this.userService = userService;
 }
        public EfGenericRepository(IAuctionSystemDbContext context)
        {
            if (context == null)
            {
                throw new ArgumentException("An instance of DbContext is required to use this repository.", "context");
            }

            this.Context = context;
            this.DbSet   = this.Context.Set <T>();
        }
        public ListAllUsersQueryHandlerTests(QueryTestFixture fixture)
        {
            this.context           = fixture.Context;
            this.mapper            = fixture.Mapper;
            this.mockedUserManager = IdentityMocker.GetMockedUserManager();

            this.userManagerService = new UserManagerService(
                this.mockedUserManager.Object,
                IdentityMocker.GetMockedRoleManager().Object,
                this.context);
        }
示例#12
0
 protected BaseJwtTokenHandler(
     IOptions <JwtSettings> options,
     IUserManager userManager,
     IAuctionSystemDbContext context,
     IDateTime dateTime)
 {
     this.UserManager = userManager;
     this.Context     = context;
     this.DateTime    = dateTime;
     this.options     = options.Value;
 }
示例#13
0
        public ListItemsQueryHandlerTests(QueryTestFixture fixture)
        {
            this.context = fixture.Context;
            this.mapper  = fixture.Mapper;

            var mockedDatetime = new Mock <IDateTime>();

            mockedDatetime.Setup(x => x.UtcNow).Returns(DateTime.UtcNow);
            mockedDatetime.Setup(x => x.Now).Returns(DateTime.Now);
            this.dateTime = mockedDatetime.Object;

            this.handler = new ListItemsQueryHandler(this.context, this.dateTime, this.mapper);
        }
        public CreatePictureCommandHandler(
            IAuctionSystemDbContext context,
            ICurrentUserService currentUserService,
            IMapper mapper,
            IOptions<CloudinaryOptions> options)
        {
            this.context = context;
            this.currentUserService = currentUserService;
            this.mapper = mapper;
            this.options = options.Value;

            var account = new Account(
                this.options.CloudName,
                this.options.ApiKey,
                this.options.ApiSecret);

            this.cloudinary = new Cloudinary(account);
        }
示例#15
0
        private async Task SeedItems(IAuctionSystemDbContext dbContext,
                                     IUserManager manager,
                                     CancellationToken cancellationToken)
        {
            if (!dbContext.Items.Any())
            {
                var random   = new Random();
                var allItems = new List <Item>();
                foreach (var category in dbContext.Categories.Include(c => c.SubCategories))
                {
                    var i = 1;
                    foreach (var subCategory in category.SubCategories)
                    {
                        var startTime = this.dateTime.UtcNow.AddDays(random.Next(0, 5)).ToUniversalTime();
                        var item      = new Item
                        {
                            Description   = $"Test Description_{i}",
                            Title         = $"Test Title_{i}",
                            StartTime     = startTime,
                            EndTime       = startTime.AddHours(random.Next(1, 10)),
                            StartingPrice = random.Next(10, 500),
                            MinIncrease   = random.Next(1, 100),
                            SubCategoryId = subCategory.Id,
                            Pictures      = new List <Picture>
                            {
                                new Picture {
                                    Url = AppConstants.DefaultPictureUrl, Created = this.dateTime.UtcNow
                                }
                            },
                            UserId = await manager.GetFirstUserId()
                        };

                        i++;
                        allItems.Add(item);
                    }
                }

                await dbContext.Items.AddRangeAsync(allItems, cancellationToken);

                await dbContext.SaveChangesAsync(cancellationToken);
            }
        }
 public ListAllUsersQueryHandler(IAuctionSystemDbContext context, IMapper mapper, IUserManager userManager)
 {
     this.context     = context;
     this.mapper      = mapper;
     this.userManager = userManager;
 }
 public GetHighestBidDetailsQueryHandler(IAuctionSystemDbContext context, IMapper mapper)
 {
     this.context = context;
     this.mapper  = mapper;
 }
示例#18
0
 public ListCategoriesQueryHandlerTests(QueryTestFixture fixture)
 {
     this.context = fixture.Context;
     this.mapper  = fixture.Mapper;
 }
示例#19
0
 public LogoutUserCommandHandler(IAuctionSystemDbContext context)
 {
     this.context = context;
 }
 public ListCategoriesQueryHandler(IAuctionSystemDbContext context, IMapper mapper)
 {
     this.context = context;
     this.mapper  = mapper;
 }
示例#21
0
 public ListItemsQueryHandler(IAuctionSystemDbContext context, IDateTime dateTime, IMapper mapper)
 {
     this.context  = context;
     this.dateTime = dateTime;
     this.mapper   = mapper;
 }
示例#22
0
 public GetHighestBidDetailsQueryHandlerTests(QueryTestFixture fixture)
 {
     this.context = fixture.Context;
     this.mapper  = fixture.Mapper;
 }
示例#23
0
 public Seeder(IAuctionSystemDbContext context, IDateTime dateTime, IUserManager userManager)
 {
     this.context     = context;
     this.dateTime    = dateTime;
     this.userManager = userManager;
 }