public void ShouldWorkWithCorrectId() { var autoMapperConfig = new AutoMapperConfig(); autoMapperConfig.Execute(typeof(DetailsController).Assembly); var hotelServiceMock = new Mock<IHotelsService>(); hotelServiceMock.Setup(x => x.GetById(It.IsAny<int>())) .Returns(HotelForTest); var hotelRoomsServiceMock = new Mock<IHotelRoomsService>(); var controller = new DetailsController(hotelServiceMock.Object, hotelRoomsServiceMock.Object); controller.WithCallTo(x => x.HotelDetails(1)) .ShouldRenderView("HotelDetails") .WithModel<DetailsViewModel>( viewModel => { Assert.AreEqual(HotelForTest, viewModel.Hotel); }).AndModelError(""); }
public void ShouldWorkWithCorrectId() { var autoMapperConfig = new AutoMapperConfig(); autoMapperConfig.Execute(typeof(DetailsController).Assembly); var hotelServiceMock = new Mock <IHotelsService>(); Hotel hotelForTest = new Hotel() { Id = 1, Name = "Some name", Description = "Some description", Location = new Location() { Country = "Bulgaria", City = "Sofia", Address = "5th Street" }, Email = "*****@*****.**", Stars = 4 }; hotelServiceMock.Setup(x => x.GetById(It.IsAny <int>())) .Returns(hotelForTest); var hotelRoomsServiceMock = new Mock <IHotelRoomsService>(); hotelRoomsServiceMock.Setup(x => x.GetUniqueRoomTypesInHotel(It.IsAny <int>())) .Returns(new List <HotelRoom>().AsQueryable()); var controller = new DetailsController(hotelServiceMock.Object, hotelRoomsServiceMock.Object); var id = 1; controller.WithCallTo(x => x.HotelDetails(id)) .ShouldRenderView("HotelDetails") .WithModel <DetailsViewModel>( viewModel => { Assert.AreEqual(hotelForTest, viewModel.Hotel); }).AndModelError(""); }
public void ShouldWorkWithCorrectId() { var autoMapperConfig = new AutoMapperConfig(); autoMapperConfig.Execute(typeof(DetailsController).Assembly); var hotelServiceMock = new Mock <IHotelsService>(); hotelServiceMock.Setup(x => x.GetById(It.IsAny <int>())) .Returns(HotelForTest); var hotelRoomsServiceMock = new Mock <IHotelRoomsService>(); var controller = new DetailsController(hotelServiceMock.Object, hotelRoomsServiceMock.Object); controller.WithCallTo(x => x.HotelDetails(1)) .ShouldRenderView("HotelDetails") .WithModel <DetailsViewModel>( viewModel => { Assert.AreEqual(HotelForTest, viewModel.Hotel); }).AndModelError(""); }