public ActionResult MyViewings()
        {
            var builder   = new MyViewingsViewModelBuilder(_context);
            var viewModel = builder.Build(User.Identity.GetUserId());

            return(View(viewModel));
        }
        public void BuildShouldReturnVIewingsForMatchingBuyerId()
        {
            // Arrange
            var builder = new MyViewingsViewModelBuilder(_context);

            var offers = new List <Models.Viewing> {
                new Models.Viewing {
                    BuyerId = "1", ViewingAt = DateTime.Now, Property = new Models.Property {
                        StreetName = "Smith Street", Description = "", IsListedForSale = true
                    }
                },
                new Models.Viewing {
                    BuyerId = "1", ViewingAt = DateTime.Now, Property = new Models.Property {
                        StreetName = "Jones Street", Description = "", IsListedForSale = true
                    }
                }
            };

            var mockSet = Substitute.For <IDbSet <Models.Viewing> >()
                          .Initialize(offers.AsQueryable());

            _context.Viewings.Returns(mockSet);

            var buyerId = "1";

            // Act
            var viewModel = builder.Build(buyerId);

            // Assert
            Assert.That(viewModel.Viewings.Count, Is.EqualTo(2));
        }
        public void BuildShouldReturnNoViewingsForABuyer()
        {
            // Arrange
            var builder = new MyViewingsViewModelBuilder(_context);

            // Act
            var viewModel = builder.Build("999");

            // Assert
            Assert.That(viewModel.Count, Is.EqualTo(0));
        }