public void DeleteUser_WinnnerInAuction_null() { var userSession = Site.Login(UserName, Pw); const string sellerName = "very lucky seller"; const string sellerPw = "seller's password"; Site.CreateUser(sellerName, sellerPw); var seller = Site.GetUsers().SingleOrDefault(u => u.Username == sellerName); var sellerSession = Site.Login(sellerName, sellerPw); var randomGen = new Random(); var startingPrice = randomGen.NextDouble() * 100 + 1; var auction = sellerSession.CreateAuction($"The th auction for {sellerName}", AlarmClock.Object.Now.AddDays(1), startingPrice); auction.BidOnAuction(userSession, startingPrice * 2); var user = Site.GetUsers().SingleOrDefault(u => u.Username == UserName); var now = AlarmClock.Object.Now; AlarmClock.Setup(ac => ac.Now).Returns(now.AddHours(25)); Site = siteFactory.LoadSite(connectionString, Site.Name, AlarmClock.Object); //needed to refresh time user.Delete(); var auction1 = Site.GetAuctions(false).SingleOrDefault(x => x.Id == auction.Id); var usr = auction1.CurrentWinner(); Assert.That(usr, Is.Null); }
public void GetAuctions_TwoSites() { var now = AlarmClock.Object.Now; AddAuctions(Site1, now.AddDays(1), 2); AddAuctions(Site2, now.AddDays(1), 1); Assert.That(Site1.GetAuctions(false).Count(), Is.EqualTo(2)); }
#pragma warning restore CS0246 // Il nome di tipo o di spazio dei nomi 'TestAttribute' non è stato trovato. Probabilmente manca una direttiva using o un riferimento all'assembly. #pragma warning restore CS0246 // Il nome di tipo o di spazio dei nomi 'Test' non è stato trovato. Probabilmente manca una direttiva using o un riferimento all'assembly. public void Delete_ExistingAuction_Deletes() { var auctionId = TheAuction.Id; TheAuction.Delete(); var deletedAuctionSurvives = Site.GetAuctions(false).Any(a => a.Id == auctionId); Assert.That(!deletedAuctionSurvives); }
public void GetAuctions_ValidArg_ReturnsEnumerableOf5() { var now = AlarmClock.Object.Now; var expectedAuctions = AddAuctions(now.AddDays(1), 2).Concat(AddAuctions(now.AddDays(12), 3)); AlarmClock.Setup(ac => ac.Now).Returns(now.AddHours(25)); Site = siteFactory.LoadSite(connectionString, Site.Name, AlarmClock.Object); //needed to refresh time var auctions = Site.GetAuctions(false); Assert.That(auctions, Is.EquivalentTo(expectedAuctions)); }
public void GetAuctions_ValidArg_ReturnsEmpty2() { var now = AlarmClock.Object.Now; AddAuctions(now.AddDays(1), 5); AlarmClock.Setup(ac => ac.Now).Returns(now.AddHours(25)); Site = siteFactory.LoadSite(connectionString, Site.Name, AlarmClock.Object); //needed to refresh time var auctions = Site.GetAuctions(true); Assert.That(auctions, Is.Empty); }
public void LoadSite_ValidArg_ReturnsFullSite7() { newSite = siteFactory.LoadSite(connectionString, siteName, alarmClockMoq.Object); var auctionList = newSite.GetAuctions(false).ToList(); Assert.That(auctionList.Count(), Is.EqualTo(2)); var barbaraAuction = auctionList.SingleOrDefault(a => a.Seller.Username == barbara); Assert.That(CheckAuctionValues(barbaraAuction, expectedAuctionList.SingleOrDefault(a => a.Seller.Username == barbara).Id, barbara, barbaraAuctionEndsOn, barbaraAuctionDescription, 8.25, carlotta)); var aliceAuction = auctionList.SingleOrDefault(a => a.Seller.Username == alice); Assert.That(CheckAuctionValues(aliceAuction, expectedAuctionList.SingleOrDefault(a => a.Seller.Username == alice).Id, alice, aliceAuctionEndsOn, aliceAuctionDescription, .25, null)); }
public void GetAuctions_OnDeletedObject_Throws() { Site.Delete(); Assert.That(() => Site.GetAuctions(true), Throws.TypeOf <InvalidOperationException>()); }
public void LoadSite_ValidArg_ReturnsSiteWithSessions6() { CollectionAssert.IsEmpty(newSite.GetAuctions(false)); }
public void LoadSite_ValidArg_ReturnsSiteWithUsers6() { Assert.That(newSite.GetAuctions(false), Is.EquivalentTo(new List <IAuction>())); }
public void Delete_CreatorOf_Auction_Ended() { SetNowToFutureTime(SecondsInADay * 4, AlarmClock); Seller.Delete(); Assert.That(Site.GetAuctions(false), Is.Empty); }
public void GetAuctions_ValidArg_ReturnsNotNull1() { var auctions = Site.GetAuctions(false); Assert.That(auctions, Is.Not.Null); }
public void CreateAuction_DbValidArg_Id() { Assert.That(Site.GetAuctions(false).Select(a => a.Id), Is.Not.Null); }