public void EmployerController_edit_post_valid_updates_model_returns_json() { //Arrange const int testid = 4242; var fakeemployer = new Domain.Employer(); var savedemployer = new Domain.Employer(); serv.Setup(p => p.Get(testid)).Returns(fakeemployer); serv.Setup(x => x.Save(It.IsAny <Domain.Employer>(), It.IsAny <string>()) ).Callback((Domain.Employer p, string str) => { savedemployer = p; }); ctrlr.ValueProvider = form.ToValueProvider(); //Act var result = ctrlr.Edit(testid, form, "UnitTest"); //Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(JsonResult)); Assert.AreEqual("{ jobSuccess = True }", result.Data.ToString()); Assert.AreEqual(fakeemployer, savedemployer); Assert.AreEqual(savedemployer.name, "blah"); Assert.AreEqual(savedemployer.address1, "UnitTest"); Assert.AreEqual(savedemployer.city, "footown"); }
public async Task EmployerController_edit_post_valid_updates_model_returns_json() { //Arrange //Act var result = await _controller.Edit(testId, "UnitTest"); //Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(JsonResult)); Assert.AreEqual("{ jobSuccess = True }", result.Value.ToString()); Assert.AreEqual(_fakeemployer, _savedemployer); Assert.AreEqual("blah", _savedemployer.name); Assert.AreEqual("UnitTest", _savedemployer.address1); Assert.AreEqual("footown", _savedemployer.city); }
public void EmployerController_edit_get_returns_employer() { //Arrange serv = new Mock <IEmployerService>(); var fakeemployer = new Domain.Employer(); serv.Setup(p => p.Get(Testid)).Returns(fakeemployer); woServ = new Mock <IWorkOrderService>(); ctrlr = new EmployerController(serv.Object, def.Object, map); //Act var result = ctrlr.Edit(Testid) as PartialViewResult; //Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result.ViewData.Model, typeof(Web.ViewModel.Employer)); }
public async Task EmployerController_edit_get_returns_employer() { //Arrange _serv = new Mock <IEmployerService>(); _serv.Setup(p => p.Get(testId)).Returns(new Employer()); var mapperConfig = new MapperConfiguration(config => { config.ConfigureMvc(); }); var mapper = mapperConfig.CreateMapper(); _controller = new EmployerController(_serv.Object, _defaults.Object, mapper, _adaptor.Object); //Act var result = await _controller.Edit(testId) as PartialViewResult; //Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result.ViewData.Model, typeof(Machete.Web.ViewModel.Employer)); }