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

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

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

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

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

            // Act & Assert
            offersController.WithCallTo(x => x.EditOffer(editableCarOfferViewModel)).ShouldRedirectToRoute(string.Empty);
        }
Example #2
0
        public void GetAllCars_WhenValidParametersArePased_ShouldReturnCorerectPartialViewResult()
        {
            // Arrange
            var autoMapperConfig = new AutoMapperConfig();

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

            var carOffer        = new CarOffer();
            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 & Assert
            offersController.WithCallTo(x => x.GetAllCars()).ShouldRenderPartialView("_GetAllCarsPartial");
        }
Example #3
0
        public void Details_WhenInValidIdIsPased_ShouldRedirectToHomeControllerRoute()
        {
            // Arrange
            var autoMapperConfig = new AutoMapperConfig();

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

            var carOffer = new CarOffer();

            var carOffersServiceMock = new Mock <ICarOffersService>();

            carOffersServiceMock.Setup(x => x.GetAll())
            .Returns(() => new List <CarOffer> {
                carOffer
            }.AsQueryable());
            var guid            = Guid.NewGuid();
            var userServiceMock = new Mock <IUserService>();
            OffersController offersController = new OffersController(carOffersServiceMock.Object, userServiceMock.Object);

            // Act & Assert
            offersController.WithCallTo(x => x.Details(null)).ShouldRedirectToRoute(string.Empty);
        }