public ActionResult Edit(EditProjectSourceModel model) { if (!ModelState.IsValid) { return(Redirect(Url.ProjectSource_Edit(model.Id))); } ProjectSourceObj obj; if (!model.Id.HasValue) { obj = ModelConverter.Convert(model); obj.Id = ProjectSourceLogic.Create(obj, CurrentUserName); if (obj.Id == -1) { this.AddError("CreatingProjectSource", "There was an error creating your ProjectSource. If this continues contact support."); return(Redirect(Url.ProjectSource_Create())); } } else { obj = ModelConverter.Convert(model); var success = ProjectSourceLogic.Update(obj, CurrentUserName); if (!success) { this.AddError("UpdatingProjectSource", "There was an error updating your ProjectSource. If this continues contact support."); return(Redirect(Url.ProjectSource_Edit(model.Id.Value))); } } return(Redirect(Url.ProjectSource_Show(obj.Id.Value))); }
public void Create_Successfully_Made() { //arrange int expected = 4; var mockRepository = new Mock <IInnerTrackRepository>(); var obj = new ProjectSourceObj(); var user = "******"; mockRepository.Setup(m => m.CreateProjectSource(obj, user)).Returns(expected); var logic = new ProjectSourceLogic(mockRepository.Object); //act var actual = logic.Create(obj, user); //assert Assert.AreEqual(expected, actual); }