コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: ResourceSteps.cs プロジェクト: JohnCai/agilewizard
        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;
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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)));
        }
コード例 #5
0
ファイル: ResourceSteps.cs プロジェクト: JohnCai/agilewizard
 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);
 }
コード例 #6
0
 public ResourceDetailPage(ResourceDetailViewModel _viewModel)
 {
     InitializeComponent();
     BindingContext = this.viewModel = _viewModel;
 }
コード例 #7
0
        public ActionResult Edit(string id, ResourceDetailViewModel detailViewModel)
        {
            Resource resource = ResourceMapper.MapFromDetailViewModelToDomain(detailViewModel);
            ResourceService.UpdateResource(id, resource);

            return RedirectToAction("Details", new { id });
        }
コード例 #8
0
 public ActionResult Create()
 {
     var viewModel = new ResourceDetailViewModel();
     return View(viewModel);
 }
コード例 #9
0
 public ActionResult Create(ResourceDetailViewModel detailViewModel)
 {
     var resource = ResourceMapper.MapFromDetailViewModelToDomain(detailViewModel);
     resource = ResourceService.AddResource(resource);
     return RedirectToAction("Details", new { id = resource.Id.Substring(10) });
 }