public override bool Equals(object obj) { return(obj is AccountAuctionRelationDTO dTO && AccountId.Equals(dTO.AccountId) && AuctionId.Equals(dTO.AuctionId) && BidValue.Equals(dTO.BidValue)); }
public BidHistory(AuctionId auctionId, long bidderId, Money offer, DateTime createDateTime) { this.Id = Guid.NewGuid(); this.AuctionId = auctionId; this.BidderId = bidderId; this.Offer = offer; this.CreateDateTime = createDateTime; }
public void Handle(CreateBidHistoryCommand command) { var auctionId = new AuctionId(command.AuctionId); var money = new Money(command.OfferedAmount, "USD"); var bidHistory = new BidHistory(auctionId, command.BidderId, money, command.CreateDateTime); _repository.Add(bidHistory); }
public AuctionBuilder() { this._price = 1000; this._auctionId = new AuctionId(1); this._endDateTime = DateTime.Now.AddYears(1); this._seller = new Participant(1, true); this._service = new FakeAuctionService(false); }
public AuctionItemAddedEventHandlerTests() { _readStore = new InMemoryReadStore(); _auctionId = new AuctionId(); _readStore.AddAuction(_auctionId, "New"); _handler = new AuctionItemAddedEventHandler(_readStore); }
public void Handle(PlaceBidOnAuctionCommand command) { var id = new AuctionId(command.AuctionId); var auction = this._repository.GetById(id); var money = new Money(command.Amount, "USD"); var bid = new Bid(command.BidderId, money); auction.PlaceBid(bid); }
public AuctionItemRemovedEventHandlerTests() { _auctionId = new AuctionId(); _readStore = new InMemoryReadStore(); _readStore.AddAuction(_auctionId, "something"); _readStore.AddAuctionItem(_auctionId, "idk"); _handler = new AuctionItemRemovedEventHandler(_readStore); }
public AuctionItemUpdatedEventHandlerTests() { _auctionId = new AuctionId(); _readStore = new InMemoryReadStore(); _readStore.AddAuction(_auctionId, "idk"); _readStore.AddAuctionItem(_auctionId, "existing", "don", "what"); _handler = new AuctionItemUpdatedEventHandler(_readStore); }
public AuctionUpdatedEventHandlerTests() { _auctionId = new AuctionId(); _originalAuctionDate = DateTimeOffset.UtcNow; _readStore = new InMemoryReadStore(); _readStore.AddAuction(_auctionId, "bob", _originalAuctionDate); _handler = new AuctionUpdatedEventHandler(_readStore); }
public async Task InitializeAsync() { var auction = new Core.Auctions.Auction("some", DateTimeOffset.UtcNow); var eventStore = new InMemoryEventStore(); await auction.CommitAsync(eventStore); _existingAuctionId = auction.Id; _validator = new AddAuctionItemCommandValidator(eventStore); }
public override int GetHashCode() { int hash = 11; hash = hash * 13 + Id.GetHashCode(); hash = hash * 13 + Price.GetHashCode(); hash = hash * 13 + BidTime.GetHashCode(); hash = hash * 13 + BidOwnerId.GetHashCode(); hash = hash * 13 + AuctionId.GetHashCode(); return(hash); }
public override int GetHashCode() { unchecked { var hashCode = Id.GetHashCode(); hashCode = (hashCode * 397) ^ Amount.GetHashCode(); hashCode = (hashCode * 397) ^ UserId.GetHashCode(); hashCode = (hashCode * 397) ^ AuctionId.GetHashCode(); hashCode = (hashCode * 397) ^ DateTime.GetHashCode(); return(hashCode); } }
public async Task InitializeAsync() { var auction = new Core.Auctions.Auction("one", DateTimeOffset.UtcNow); auction.AddAuctionItem(new AuctionItem(ItemName, "donor")); _existingAuctionId = auction.Id; var eventStore = new InMemoryEventStore(); await auction.CommitAsync(eventStore); _validator = new RemoveAuctionItemCommandValidator(eventStore); }
public async Task InitializeAsync() { var auction = new Core.Auctions.Auction("one", DateTimeOffset.UtcNow); auction.AddAuctionItem(new AuctionItem(AuctionItemName, "bill")); _eventStore = new InMemoryEventStore(); await auction.CommitAsync(_eventStore); _auctionId = auction.Id; _handler = new UpdateAuctionItemCommandHandler(_eventStore); }
public UpdateAuctionItemCommand( AuctionId auctionId, string oldItemName, string newItemName = null, string donor = null, string description = null, int?quantity = null) { AuctionId = auctionId; OldItemName = oldItemName; NewItemName = newItemName; Donor = donor; Description = description; Quantity = quantity; }
public async Task WhenGettingAuctionItemsThenReturnsPopulatedAuctionItems() { var auctionId = new AuctionId(); _readStore.AddAuction(auctionId); _readStore.AddAuctionItem(auctionId, "shirts", "donor", "desc", 54); var viewModel = await _handler.HandleAsync(new GetAuctionItemsListQuery(auctionId)); var itemViewModel = viewModel.Items[0]; Assert.Equal("shirts", itemViewModel.Name); Assert.Equal("donor", itemViewModel.Donor); Assert.Equal("desc", itemViewModel.Description); Assert.Equal(54, itemViewModel.Quantity); }
public static AuctionReadModel AddAuction( this InMemoryReadStore store, AuctionId auctionId = null, string name = null, DateTimeOffset?auctionDate = null) { var entry = store.Add(new AuctionReadModel { Id = auctionId ?? new AuctionId(), Name = name ?? $"{Guid.NewGuid()}", AuctionDate = auctionDate.GetValueOrDefault(DateTimeOffset.UtcNow) }); store.SaveChanges(); return(entry.Entity); }
public async Task WhenListIsQueriedThenPopulatesViewModelsFromReadModel() { var auctionId = new AuctionId(); var auction = _readStore.AddAuction(auctionId); _readStore.AddAuctionItem(auctionId, "other"); _readStore.AddAuctionItem(auctionId, "three"); _readStore.AddAuctionItem(auctionId, "one"); var viewModel = await _handler.HandleAsync(new GetAuctionsListQuery()); var auctionListItem = viewModel.Items[0]; Assert.Equal(auction.Id, auctionListItem.Id); Assert.Equal(auction.Name, auctionListItem.Name); Assert.Equal(auction.AuctionDate, auctionListItem.AuctionDate); Assert.Equal(3, auctionListItem.ItemCount); }
public async Task WhenGettingAuctionItemsThenReturnsItemsMatchingAuctionId() { var auctionId = new AuctionId(); _readStore.AddAuction(auctionId); _readStore.AddAuctionItem(auctionId, "shirts", "donor"); _readStore.AddAuctionItem(auctionId, "shoes", "donor"); _readStore.AddAuctionItem(auctionId, "shorts", "donor"); var otherAuctionId = new AuctionId(); _readStore.AddAuction(otherAuctionId); _readStore.AddAuctionItem(otherAuctionId, "nope", "bob"); var viewModel = await _handler.HandleAsync(new GetAuctionItemsListQuery(auctionId)); Assert.Equal(3, viewModel.Items.Length); }
public static AuctionItemReadModel AddAuctionItem( this InMemoryReadStore store, AuctionId auctionId, string name, string donor = null, string description = null, int quantity = 1) { var entry = store.Add(new AuctionItemReadModel { Description = description, Donor = donor, AuctionId = auctionId, Name = name, Quantity = quantity }); store.SaveChanges(); return(entry.Entity); }
public UpdateAuctionCommand(AuctionId auctionId, string name, DateTimeOffset?auctionDate) { AuctionId = auctionId; Name = name; AuctionDate = auctionDate; }
public AuctionBuilder WithId(AuctionId id) { this._auctionId = id; return(this); }
public BidderAddedToAuction(AuctionId id, string bidderName) { Id = id; BidderName = bidderName; }
public AddAuctionItemCommand(AuctionId auctionId, AuctionItem auctionItem) { AuctionId = auctionId; AuctionItem = auctionItem; }
public BidPlacedOnItem(AuctionId id, string bidderName) { Id = id; BidderName = bidderName; }
public AuctionOpened(AuctionId id, string auctionName) { Id = id; AuctionName = auctionName; }
public OpenAuction(AuctionId id, string auctionName) { Id = id; AuctionName = auctionName; }
public MissingAuctionItemException(AuctionId auctionId, string name) : base($"Auction {auctionId} does not have an item with name {name}.") { }
public DuplicateAuctionItemException(AuctionId id, string name) : base($"Auction {id} already has an item with name {name}.") { }