public void SetTimeRange_Should_Throw_InvalidEndTimeException_When_Set_InvalidEndTime() { var existPlan = new FlashSalePlan( id: Guid.NewGuid(), tenantId: null, storeId: Guid.NewGuid(), beginTime: DateTime.Now, endTime: DateTime.Now.AddSeconds(1), productId: Guid.NewGuid(), productSkuId: Guid.NewGuid(), isPublished: true ); Assert.Throws <InvalidEndTimeException>(() => existPlan.SetTimeRange(DateTime.Now, DateTime.Now.AddMinutes(-1))); }
public void SetPublished() { var existPlan = new FlashSalePlan( id: Guid.NewGuid(), tenantId: null, storeId: Guid.NewGuid(), beginTime: DateTime.Now, endTime: DateTime.Now.AddSeconds(1), productId: Guid.NewGuid(), productSkuId: Guid.NewGuid(), isPublished: true ); existPlan.SetPublished(false); existPlan.IsPublished.ShouldBe(false); }
protected virtual async Task <FlashSalePlan> CreateFlashSalePlanAsync(bool useSku2 = false, CreateTimeRange timeRange = CreateTimeRange.Starting, bool isPublished = true) { DateTime beginTime; DateTime endTime; switch (timeRange) { case CreateTimeRange.Starting: beginTime = Clock.Now; endTime = beginTime.AddMinutes(30); break; case CreateTimeRange.NotStart: beginTime = Clock.Now.AddMinutes(10); endTime = beginTime.AddMinutes(30); break; case CreateTimeRange.Expired: beginTime = Clock.Now.AddDays(-1); endTime = beginTime.AddMinutes(30); break; case CreateTimeRange.WillBeExpired: beginTime = Clock.Now.AddDays(-30); endTime = Clock.Now.AddSeconds(1); break; default: throw new AbpException(); } var flashSalePlan = new FlashSalePlan( GuidGenerator.Create(), CurrentTenant.Id, FlashSalesTestData.Store1Id, beginTime, endTime, FlashSalesTestData.Product1Id, useSku2 ? FlashSalesTestData.ProductSku2Id : FlashSalesTestData.ProductSku1Id, isPublished ); return(await WithUnitOfWorkAsync(async() => await FlashSalePlanRepository.InsertAsync(flashSalePlan, autoSave: true))); }
public void SetTimeRange() { var existPlan = new FlashSalePlan( id: Guid.NewGuid(), tenantId: null, storeId: Guid.NewGuid(), beginTime: DateTime.Now, endTime: DateTime.Now.AddSeconds(1), productId: Guid.NewGuid(), productSkuId: Guid.NewGuid(), isPublished: true ); var newBeginTime = DateTime.Now; var newEndTime = newBeginTime.AddMinutes(1); existPlan.SetTimeRange(newBeginTime, newEndTime); existPlan.BeginTime.ShouldBe(newBeginTime); existPlan.EndTime.ShouldBe(newEndTime); }
public void SetProductSku() { var existPlan = new FlashSalePlan( id: Guid.NewGuid(), tenantId: null, storeId: Guid.NewGuid(), beginTime: DateTime.Now, endTime: DateTime.Now.AddSeconds(1), productId: Guid.NewGuid(), productSkuId: Guid.NewGuid(), isPublished: true ); var newStoreId = Guid.NewGuid(); var newProductId = Guid.NewGuid(); var newProductSkuId = Guid.NewGuid(); existPlan.SetProductSku(newStoreId, newProductId, newProductSkuId); existPlan.StoreId.ShouldBe(newStoreId); existPlan.ProductId.ShouldBe(newProductId); existPlan.ProductSkuId.ShouldBe(newProductSkuId); }
protected virtual async Task RemoveUserFlashSaleResultCacheAsync(FlashSalePlan plan, Guid userId) { await DistributedCache.RemoveAsync(await GetUserFlashSaleResultCacheKeyAsync(plan, userId)); }
protected virtual Task <string> GetUserFlashSaleResultCacheKeyAsync(FlashSalePlan plan, Guid userId) { return(Task.FromResult(string.Format(FlashSalePlanAppService.UserFlashSaleResultCacheKeyFormat, plan.TenantId, plan.Id, userId))); }