public void CreateAuction_Is_Idempotent() { // arrange var auction = new Auction("a1", new AuctionState()); // act auction.Create("s1", new Item(), 10, Samples.YesterdayAndTomorrowWindow); auction.Create("s1", new Item(), 10, Samples.YesterdayAndTomorrowWindow); // assert Assert.That(auction.Changes.Count(), Is.EqualTo(1)); Assert.That(auction.Changes.First().Payload, Is.InstanceOf<AuctionCreated>()); }
public void CreateAuction_Is_Idempotent() { // arrange var auction = new Auction("a1", new AuctionState()); // act auction.Create("s1", new Item(), 10, Samples.YesterdayAndTomorrowWindow); auction.Create("s1", new Item(), 10, Samples.YesterdayAndTomorrowWindow); // assert Assert.That(auction.Changes.Count(), Is.EqualTo(1)); Assert.That(auction.Changes.First().Payload, Is.InstanceOf <AuctionCreated>()); }
public ActionResult CreateAuction(FormCreateAuction fcAuction) { User u = (User)Session[KeysUtils.SessionUser()]; if (u == null) { u = (User)Session[KeysUtils.SessionAdmin()]; if (u == null) { return(RedirectToAction("Index", "Home")); } } if (ModelState.IsValid) { Auction a = Auction.Create(fcAuction, u.user_id); a.save(); ViewBag.Status = true; ViewBag.Message = "Successfuly creaed auction"; } else { ViewBag.Message = "Invalid request"; } return(View(fcAuction)); }
public void TestSellerCanCreateAuction() { // Set up user manager User seller = CreateDefaultUser(); UserManager userManager = new UserManager(); bool registerSuccess = userManager.Register(seller); userManager.SetSeller(seller.UserName); userManager.LogIn(seller.UserName, anyPassword, out UserManagerStatus status); // Auction information string itemDesc = "Laptop"; decimal startingPrice = 100; DateTime startTime = DateTime.Now.AddDays(1); DateTime endTime = startTime.AddDays(5); // seller, desc, startingPrice, startTime, endTime // constraints - user must be a seller, seller logged in // start time > now, end time> start time Auction auction = Auction.Create(seller, itemDesc, startingPrice, startTime, endTime); Assert.IsNotNull(auction, "Auction can not be created"); Assert.AreEqual(auction.Seller.UserName, anyUserName, "Username does not match"); Assert.AreEqual(auction.ItemDesc, itemDesc, "Item description does not match"); Assert.AreEqual(auction.StartingPrice, startingPrice, "Username does not match"); Assert.AreEqual(auction.StartingPrice, auction.CurrentPrice, "At the beginning of the auction, starting price should equal current price."); Assert.AreEqual(auction.StartTime, startTime, "Username does not match"); Assert.AreEqual(auction.EndTime, endTime, "Username does not match"); }
public static Auction Translate(GetAuctionRequest model) => model != null?Auction.Create( userId : model.UserId, name : model.Name, initialValue : model.InitialValue, used : model.Used, startDate : model.StartDate, endDate : model.EndDate ) : Auction.Create();
public void AddAuction(Auction newAuction) { if (newAuction == null) return; auctions.Add(newAuction.ItemLowId, newAuction); items.Add(newAuction.ItemLowId); //if this is a new one created by player, it should be save in database if (newAuction.IsNew) { newAuction.Create(); } }
public async Task CreateAuctionAsync(AuctionCommand auctionCommand, Guid userId) { var auction = await _repository.GetAsync(auctionCommand.Url); if (auction != null) { throw new Exception("Auction already existing in database."); } Auction auctionNew = Auction.Create(auctionCommand.AuctionName, auctionCommand.Url, auctionCommand.IsActive, userId); await _repository.AddAsync(auctionNew); }
public static Auction CreateTestAuction(decimal? minPrice = null, Window window = null) { var auction = new Auction("test-auction-id", new AuctionState()); var price = minPrice ?? 10; window = window ?? new Window { Start = DateTime.UtcNow.AddDays(-1), End = DateTime.UtcNow.AddDays(1) }; auction.Create( "test-seller-id", new Item { Id = "test-item-id", Name = "item name" }, price, window); // create a new aggregate from the state, to ensure the aggregate doesn't come with changes return AggregateFactory.For<Auction>().CreateFromState(auction.Id, auction.State); }
Auction CreateDefaultAuction() { User seller = CreateDefaultUser(); seller.LoggedIn = true; seller.IsSeller = true; // Auction information string itemDesc = "Laptop"; DateTime startTime = DateTime.Now.AddDays(1); DateTime endTime = startTime.AddDays(5); Auction auction = Auction.Create(seller, itemDesc, anyStartingPrice, startTime, endTime); Assert.IsNotNull(auction, "Auction was not created"); return(auction); }
public static Auction CreateTestAuction(decimal?minPrice = null, Window window = null) { var auction = new Auction("test-auction-id", new AuctionState()); var price = minPrice ?? 10; window = window ?? new Window { Start = DateTime.UtcNow.AddDays(-1), End = DateTime.UtcNow.AddDays(1) }; auction.Create( "test-seller-id", new Item { Id = "test-item-id", Name = "item name" }, price, window); // create a new aggregate from the state, to ensure the aggregate doesn't come with changes return(AggregateFactory.For <Auction>().CreateFromState(auction.Id, auction.State)); }
private Auction MockAuction() { return(Auction.Create(userId: 1, "Mocked", initialValue: 100, startDate: DateTime.Now, endDate: DateTime.Now, used: false)); }