public void AddNewAuction_WhenEmptyName_WillThrowException()
        {
            var auctionToAdd = new Auction()
            {
                AuctionName = ""
            };

            var ex = Assert.Throws <ArgumentException>(() => AuctionsService.AddNewAuction(auctionToAdd));

            StringAssert.Contains("AuctionName can't be empty", ex.Message);
        }
        public void ClearAllAuctions_Always_WillDeleteAllAuctions()
        {
            var auctionToAdd = new Auction()
            {
                AuctionName = "Auction1"
            };

            AuctionsService.AddNewAuction(auctionToAdd);

            AuctionsService.ClearAllAuctions();

            CollectionAssert.IsEmpty(AuctionsService.GetAllAuctions());
        }
        public void AddNewAuction_WhenAddingValidAuction_WillSaveWithNewId()
        {
            var auctionToAdd = new Auction()
            {
                AuctionName = "Auction1"
            };

            AuctionsService.AddNewAuction(auctionToAdd);

            var addedAuction = AuctionsService.GetAllAuctions().Single();

            Assert.AreEqual(1, addedAuction.Id);
        }
        public void AddNewAuction_WhenValidName_WillBeSaved()
        {
            var auctionToAdd = new Auction()
            {
                AuctionName = "Test-Auction"
            };

            AuctionsService.AddNewAuction(auctionToAdd);

            var allAuctions = AuctionsService.GetAllAuctions();

            CollectionAssert.Contains(allAuctions, auctionToAdd);
        }
        public void AddNewAuction_WhenAddingSecondAuction_WillSaveWithNewIdIncreasedBy1()
        {
            var auctionToAdd = new Auction()
            {
                AuctionName = "Auction1"
            };

            AuctionsService.AddNewAuction(auctionToAdd);
            var secondAuctionToAdd = new Auction()
            {
                AuctionName = "Auction2"
            };

            AuctionsService.AddNewAuction(secondAuctionToAdd);

            var lastAddedAuction = AuctionsService.GetAllAuctions().Last(a => a.AuctionName == "Auction2");

            Assert.AreEqual(2, lastAddedAuction.Id);
        }
 public IHttpActionResult AddAuction(Auction auction)
 {
     auction = AuctionsService.AddNewAuction(auction);
     return(Ok(auction));
 }