public void Check_Bid_Functionality() { Assert.IsTrue(PlaceBid.MakeABid(), "bidding was not successful (or there are no lots available for bidding)"); ITakesScreenshot screenshotDriver = Driver as ITakesScreenshot; Screenshot screenshot = screenshotDriver.GetScreenshot(); string timestamp = DateTime.Now.ToString("yyyyMMdd-hhmmss");//yyyy-MM-dd-hhmm screenshot.SaveAsFile(@"C:\Work\AutomationTesting.Betsold\TestResults\PlaceBid\Exception-" + timestamp + ".jpg", ScreenshotImageFormat.Jpeg); }
public void IfBidIsHigherThanPreviousBidsThenBidPlacedIsRaised() { var createAuctionCommand = Command.Create(_aggregateId, _createAuction); _subject.HandleCommand(createAuctionCommand); var placeBidCommand = Command.Create(_aggregateId, _placeBid); _subject.HandleCommand(placeBidCommand); var result = _subject.HandleCommand(Command.Create(_aggregateId, PlaceBid.Create(Bid.Create(11.5m)))); Assert.True(result is CommandResultSuccess); var newEvent = (result as CommandResultSuccess).Events.Single(); Assert.True(newEvent is BidPlaced); Assert.Equal(11.5m, (newEvent as BidPlaced).Bid.Amount); }
public ActionResult Place([FromBody] PlaceBidDto dto) { Console.WriteLine("Bid: " + JsonConvert.SerializeObject(dto)); if (!ModelState.IsValid) { return(BadRequest()); } var bid = Bid.Create(dto.Amount); var placeBid = PlaceBid.Create(bid); var command = Command.Create(dto.Id, placeBid); var result = _commandHandler.HandleCommand(command); switch (result) { case CommandResultSuccess _: return(Ok()); default: return(Conflict()); } }
public static CommandResult Handle(State state, PlaceBid placeBid) { switch (state) { case CreatedState created: if (DateTime.UtcNow >= created.EndTime) { CommandResultFailure.Create("Auction has finished"); } if (placeBid.Bid.Amount <= created.HighestBid) { CommandResultFailure.Create("Bid is not higher than current highest bid"); } var bidPlaced = BidPlaced.Create(placeBid.Bid); return(CommandResultSuccess.Create(new List <EventPayload> { bidPlaced })); default: return(CommandResultFailure.Create("Auction not created")); } }
private async Task<int> getBid(int maxBid, string playerName) { PlaceBid placeBid = new PlaceBid(maxBid); placeBid.InitializeComponent(); placeBid.Title = playerName; await placeBid.ShowAsync(); return placeBid.selectedAmount; }
public void OnBid(PlaceBid message) { MaximumBid = message.MaximumBid; Console.WriteLine("Current State " + CurrentState.Name); Console.WriteLine("Received maximum bid of $" + message.MaximumBid); }