public void Details_WhenValidParametersArePased_ShouldReturnCorerectViewResultName() { // Arrange var autoMapperConfig = new AutoMapperConfig(); autoMapperConfig.Execute(typeof(OffersController).Assembly); var carOffer = new CarOffer(); var guid = Guid.NewGuid(); var carOffersServiceMock = new Mock <ICarOffersService>(); carOffersServiceMock.Setup(x => x.GetAll()) .Returns(() => new List <CarOffer> { carOffer }.AsQueryable()); var userServiceMock = new Mock <IUserService>(); OffersController offersController = new OffersController(carOffersServiceMock.Object, userServiceMock.Object); // Act ViewResult result = offersController.Details(guid) as ViewResult; // Assert Assert.AreEqual(string.Empty, result.ViewName); }
public void TestDB_OfferEdit_Updates() { //Arrange OffersController controller = new OffersController(db); Offer newOffer = new Offer { OfferId = 1, Name = "HFBW" }; //Act controller.Create(newOffer); newOffer.Name = "Human Flesh Body World"; controller.Edit(newOffer); var offerOutput = (controller.Details(1) as ViewResult).ViewData.Model as Offer; Assert.AreEqual(offerOutput.Name, "Human Flesh Body World"); db.DeleteAll(); }
public void Mock_GetDetails_ReturnsView() { // Arrange Offer testOffer = new Offer(); { }; DbSetup(); OffersController controller = new OffersController(mock.Object); // Act var resultView = controller.Details(testOffer.OfferId) as ViewResult; var model = resultView.ViewData.Model as Offer; // Assert Assert.IsInstanceOfType(resultView, typeof(ViewResult)); Assert.IsInstanceOfType(model, typeof(Offer)); }