Example #1
0
        public void EditOffer_WhenValidParametersArePased_ShouldReturnCorerectViewResultName()
        {
            // Arrange
            var autoMapperConfig = new AutoMapperConfig();

            autoMapperConfig.Execute(typeof(OffersController).Assembly);

            var carOffer = new CarOffer();
            var guid     = Guid.NewGuid();

            var userServiceMock      = new Mock <IUserService>();
            var carOffersServiceMock = new Mock <ICarOffersService>();

            carOffersServiceMock.Setup(x => x.GetAll())
            .Returns(() => new List <CarOffer> {
                carOffer
            }.AsQueryable());

            OffersController offersController = new OffersController(carOffersServiceMock.Object, userServiceMock.Object);

            // Act
            ViewResult result = offersController.EditOffer(guid) as ViewResult;

            // Assert
            Assert.AreEqual(string.Empty, result.ViewName);
        }
Example #2
0
        public void EditOffer_WhenValidParametersArePased_ShouldCallUpdateMethod()
        {
            // Arrange
            var autoMapperConfig = new AutoMapperConfig();

            autoMapperConfig.Execute(typeof(OffersController).Assembly);

            var carOffer = new CarOffer();

            var carOffersServiceMock = new Mock <ICarOffersService>();

            carOffersServiceMock.Setup(x => x.Update(carOffer)).Verifiable();
            carOffersServiceMock.Object.Update(carOffer);

            var userServiceMock = new Mock <IUserService>();
            OffersController offersController = new OffersController(carOffersServiceMock.Object, userServiceMock.Object);
            var editableCarOfferViewModel     = new EditableCarOfferViewModel();
            // Act
            ViewResult result = offersController.EditOffer(editableCarOfferViewModel) as ViewResult;

            // Assert
            carOffersServiceMock.Verify(x => x.Update(carOffer), Times.Once);
        }