public PromotionRedeemedDomainEvent( UserId userId, PromotionId promotionId, CurrencyType currencyType, decimal amount ) { UserId = userId; PromotionId = promotionId; CurrencyType = currencyType; Amount = amount; }
public void ChallengeClosedDomainEvent_WithToken_ShouldBeValid() { // Arrange var userId = new UserId(); var promotionId = new PromotionId(); var currencyType = CurrencyType.Token; const decimal amount = 20.0m; var domainEvent = new PromotionRedeemedDomainEvent( userId, promotionId, currencyType, amount); // Assert domainEvent.UserId.Should().Be(userId); domainEvent.PromotionId.Should().Be(promotionId); domainEvent.CurrencyType.Should().Be(currencyType); domainEvent.Amount.Should().Be(amount); }
protected override async Task SeedProductionAsync() { await this.SeedAdministratorAccountAsync(); var assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) !; var file = File.OpenRead(Path.Combine(assemblyPath, "Setup/Challenges.Production.csv")); using var csvReader = file.OpenCsvReader(); Challenges.AddRange( csvReader.GetRecords( new { Id = default(Guid), EntryFeeCurrency = default(int), EntryFeeAmount = default(decimal), Entries = default(int) }) .Select( record => { var payoutStrategy = new ChallengePayoutFactory().CreateInstance(); var payoutEntries = new ChallengePayoutEntries(record.Entries / 2); var currency = CurrencyType.FromValue(record.EntryFeeCurrency) !; var entryFee = new EntryFee(record.EntryFeeAmount, currency); var payout = payoutStrategy.GetChallengePayout(payoutEntries, entryFee); return(new Challenge(record.Id.ConvertTo <ChallengeId>(), payout)); }) .Where(challenge => Challenges.All(x => x.Id != challenge.Id)) .Select(challenge => challenge.ToModel())); await this.CommitAsync(); var startedAt = DateTimeOffset.FromUnixTimeMilliseconds(1582261200000).UtcDateTime; var duration = TimeSpan.FromDays(4); var promotion1 = new Promotion( "DHANA20REDCUP", new Money(5), duration, new DateTimeProvider(startedAt + duration)); promotion1.SetEntityId(PromotionId.Parse("885cdd1e-0ed9-4fdc-9c29-d48a9d071cfd")); var promotion2 = new Promotion( "DHANA20TOK", new Token(250), duration, new DateTimeProvider(startedAt + duration)); promotion2.SetEntityId(PromotionId.Parse("263aa2ed-3f88-4070-96e6-a098814e44f3")); var promotions = new List <Promotion> { promotion1, promotion2 }; Promotions.AddRange(promotions.Where(promotion => Promotions.All(x => x.Id != promotion.Id)).Select(promotion => promotion.ToModel())); await this.CommitAsync(); }
public override int GetHashCode() { int hashPromoId = PromotionId == null ? 0 : PromotionId.GetHashCode(); return(hashPromoId); }