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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }