public void HandleShouldAddOfferToProperty() { // Arrange var offerCommand = new MakeOfferCommand() { PropertyId = 1, UserId = Guid.NewGuid().ToString(), Offer = 1 }; var command = new ListPropertyCommand { PropertyId = 1 }; var property = new Domain.Models.Property { Id = 1, Description = "Test Property" }; _context.Properties.Find(1).Returns(property); // Act _offerHandler.Handle(offerCommand); // Assert var testProperty = _context.Properties.Find(1); Assert.That(testProperty.Offers.Count, Is.EqualTo(1)); Assert.That(testProperty.Offers.First().UserId, Is.EqualTo(offerCommand.UserId)); Assert.That(testProperty.Offers.First().Amount, Is.EqualTo(offerCommand.Offer)); }
public void HandleShouldUpdatePropertyToBeListedForSale() { // Arrange var command = new ListPropertyCommand { PropertyId = 1 }; var property = new Models.Property { Description = "Test Property", IsListedForSale = false }; _properties.Find(1).Returns(property); // Act // WHEN the property is listed for sale _handler.Handle(command); // Assert _context.Properties.Received(1).Find(1); // AND the changes are saved _context.Received(1).SaveChanges(); // THEN the property is listed for sale Assert.True(property.IsListedForSale); }
public ActionResult ListForSale(ListPropertyCommand command) { var handler = new ListPropertyCommandHandler(_context); handler.Handle(command); return(RedirectToAction("MyProperties")); }
public void HandleShouldUpdatePropertyToBeListedForSale() { // Arrange var command = new ListPropertyCommand { PropertyId = 1 }; var property = GetMockProperty(description: "Test Property"); _properties.Find(1).Returns(property); // Act _handler.Handle(command); // Assert _context.Properties.Received(1).Find(1); _context.Received(1).SaveChanges(); Assert.True(property.IsListedForSale); }
public void HandleShouldUpdatePropertyToBeListedForSaleInvalidProperty() { // Arrange var command = new ListPropertyCommand { PropertyId = 2 }; var property = new Models.Property { Description = "Test Property", IsListedForSale = false }; _properties.Find(1).Returns(property); _properties.Find(2).Returns(null as Models.Property); // Act _handler.Handle(command); // Assert Assert.True(property.IsListedForSale); }
public void HandleShouldUpdatePropertyToBeListedForSale() { // Arrange var command = new ListPropertyCommand { PropertyId = 1 }; var property = new Domain.Models.Property { Description = "Test Property", IsListedForSale = false, }; _properties.Find(1).Returns(property); // Act _handler.Handle(command); // Assert _context.Properties.Received(1).Find(1); _context.Received(1).SaveChanges(); Assert.True(property.IsListedForSale); }