示例#1
0
    public async Task HandleEventAsync_When_Create_Order_Failed()
    {
        var existFlashResult = await CreateFlashSaleResultAsync();

        var createFlashSaleOrderCompleteEto = new CreateFlashSaleOrderCompleteEto()
        {
            TenantId        = existFlashResult.TenantId,
            PendingResultId = existFlashResult.Id,
            Success         = false,
            StoreId         = FlashSalesTestData.Store1Id,
            PlanId          = existFlashResult.PlanId,
            OrderId         = null,
            Reason          = "Failed reason",
            UserId          = existFlashResult.UserId,
        };

        await CreateFlashSaleOrderCompleteEventHandler.HandleEventAsync(createFlashSaleOrderCompleteEto);

        var flashResult = await FlashSaleResultRepository.GetAsync(existFlashResult.Id);

        flashResult.Status.ShouldBe(FlashSaleResultStatus.Failed);
        flashResult.OrderId.ShouldBe(null);
        flashResult.Reason.ShouldBe("Failed reason");
    }
示例#2
0
    public async Task HandleEventAsync_When_Create_Order_Success()
    {
        var existFlashResult = await CreateFlashSaleResultAsync();

        var createFlashSaleOrderCompleteEto = new CreateFlashSaleOrderCompleteEto()
        {
            TenantId        = existFlashResult.TenantId,
            PendingResultId = existFlashResult.Id,
            Success         = true,
            StoreId         = existFlashResult.StoreId,
            PlanId          = existFlashResult.PlanId,
            OrderId         = GuidGenerator.Create(),
            Reason          = null,
            UserId          = existFlashResult.UserId,
        };

        await CreateFlashSaleOrderCompleteEventHandler.HandleEventAsync(createFlashSaleOrderCompleteEto);

        var flashResult = await FlashSaleResultRepository.GetAsync(existFlashResult.Id);

        flashResult.Status.ShouldBe(FlashSaleResultStatus.Successful);
        flashResult.OrderId.ShouldBe(createFlashSaleOrderCompleteEto.OrderId);
        flashResult.Reason.ShouldBe(null);
    }