Пример #1
0
        public void PlacingABid_AuctionHasNotYetStarted_RaisesExecption()
        {
            var repo = new InMemoryMainRepository();
            var simpleMemberService = new SimpleMemberService(repo);
            var auction = CreateGeneratedAuction();
            auction.Seller = simpleMemberService.GetCurrentMember();

            var service = new AuctionService(repo, simpleMemberService);

            auction.StartDateTimeUtc = DateTime.UtcNow.AddDays(1);
            service.Save(auction);

            service.PlaceBid(auction, 100);
        }
Пример #2
0
        public void WithExistingAuction_AfterPlacingABid_TheBidShouldBeAssignedToAuctionAndUser()
        {
            var repo = new InMemoryMainRepository();
            var userService = new MockedMemberService(repo);
            var service = new AuctionService(repo, userService);

            var auction = CreateGeneratedAuction();

            auction.Seller = userService.Add("Seller", "*****@*****.**");

            service.Save(auction);

            // Litte hack: Manual change of start time
            auction.StartDateTimeUtc = DateTime.UtcNow.AddDays(-1);

            var bidder = userService.Add("Michael", "*****@*****.**");
            userService.SetCurrentMember(bidder);

            service.PlaceBid(auction, 51);

            Assert.AreEqual(1, auction.Bids.Count);
            Assert.AreEqual(1, bidder.Bids.Count);
        }