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

            this.handler = new GetPictureDetailsQueryHandler(this.context, this.mapper);
        }
コード例 #2
0
ファイル: Seeder.cs プロジェクト: wvnijnatten/AuctionSystem
        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;
 }
コード例 #4
0
 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;
 }
コード例 #6
0
 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;
 }
コード例 #8
0
 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;
 }
コード例 #10
0
        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>();
        }
コード例 #11
0
        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);
        }
コード例 #14
0
        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
ファイル: Seeder.cs プロジェクト: wvnijnatten/AuctionSystem
        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);
            }
        }
コード例 #16
0
 public ListAllUsersQueryHandler(IAuctionSystemDbContext context, IMapper mapper, IUserManager userManager)
 {
     this.context     = context;
     this.mapper      = mapper;
     this.userManager = userManager;
 }
コード例 #17
0
 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;
 }
コード例 #20
0
 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
ファイル: Seeder.cs プロジェクト: wvnijnatten/AuctionSystem
 public Seeder(IAuctionSystemDbContext context, IDateTime dateTime, IUserManager userManager)
 {
     this.context     = context;
     this.dateTime    = dateTime;
     this.userManager = userManager;
 }