Exemplo n.º 1
0
 public override bool Equals(object obj)
 {
     return(obj is AccountAuctionRelationDTO dTO &&
            AccountId.Equals(dTO.AccountId) &&
            AuctionId.Equals(dTO.AuctionId) &&
            BidValue.Equals(dTO.BidValue));
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 8
0
        public AuctionItemUpdatedEventHandlerTests()
        {
            _auctionId = new AuctionId();

            _readStore = new InMemoryReadStore();
            _readStore.AddAuction(_auctionId, "idk");
            _readStore.AddAuctionItem(_auctionId, "existing", "don", "what");

            _handler = new AuctionItemUpdatedEventHandler(_readStore);
        }
Exemplo n.º 9
0
        public AuctionUpdatedEventHandlerTests()
        {
            _auctionId           = new AuctionId();
            _originalAuctionDate = DateTimeOffset.UtcNow;

            _readStore = new InMemoryReadStore();
            _readStore.AddAuction(_auctionId, "bob", _originalAuctionDate);

            _handler = new AuctionUpdatedEventHandler(_readStore);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
 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);
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
 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;
 }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 18
0
        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);
        }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 21
0
 public UpdateAuctionCommand(AuctionId auctionId, string name, DateTimeOffset?auctionDate)
 {
     AuctionId   = auctionId;
     Name        = name;
     AuctionDate = auctionDate;
 }
Exemplo n.º 22
0
 public AuctionBuilder WithId(AuctionId id)
 {
     this._auctionId = id;
     return(this);
 }
Exemplo n.º 23
0
 public BidderAddedToAuction(AuctionId id, string bidderName)
 {
     Id = id;
     BidderName = bidderName;
 }
 public AddAuctionItemCommand(AuctionId auctionId, AuctionItem auctionItem)
 {
     AuctionId   = auctionId;
     AuctionItem = auctionItem;
 }
Exemplo n.º 25
0
 public BidPlacedOnItem(AuctionId id, string bidderName)
 {
     Id = id;
     BidderName = bidderName;
 }
Exemplo n.º 26
0
 public AuctionOpened(AuctionId id, string auctionName)
 {
     Id = id;
     AuctionName = auctionName;
 }
Exemplo n.º 27
0
 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}.")
 {
 }