public void AddBid(Member memberParam, decimal amountParam) { if (Bids.Count() == 0 || amountParam > Bids.Max(e => e.BidAmount)) { Bids.Add(new Bid() { BidAmount = amountParam, DatePlaced = DateTime.Now, Member = memberParam }); } else { throw new InvalidOperationException("Bid amount too low"); } }
public void CanAddBid() { // Arrange - set up the scenario Item target = new Item(); Member memberParam = new Member(); Decimal amountParam = 150M; // Act - perform the test target.AddBid(memberParam, amountParam); // Assert - check the behavior Assert.AreEqual(1, target.Bids.Count()); Assert.AreEqual(amountParam, target.Bids[0].BidAmount); }
public void CanAddHigherBid() { // Arrange Item target = new Item(); Member firstMember = new Member(); Member secondMember = new Member(); Decimal amountParam = 150M; // Act target.AddBid(firstMember, amountParam); target.AddBid(secondMember, amountParam + 10); // Assert Assert.AreEqual(2, target.Bids.Count()); Assert.AreEqual(amountParam + 10, target.Bids[1].BidAmount); }
public void CannotAddLowerBid() { // Arrange Item target = new Item(); Member memberParam = new Member(); Decimal amountParam = 150M; // Act & Assert target.AddBid(memberParam, amountParam); try { target.AddBid(memberParam, amountParam - 10); Assert.Fail("An exception should be thrown when adding a lower bid"); } catch (Exception ex) { Assert.IsInstanceOfType(ex, typeof(InvalidOperationException)); } }
public void CanChangeLoginName() { // Arrange (set up a scenario) Member bob = new Member() { LoginName = "Bob" }; FakeMembersRepository repositoryParam = new FakeMembersRepository(); repositoryParam.Members.Add(bob); AdminController target = new AdminController(repositoryParam); string oldLoginParam = bob.LoginName; string newLoginParam = "Anastasia"; // Act (attempt the operation) target.ChangeLoginName(oldLoginParam, newLoginParam); // Assert (verify the result) Assert.AreEqual(newLoginParam, bob.LoginName); Assert.IsTrue(repositoryParam.DidSubmitChanges); }
public void CannotAddLowerBid() { // Arrange Item target = new Item(); Member memberParam = new Member(); Decimal amountParam = 150M; // Act target.AddBid(memberParam, amountParam); target.AddBid(memberParam, amountParam - 10); }
public void AddMember(Member member) { throw new NotImplementedException(); }
public void AddMember(Member member) { /* Implement me */ }