public void Bind() { var id = Request.Params["action"] == null?Guid.NewGuid() : Guid.Parse(Request.Params["action"]); var data = VideoSvc.GetVideoById(id); if (data == null) { ReturnMsg rm = new ReturnMsg() { Code = StatusCode.Error, Message = "数据丢失,请稍后再试", Data = null }; Session["msg"] = rm; Response.Redirect("Users_List.aspx"); } this.hfId.Value = data.Video_Id.ToString(); this.txtName.Text = data.Video_Title; this.txtIntro.Text = data.Video_Intro; this.textPath.Text = data.Video_Path; imgUrl = data.Video_Image; }
public void GetVideoById_ShouldGetById() { var videoRepositoryMock = new Mock <IRepository <Video> >(); var unitOfWorkMock = new Mock <IUnitOfWork>(); var commentRepositoryMock = new Mock <IRepository <Comment> >(); Video video = new Video(); Guid id = Guid.NewGuid(); videoRepositoryMock.Setup(x => x.GetById(id)) .Returns(video); VideoServices videoService = new VideoServices(videoRepositoryMock.Object, unitOfWorkMock.Object, commentRepositoryMock.Object); var newVideo = videoService.GetVideoById(id); videoRepositoryMock.Verify(x => x.GetById(id), Times.Once()); Assert.Same(video, newVideo); }