public async Task EditGetReturnsTheCorrectViewModel() { var campaignSummaryViewModel = new CampaignSummaryViewModel { Id = 4, OrganizationId = 1, Name = "TestCampaign" }; var resourceDetailViewModel = new ResourceDetailViewModel { Id = 5 }; var mockMediator = new Mock <IMediator>(); mockMediator.Setup(m => m.SendAsync(It.IsAny <ResourceDetailQuery>())).ReturnsAsync(resourceDetailViewModel); mockMediator.Setup(m => m.SendAsync(It.IsAny <CampaignSummaryQuery>())).ReturnsAsync(campaignSummaryViewModel); var sut = new ResourceController(mockMediator.Object); sut.MakeUserAnOrgAdmin(campaignSummaryViewModel.OrganizationId.ToString()); var result = await sut.Edit(It.IsAny <int>()) as ViewResult; result.ShouldNotBeNull(); result.Model.ShouldBeOfType <ResourceEditViewModel>(); result.Model.ShouldBeOfType <ResourceEditViewModel>().CampaignId.ShouldBe(campaignSummaryViewModel.Id); result.Model.ShouldBeOfType <ResourceEditViewModel>().Id.ShouldBe(resourceDetailViewModel.Id); }
public void GivenNewResourceWithTitleAndContentAndAuthorAndTagsAndReferenceUrl(string title, string content, string author, string tags, string referenceurl) { var resourceModel = new ResourceDetailViewModel { Tags = tags, Title = title, Author = author, Content = content, ReferenceUrl = referenceurl, }; PendingSubmittedResourceDetailViewModel = resourceModel; }
public async Task DetailsReturnsTheCorrectView() { var mockMediator = new Mock <IMediator>(); var resourceDetailViewModel = new ResourceDetailViewModel { Id = 2 }; mockMediator.Setup(m => m.SendAsync(It.IsAny <ResourceDetailQuery>())).ReturnsAsync(It.IsAny <ResourceDetailViewModel>()); var sut = new ResourceController(mockMediator.Object); var result = await sut.Details(resourceDetailViewModel.Id) as ViewResult; result.ShouldNotBeNull(); result.ViewName.ShouldBeNull(); }
public async Task DetailsSendsResourceDetailQuery_WithCorrectResourceId() { var mockMediator = new Mock <IMediator>(); var resourceDetailViewModel = new ResourceDetailViewModel { Id = 2 }; mockMediator.Setup(m => m.SendAsync(It.IsAny <ResourceDetailQuery>())).ReturnsAsync(It.IsAny <ResourceDetailViewModel>()); var sut = new ResourceController(mockMediator.Object); var result = await sut.Details(resourceDetailViewModel.Id); result.ShouldNotBeNull(); mockMediator.Verify(m => m.SendAsync(It.Is <ResourceDetailQuery>(r => r.ResourceId == resourceDetailViewModel.Id))); }
private void AssertResource(Resource resource, ResourceDetailViewModel resourceDetailViewModel) { Assert.Equal(resource.Title, resourceDetailViewModel.Title); Assert.Equal(resource.Content, resourceDetailViewModel.Content); Assert.Equal(resource.Author, resourceDetailViewModel.Author); Assert.Equal(resource.ReferenceUrl, resourceDetailViewModel.ReferenceUrl); Assert.Equal(resource.Tags.Count, resourceDetailViewModel.Tags.ToTagList().Count); }
public ResourceDetailPage(ResourceDetailViewModel _viewModel) { InitializeComponent(); BindingContext = this.viewModel = _viewModel; }
public ActionResult Edit(string id, ResourceDetailViewModel detailViewModel) { Resource resource = ResourceMapper.MapFromDetailViewModelToDomain(detailViewModel); ResourceService.UpdateResource(id, resource); return RedirectToAction("Details", new { id }); }
public ActionResult Create() { var viewModel = new ResourceDetailViewModel(); return View(viewModel); }
public ActionResult Create(ResourceDetailViewModel detailViewModel) { var resource = ResourceMapper.MapFromDetailViewModelToDomain(detailViewModel); resource = ResourceService.AddResource(resource); return RedirectToAction("Details", new { id = resource.Id.Substring(10) }); }