public void YourOffers_WhenInValidGetAllParamIsPased_ShouldReturnNull() { // Arrange var autoMapperConfig = new AutoMapperConfig(); autoMapperConfig.Execute(typeof(OffersController).Assembly); var userServiceMock = new Mock <IUserService>(); var carOffer = new CarOffer(); 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 Assert.Throws <NullReferenceException>(() => offersController.YourOffers()); }