public void TestPlaceBidWhenSold() { AuctionItem item = getAuctionItem(); item.PlaceBid(1100, "bla"); item.EvaluateIfSold(); bool success = item.PlaceBid(1200, "bla"); Assert.IsFalse(success); }
public void TestEvaluateIfSoldFalse() { AuctionItem item = getAuctionItem(); item.PlaceBid(200, "bla"); bool isSold = item.EvaluateIfSold(); Assert.IsFalse(isSold); }
public void TestPlaceBidLower() { AuctionItem item = getAuctionItem(); decimal newBid = 80; bool success = item.PlaceBid(newBid, "bla"); decimal expectedBid = 100; decimal actualBid = item.Bid; Assert.IsFalse(success); Assert.AreEqual(expectedBid, actualBid); }
public void TestPlaceBidHigher() { AuctionItem item = getAuctionItem(); decimal newBid = 120; bool success = item.PlaceBid(newBid, "bla"); decimal expectedBid = newBid; decimal actualBid = item.Bid; Assert.IsTrue(success); Assert.AreEqual(expectedBid, actualBid); }
public override void OnResponse(Server.Network.NetState sender, RelayInfo info) { if (!AuctionSystem.Running) { sender.Mobile.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[15]); return; } if (!AuctionSystem.Auctions.Contains(m_Auction)) { sender.Mobile.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[207]); if (m_Callback != null) { try { m_Callback.DynamicInvoke(new object[] { m_User }); } catch {} } return; } switch (info.ButtonID) { case 0: // Close if (m_Callback != null) { try { m_Callback.DynamicInvoke(new object[] { m_User }); } catch {} } break; case 1: // Prev item m_User.SendGump(new AuctionViewGump(m_User, m_Auction, m_Callback, m_Page - 1)); break; case 2: // Next item m_User.SendGump(new AuctionViewGump(m_User, m_Auction, m_Callback, m_Page + 1)); break; case 3: // Web link m_User.SendGump(new AuctionViewGump(m_User, m_Auction, m_Callback, m_Page)); m_Auction.SendLinkTo(m_User); break; case 4: // Bid uint bid = 0; try { bid = uint.Parse(info.TextEntries[0].Text, NumberStyles.AllowThousands); } catch {} if (m_Auction.Expired) { m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[84]); } else if (bid == 0) { m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[85]); } else { if (m_Auction.AllowBuyNow && bid >= m_Auction.BuyNow) { // Do buy now instead goto case 8; } else { m_Auction.PlaceBid(m_User, (int)bid); } } m_User.SendGump(new AuctionViewGump(m_User, m_Auction, m_Callback, m_Page)); break; case 5: // View bids m_User.SendGump(new BidViewGump(m_User, m_Auction.Bids, new AuctionGumpCallback(BidViewCallback))); break; case 6: // Staff Panel m_User.SendGump(new AuctionControlGump(m_User, m_Auction, this)); break; case 8: // Buy Now if (m_Auction.DoBuyNow(sender.Mobile)) { goto case 0; // Close the gump } else { sender.Mobile.SendGump(new AuctionViewGump(sender.Mobile, m_Auction, m_Callback, m_Page)); } break; } }
public override void OnResponse(Server.Network.NetState sender, RelayInfo info) { if (!m_Buttons.Contains(info.ButtonID)) { Console.WriteLine(@"The auction system located a potential exploit. Player {0} (Acc. {1}) tried to press an unregistered button in a gump of type: {2}" , sender.Mobile != null ? sender.Mobile.ToString() : "Unkown", sender.Mobile != null && sender.Mobile.Account != null ? (sender.Mobile.Account as Server.Accounting.Account).Username : "******", this.GetType().Name); return; } if (!AuctionSystem.Running) { sender.Mobile.SendMessage(AuctionSystem.MessageHue, AuctionSystem.ST[15]); return; } if (!AuctionSystem.Auctions.Contains(m_Auction)) { sender.Mobile.SendMessage(AuctionSystem.MessageHue, AuctionSystem.ST[207]); if (m_Callback != null) { try { m_Callback.DynamicInvoke(new object[] { m_User }); } catch {} } return; } switch (info.ButtonID) { case 0: // Close if (m_Callback != null) { try { m_Callback.DynamicInvoke(new object[] { m_User }); } catch {} } break; case 1: // Prev item m_User.SendGump(new AuctionViewGump(m_User, m_Auction, m_Callback, m_Page - 1)); break; case 2: // Next item m_User.SendGump(new AuctionViewGump(m_User, m_Auction, m_Callback, m_Page + 1)); break; case 3: // Web link m_User.SendGump(new AuctionViewGump(m_User, m_Auction, m_Callback, m_Page)); m_Auction.SendLinkTo(m_User); break; case 4: // Bid uint bid = 0; try { bid = uint.Parse(info.TextEntries[0].Text); } catch {} if (m_Auction.Expired) { m_User.SendMessage(AuctionSystem.MessageHue, AuctionSystem.ST[84]); } else if (bid == 0) { m_User.SendMessage(AuctionSystem.MessageHue, AuctionSystem.ST[85]); } else { if (m_Auction.AllowBuyNow && bid >= m_Auction.BuyNow) { // Do buy now instead goto case 8; } else { m_Auction.PlaceBid(m_User, (int)bid); } } m_User.SendGump(new AuctionViewGump(m_User, m_Auction, m_Callback, m_Page)); break; case 5: // View bids m_User.SendGump(new BidViewGump(m_User, m_Auction.Bids, new AuctionGumpCallback(BidViewCallback))); break; case 6: // Staff Panel m_User.SendGump(new AuctionControlGump(m_User, m_Auction, this)); break; case 8: // Buy Now if (m_Auction.DoBuyNow(sender.Mobile)) { goto case 0; // Close the gump } else { sender.Mobile.SendGump(new AuctionViewGump(sender.Mobile, m_Auction, m_Callback, m_Page)); } break; } }
public override void OnResponse(Server.Network.NetState sender, RelayInfo info) { if (!AuctionSystem.Running) { sender.Mobile.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[15]); return; } if (!AuctionSystem.Auctions.Contains(m_Auction)) { sender.Mobile.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[207]); if (m_Callback != null) { try { m_Callback.DynamicInvoke(new object[] { m_User }); } catch { } } return; } int buttonid = info.ButtonID; if (buttonid < 0 || buttonid > 9) { sender.Mobile.SendMessage("Invalid option. Please try again."); return; } switch (info.ButtonID) { case 0: // Close if (m_Callback != null) { try { m_Callback.DynamicInvoke(new object[] { m_User }); } catch {} } break; case 1: // Prev item m_User.SendGump(new AuctionViewGump(m_User, m_Auction, m_Callback, m_Page - 1)); break; case 2: // Next item m_User.SendGump(new AuctionViewGump(m_User, m_Auction, m_Callback, m_Page + 1)); break; case 3: // Web link m_User.SendGump(new AuctionViewGump(m_User, m_Auction, m_Callback, m_Page)); m_Auction.SendLinkTo(m_User); break; case 4: // Bid uint bid = 0; try { bid = uint.Parse(info.TextEntries[0].Text, NumberStyles.AllowThousands); } catch {} if (m_Auction.Expired) { m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[84]); } else if (bid == 0) { m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[85]); } else { if (m_Auction.AllowBuyNow && bid >= m_Auction.BuyNow) { // Do buy now instead goto case 8; } else { m_Auction.PlaceBid(m_User, (int)bid); } } m_User.SendGump(new AuctionViewGump(m_User, m_Auction, m_Callback, m_Page)); break; case 5: // View bids m_User.SendGump(new BidViewGump(m_User, m_Auction.Bids, new AuctionGumpCallback(BidViewCallback))); break; case 6: // Staff Panel m_User.SendGump(new AuctionControlGump(m_User, m_Auction, this)); break; case 7: // Owner Cancel Auction m_Auction.End(m_User); // m_Auction.StaffDelete(m_User, ItemFate.ReturnToOwner); break; case 8: // Buy Now if (m_Auction.DoBuyNow(sender.Mobile)) { goto case 0; // Close the gump } else { sender.Mobile.SendGump(new AuctionViewGump(sender.Mobile, m_Auction, m_Callback, m_Page)); } break; case 9: // Quick Bid // Minimum bid amount for quick bids int quickbid = m_Auction.MinBid; if (m_Auction.HasBids) { quickbid = m_Auction.HighestBid.Amount + m_Auction.BidIncrement; } if (m_Auction.Expired) { m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[84]); } else if (quickbid == 0) { m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[85]); } else { if (m_Auction.AllowBuyNow && quickbid >= m_Auction.BuyNow) { // Do buy now instead goto case 8; } else { m_Auction.PlaceBid(m_User, (int)quickbid); } } m_User.SendGump(new AuctionViewGump(m_User, m_Auction, m_Callback, m_Page)); break; } }