public void UserCannotBuyHisOwnAuctions()
		{
			var auction = new TestAuction
			{
				SellerId = "1",
				EndDate  = DateTime.Now.Add(TimeSpan.FromDays(2)),
			};

			var result = mTestedService.CanBeBought(auction, buyerId: "1");

			Assert.That(result, Is.False);
		}
		public void WhenAuctionIsInactive_ItCannotBeBought()
		{
			var auction = new TestAuction
			{
				SellerId = "1",
				EndDate  = DateTime.Now.Subtract(TimeSpan.FromDays(2)),
			};

			var result = mTestedService.CanBeBought(auction, buyerId: "2");

			Assert.That(result, Is.False);
		}
		public void WhenAuctionIsAlreadySold_ItCannotBeBoughtAgain()
		{
			var auction = new TestAuction
			{
				SellerId    = "1",
				EndDate     = DateTime.Now.Add(TimeSpan.FromDays(2)),
				BuyoutPrice = new Money(100, new TestCurrency()),
				Offers      = new Collection<BuyOffer> { new TestBuyOffer { UserId = "3", Amount = 100 } }
			};

			auction.Offers.Single().Auction = auction;

			var result = mTestedService.CanBeBought(auction, buyerId: "2");

			Assert.That(result, Is.False);
		}
Ejemplo n.º 4
0
		private void AddAuctionsToCategory(AuctioneerDbContext context,
		                                   int categoryId,
		                                   int auctionCount,
		                                   AuctionStatus status = AuctionStatus.Active)
		{
			for(int i = 0; i < auctionCount; ++i)
			{
				var auction = new TestAuction
				{
					CategoryId  = categoryId,
					EndDate     = (status != AuctionStatus.Expired) ? DateTime.Now.Add(TimeSpan.FromDays(1))
					                                                : DateTime.Now.Subtract(TimeSpan.FromDays(1)),
					BuyoutPrice = new Money(10, new TestCurrency())
				};

				if(status == AuctionStatus.Sold)
				{
					auction.Offers.Add(new TestBuyOffer { Amount = 10 } );
				}

				context.Auctions.Add(auction);
			}
		}
Ejemplo n.º 5
0
		public async Task RemovalOfAuctionsAfterSomeoneRaisedAnOfferIsNotAllowed()
		{
			var auction = new TestAuction
			{
				SellerId = "2",
				EndDate  = DateTime.Now.Add(TimeSpan.FromDays(2)),
				Offers   = new Collection<BuyOffer> { new TestBuyOffer() }
			};

			var result = await mTestedService.CanBeRemoved(auction, userId: "2");

			Assert.That(result, Is.False);
		}