public GetAllOfferingPlatformsQuery_should()
 {
     _offeringPlatforms = new List <OfferingPlatformEntity>(new[]
     {
         Any.OfferingPlatformEntity()
     });
     _context = GetContextWithData();
     _handler = new GetAllOfferingPlatformsQueryHandler(_context);
 }
Пример #2
0
 public GetAllProductStatusesQuery_should()
 {
     _productStatuses = new List <ProductStatusEntity>(new[]
     {
         Any.ProductStatusEntity()
     });
     _context = GetContextWithData();
     _handler = new GetAllProductStatusesQueryHandler(_context);
 }
Пример #3
0
        private ProductAuthorityDatabaseContext GetContext()
        {
            var options = new DbContextOptionsBuilder <ProductAuthorityDatabaseContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var context = new ProductAuthorityDatabaseContext(options, _mediatorMock.Object);

            return(context);
        }
        public GetProductBasedOnEffectiveStartDateQuery_should()
        {
            _products = new List <ProductEntity>(new[]
            {
                Any.ProductEntity("key", new DateTime(2019, 01, 01), new DateTime(2019, 02, 01)),
                Any.ProductEntity("key", new DateTime(2019, 02, 01))
            });

            _context = GetContextWithData();
            _handler = new GetProductBasedOnEffectiveStartDateQueryHandler(_context);
        }
Пример #5
0
        public AddOfferingCommandHandler_should()
        {
            _products = new List <ProductEntity>(new[]
            {
                Any.ProductEntity(Any.String(), new DateTime(2019, 02, 01))
            });
            _context = GetContextWithData();

            _handler = new AddOfferingCommandHandler(_context);
            _command = new AddOfferingCommand(_products.First().ProductKey, _products.First().EffectiveStartDate, Any.String(), Any.String(), Any.String(), Any.String());
        }
        public UpdateProductCommandHandler_should()
        {
            _products = new List <ProductEntity>(new[]
            {
                Any.ProductEntity("key", new DateTime(2019, 02, 01))
            });

            _context = GetContextWithData();
            _handler = new UpdateProductCommandHandler(_context);
            _command = new UpdateProductCommand(_products.First().ProductKey, DateTime.Now, Any.String(), Any.String(), Any.String(), Any.String(), Any.String(), Any.String(), Any.String(), Any.Int());
        }
Пример #7
0
        private ProductAuthorityDatabaseContext GetContextWithData()
        {
            var options = new DbContextOptionsBuilder <ProductAuthorityDatabaseContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var context = new ProductAuthorityDatabaseContext(options, _mediatorMock.Object);

            context.ProductStatuses.AddRange(_productStatuses);

            context.SaveChanges();
            return(context);
        }
Пример #8
0
 public GetOfferingBasedOnProductKeyQuery_should()
 {
     _products = new List <ProductEntity>(new[]
     {
         Any.ProductEntity(Any.String(), new DateTime(2019, 02, 01)),
         Any.ProductEntity(Any.String(), new DateTime(2019, 02, 01))
     });
     _offerings = new List <OfferingEntity>(new[]
     {
         Any.OfferingEntity("key", _products.First().ProductId, _products.First().EffectiveStartDate),
         Any.OfferingEntity("key2", _products.Last().ProductId, _products.Last().EffectiveStartDate)
     });;
     _context = GetContextWithData();
     _handler = new GetOfferingBasedOnProductKeyQueryHandler(_context);
 }
Пример #9
0
        public UpdateOfferingCommandHandler_should()
        {
            _products = new List <ProductEntity>(new[]
            {
                Any.ProductEntity(Any.String(), new DateTime(2019, 02, 01))
            });
            _offerings = new List <OfferingEntity>(new[]
            {
                Any.OfferingEntity("key", _products.First().ProductId, _products.First().EffectiveStartDate)
            });;
            _context = GetContextWithData();

            _handler = new UpdateOfferingCommandHandler(_context);
            _command = new UpdateOfferingCommand(_products.First().ProductKey, _offerings.First().OfferingKey, _products.First().EffectiveStartDate.AddDays(1), Any.String(), Any.String(), Any.String(), Any.String());
        }
        public UpdateProductDtoValidator(ProductAuthorityDatabaseContext context)
        {
            _context = context;

            //Add Model State validations here.
            //This will help avoid transmitting invalid commands to command handlers and enforce the fail fast principle.
            ////https://fluentvalidation.net/start

            RuleFor(p => p.ProductKey).NotEmpty().MaximumLength(16);
            RuleFor(p => p.EffectiveStartDate).NotEmpty();
            RuleFor(p => p.ProductName).NotEmpty().MaximumLength(128);
            RuleFor(p => p.ProductDisplayName).MaximumLength(128);
            RuleFor(p => p.PrintIssn).MaximumLength(8);
            RuleFor(p => p.OnlineIssn).MaximumLength(8);
            RuleFor(p => p.ProductTypeCode).MaximumLength(4);
            RuleFor(p => p.ProductStatusCode).MaximumLength(4);
            RuleFor(p => p.PublisherProductCode).MaximumLength(32);

            RuleFor(p => p.EffectiveStartDate).Must(IsProductValidForDateRangeAsync).WithMessage($"No product found for the specified 'Product Key' and 'Effective Start date'.");
        }
Пример #11
0
        private ProductAuthorityDatabaseContext GetContextWithData()
        {
            var options = new DbContextOptionsBuilder <ProductAuthorityDatabaseContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var context = new ProductAuthorityDatabaseContext(options, _mediatorMock.Object);

            context.ProductStatuses.AddRange(new[]
            {
                new ProductStatusEntity {
                    ProductStatusCode = "A", ProductStatusName = "StatusA"
                }
            });

            context.ProductTypes.AddRange(_products.Select(x => x.ProductType));
            context.ProductStatuses.AddRange(_products.Select(x => x.ProductStatus));
            context.Products.AddRange(_products);

            context.SaveChanges();
            return(context);
        }
 public GetAllOfferingPlatformsQueryHandler(ProductAuthorityDatabaseContext context)
 {
     _context = context;
 }
 public AddRateCommandHandler(ProductAuthorityDatabaseContext context)
 {
     _context = context;
 }
Пример #14
0
 public GetOfferingBasedOnProductKeyQueryHandler(ProductAuthorityDatabaseContext context)
 {
     _context = context;
 }
 public UpdateProductCommandHandler(ProductAuthorityDatabaseContext context)
 {
     _context = context;
 }
Пример #16
0
 public GetAllDeliveryMethodsQueryHandler(ProductAuthorityDatabaseContext context)
 {
     _context = context;
 }
Пример #17
0
 public AddProductCommandHandler_should()
 {
     _context = GetContext();
     _handler = new AddProductCommandHandler(_context);
     _command = new AddProductCommand(Any.String(), Any.String(), Any.Long(), Any.String(), Any.String(), Any.String(), Any.String(), Any.String(), Any.Int());
 }
 public GetAllOfferingStatusesQueryHandler(ProductAuthorityDatabaseContext context)
 {
     _context = context;
 }
Пример #19
0
 public GetRateBasedOnRateKeyQueryHandler(ProductAuthorityDatabaseContext context)
 {
     _context = context;
 }
Пример #20
0
 public GetAllRateTypesQueryHandler(ProductAuthorityDatabaseContext context)
 {
     _context = context;
 }
 public GetProductBasedOnEffectiveStartDateQueryHandler(ProductAuthorityDatabaseContext context)
 {
     _context = context;
 }