public void CreateBidsByService(IList <Bid> bids) { foreach (var bid in bids) { LinkBidToScenarioAuction(bid); BidsService.PlaceBid(bid); } }
public void PlaceBid_WithNullBid_WillThrowException() { TestDelegate act = () => BidsService.PlaceBid(null); var ex = Assert.Throws <ArgumentNullException>(act); StringAssert.Contains("Value cannot be null.\r\nParameter name: bid", ex.Message); }
private Bid CreateBid(int auctionId, string username, double price) { Bid bid = new Bid() { Username = username, Price = price, AuctionId = auctionId }; BidsService.PlaceBid(bid); return(bid); }
public void PlaceBid_WithInvalidPrice_WillThrowException(double price) { Bid bid = new Bid() { Username = "******", Price = price }; TestDelegate act = () => BidsService.PlaceBid(bid); var ex = Assert.Throws <ArgumentException>(act); StringAssert.Contains("Invalid price, price should be greater than 0", ex.Message); }
public void PlaceBid_WithInvalidUsername_WillThrowException(string username) { Bid bid = new Bid() { Price = 10, Username = username }; TestDelegate act = () => BidsService.PlaceBid(bid); var ex = Assert.Throws <ArgumentException>(act); StringAssert.Contains("Username can't be null", ex.Message); }
public void PlaceBid_WithoutAuctionId_WillThrowException() { Bid bid = new Bid() { Username = "******", Price = 11 }; TestDelegate act = () => BidsService.PlaceBid(bid); var ex = Assert.Throws <ArgumentException>(act); StringAssert.Contains("AuctionId can't be null", ex.Message); }
public void PlaceBid_WithValidUsernameAndPrice_WillBeSaved(double price, string username) { var newBid = new Bid() { Price = price, Username = username, AuctionId = 1 }; BidsService.PlaceBid(newBid); var bids = BidsService.GetAllBids(1); var actualBid = bids.First(); actualBid.ShouldCompare(newBid); }
public void GetAllBids_WhenThereAreBids_WillReturnAllBidsSortedByPrice() { var bid11 = CreateBid(1, "User1", 11); var bid14 = CreateBid(1, "User2", 14); var bid05 = CreateBid(1, "User3", 0.5); var bid12 = CreateBid(1, "User4", 12); var allBids = BidsService.GetAllBids(1); var expected = new List <Bid>() { bid14, bid12, bid11, bid05 }.AsReadOnly(); expected.ShouldCompare(allBids); }
public void PlaceBid_UpdatePrice_WillUpdateTheLastBid() { var firstBid = new Bid() { AuctionId = 1, Price = 10, Username = "******" }; BidsService.PlaceBid(firstBid); var secondBid = new Bid() { AuctionId = 1, Price = 12, Username = "******" }; BidsService.PlaceBid(secondBid); var allBids = BidsService.GetAllBids(1); Assert.AreEqual(1, allBids.Count); allBids[0].ShouldCompare(secondBid); }
public IHttpActionResult PlaceBid(Bid bid) { if (bid == null) { return(BadRequest("Bid cannot be empty!")); } if (!bid.Price.HasValue) { return(BadRequest("Price cannot be empty!")); } if (string.IsNullOrEmpty(bid.Username)) { return(BadRequest("Username cannot be empty!")); } if (bid.Price <= 0) { return(BadRequest("Price must be greater than 0")); } BidsService.PlaceBid(bid); return(Ok()); }
public ActionResult Status() { BidsService bidsService = new BidsService(); BidStatusViewModel model = new BidStatusViewModel(); string ID = User.Identity.GetUserId(); var model1 = new List <BidStatusViewModel>(); List <string> TitleAmountList = new List <string>(); var nobids = bidsService.NoOfBids(ID); int no = nobids.Count(); for (int i = 0; i < no; i++) { model.Bids = bidsService.GetBidByUserID(ID, nobids[i]); TitleAmountList = bidsService.GetBidByID(model.Bids, ID); var Title = TitleAmountList[0]; var BidAmount1 = Convert.ToDecimal(TitleAmountList[1]); var BidAmount = Convert.ToDecimal(TitleAmountList[2]); var EndingTime = Convert.ToDateTime(TitleAmountList[3]); model1.Add(new BidStatusViewModel { BidID = ID, Title = Title, BidAmount1 = BidAmount1, BidAmount = BidAmount, EndingTime = EndingTime }); // model1.Add(new BidStatusViewModel { BidAmount1 = BidAmount1 }); /// model1.Add(new BidStatusViewModel { BidAmount = BidAmount }); // model1.Add(new BidStatusViewModel { EndingTime = EndingTime }); // Amount = TitleAmountList // var latestBidder = model.Bid.OrderByDescending(s => s.UserID == ID).FirstOrDefault(); // model.LatestBidder = latestBidder != null ? latestBidder.User : null; } return(View(model1)); }
public JobsController(JobsService js, BidsService bs) { _js = js; _bs = bs; }
public ContractorsController(ContractorsService service, BidsService bidsService) { _service = service; _bidsService = bidsService; }
public void SetUp() { BidsService.ClearAllBids(); }
public IList <Bid> GetAllBidsFromService() { return(BidsService.GetAllBids(LastAuctionId)); }
public BidsController(BidsService bs) { _bs = bs; }
public IHttpActionResult GetAllBids(int auctionId) { var allBids = BidsService.GetAllBids(auctionId); return(Ok(allBids)); }
public BidsController(BidsService bservice) { _bservice = bservice; }
public JobsController(JobsService js, BidsService bs) { _service = js; }
public BidsController(BidsService service) { _service = service; }
public void TearDown() { BidsService.ClearAllBids(); }
public ContractorsController(ContractorsService cs, BidsService bs) { _cs = cs; _bs = bs; }
private async void SendAlarm(BidType type) { if (IsBusy) { return; } IsBusy = true; if (Device.RuntimePlatform == Device.Android) { if (!await CheckPermission(Permission.Location, "Для отправки тревоги, необходимо разрешение на использование геоданных.")) { IsBusy = false; return; } } var guid = Guid.NewGuid(); var user = App.User; bool res = false; IBidsService service = new BidsService { AccessToken = (string)user.UserToken.Token.Clone(), TokenType = (string)user.UserToken.TokenType.Clone() }; try { res = await service.CreateBid(new Bid { Guid = guid, Client = user, Location = await Location.GetCurrentGeolocationAsync(GeolocationAccuracy.Best), Status = BidStatus.PendingAcceptance, Type = type }); } catch (Exception e) { Console.WriteLine(e); } if (res) { if (type == BidType.Call) { App.Call("+7 911 447-11-83"); } else if (type == BidType.Alert) { await Application.Current.MainPage.DisplayAlert("Внимание", "Тревога отправлена", "OK"); } await Task.Run(() => { DependencyService.Get <ILocationTrackingService>() .StartService(guid); }); } else { if (string.IsNullOrEmpty(service.LastError)) { await Application.Current.MainPage.DisplayAlert("Внимание", "Ошибка сервера.", "Ок"); } else { await Application.Current.MainPage.DisplayAlert("Внимание", service.LastError, "Ок"); } } IsBusy = false; }