public async Task UpdateAsync_Should_Throw_Exception_When_Validate_Product_Failed()
    {
        var createDto = new FlashSalePlanCreateDto()
        {
            StoreId      = FlashSalesTestData.Store1Id,
            BeginTime    = DateTime.Now,
            EndTime      = DateTime.Now.AddMinutes(30),
            ProductId    = FlashSalesTestData.Product1Id,
            ProductSkuId = FlashSalesTestData.ProductSku1Id,
            IsPublished  = true
        };
        var returnFlashSalePlanDto = await AppService.CreateAsync(createDto);

        var updateDto = new FlashSalePlanUpdateDto()
        {
            BeginTime    = DateTime.Now.AddMinutes(30),
            EndTime      = DateTime.Now.AddMinutes(60),
            ProductId    = FlashSalesTestData.Product1Id,
            ProductSkuId = FlashSalesTestData.ProductSku1Id,
            IsPublished  = false
        };

        Product1.StoreId = Guid.NewGuid();
        await AppService.UpdateAsync(returnFlashSalePlanDto.Id, updateDto).ShouldThrowAsync <ProductIsNotInThisStoreException>();

        Product1.StoreId = FlashSalesTestData.Store1Id;

        Product1.InventoryStrategy = InventoryStrategy.ReduceAfterPlacing;
        await AppService.UpdateAsync(returnFlashSalePlanDto.Id, updateDto).ShouldThrowAsync <UnexpectedInventoryStrategyException>();

        Product1.StoreId           = FlashSalesTestData.Store1Id;
        Product1.InventoryStrategy = InventoryStrategy.FlashSales;
    }
    public async Task UpdateAsync_Should_Throw_Exception_When_Has_Result_And_Change_Product()
    {
        var createDto = new FlashSalePlanCreateDto()
        {
            StoreId      = FlashSalesTestData.Store1Id,
            BeginTime    = DateTime.Now,
            EndTime      = DateTime.Now.AddMinutes(30),
            ProductId    = FlashSalesTestData.Product1Id,
            ProductSkuId = FlashSalesTestData.ProductSku1Id,
            IsPublished  = true
        };
        var returnFlashSalePlanDto = await AppService.CreateAsync(createDto);

        var updateDto = new FlashSalePlanUpdateDto()
        {
            BeginTime    = DateTime.Now.AddMinutes(30),
            EndTime      = DateTime.Now.AddMinutes(value: 60),
            ProductId    = FlashSalesTestData.Product1Id,
            ProductSkuId = FlashSalesTestData.ProductSku2Id,
            IsPublished  = false
        };

        await CreatePendingResultAsync(returnFlashSalePlanDto.Id, returnFlashSalePlanDto.StoreId, Guid.NewGuid());

        await AppService.UpdateAsync(returnFlashSalePlanDto.Id, updateDto).ShouldThrowAsync <RelatedFlashSaleResultsExistException>();
    }
    public async Task UpdateAsync()
    {
        var createDto = new FlashSalePlanCreateDto()
        {
            StoreId      = FlashSalesTestData.Store1Id,
            BeginTime    = DateTime.Now,
            EndTime      = DateTime.Now.AddMinutes(30),
            ProductId    = FlashSalesTestData.Product1Id,
            ProductSkuId = FlashSalesTestData.ProductSku1Id,
            IsPublished  = true
        };
        var returnFlashSalePlanDto = await AppService.CreateAsync(createDto);

        var updateDto = new FlashSalePlanUpdateDto()
        {
            BeginTime    = DateTime.Now.AddMinutes(30),
            EndTime      = DateTime.Now.AddMinutes(60),
            ProductId    = FlashSalesTestData.Product1Id,
            ProductSkuId = FlashSalesTestData.ProductSku1Id,
            IsPublished  = false
        };

        var flashSalePlan = await AppService.UpdateAsync(returnFlashSalePlanDto.Id, updateDto);

        flashSalePlan.Id.ShouldBe(returnFlashSalePlanDto.Id);
        flashSalePlan.StoreId.ShouldBe(createDto.StoreId);
        flashSalePlan.BeginTime.ShouldBe(updateDto.BeginTime);
        flashSalePlan.EndTime.ShouldBe(updateDto.EndTime);
        flashSalePlan.ProductId.ShouldBe(updateDto.ProductId);
        flashSalePlan.ProductSkuId.ShouldBe(updateDto.ProductSkuId);
        flashSalePlan.IsPublished.ShouldBe(updateDto.IsPublished);
    }
    public async Task DeleteAsync()
    {
        var createDto = new FlashSalePlanCreateDto()
        {
            StoreId      = FlashSalesTestData.Store1Id,
            BeginTime    = DateTime.Now,
            EndTime      = DateTime.Now.AddMinutes(30),
            ProductId    = FlashSalesTestData.Product1Id,
            ProductSkuId = FlashSalesTestData.ProductSku1Id,
            IsPublished  = true
        };
        var returnFlashSalePlanDto = await AppService.CreateAsync(createDto);

        await AppService.DeleteAsync(returnFlashSalePlanDto.Id);

        await AppService.GetAsync(returnFlashSalePlanDto.Id).ShouldThrowAsync <EntityNotFoundException>();
    }
 public virtual Task <FlashSalePlanDto> CreateAsync(FlashSalePlanCreateDto input)
 {
     return(Service.CreateAsync(input));
 }