当前位置: 首页>>代码示例>>C#>>正文


C# ItineraryController.AddTeamMember方法代码示例

本文整理汇总了C#中AllReady.Areas.Admin.Controllers.ItineraryController.AddTeamMember方法的典型用法代码示例。如果您正苦于以下问题:C# ItineraryController.AddTeamMember方法的具体用法?C# ItineraryController.AddTeamMember怎么用?C# ItineraryController.AddTeamMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AllReady.Areas.Admin.Controllers.ItineraryController的用法示例。


在下文中一共展示了ItineraryController.AddTeamMember方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ItineraryController

        public async Task AddTeamMemberRedirectsToCorrectActionWithCorrectRouteValuesWhenOrganizationIdIsNotZero_AndUserIsOrgAdmin_AndIdOrSelectedTeamMemberIsNotZero()
        {
            const int itineraryId = 1;
            const int orgId = 1;

            var mockMediator = new Mock<IMediator>();
            mockMediator.Setup(x => x.SendAsync(It.IsAny<AddTeamMemberCommand>())).ReturnsAsync(true);
            mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(orgId);

            var sut = new ItineraryController(mockMediator.Object, null);
            sut.MakeUserAnOrgAdmin(orgId.ToString());
            var result = await sut.AddTeamMember(itineraryId, 1) as RedirectToActionResult;

            Assert.Equal(result.ActionName, nameof(ItineraryController.Details));
            Assert.Equal(result.RouteValues, new Dictionary<string, object> { ["id"] = itineraryId });
        }
开发者ID:dpaquette,项目名称:allReady,代码行数:16,代码来源:ItineraryAdminControllerTests.cs

示例2: AddTeamMemberDoesNotCallAddTeamMemberCommand_WhenSelectedTeamMemberIsZero

        public async Task AddTeamMemberDoesNotCallAddTeamMemberCommand_WhenSelectedTeamMemberIsZero()
        {
            var mockMediator = new Mock<IMediator>();
            mockMediator.Setup(x => x.SendAsync(It.IsAny<AddTeamMemberCommand>())).ReturnsAsync(true);
            mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(1);

            var sut = new ItineraryController(mockMediator.Object, null);
            sut.SetClaims(new List<Claim>
            {
                new Claim(AllReady.Security.ClaimTypes.UserType, UserType.SiteAdmin.ToString())
            });

            await sut.AddTeamMember(1, 0);

            mockMediator.Verify(x => x.SendAsync(It.IsAny<AddTeamMemberCommand>()), Times.Never);
        }
开发者ID:dpaquette,项目名称:allReady,代码行数:16,代码来源:ItineraryAdminControllerTests.cs

示例3: AddTeamMemberSendsOrganizationIdQueryWithCorrectItineraryId

        public async Task AddTeamMemberSendsOrganizationIdQueryWithCorrectItineraryId()
        {
            const int itineraryId = 1;

            var mockMediator = new Mock<IMediator>();
            mockMediator.Setup(x => x.SendAsync(It.IsAny<AddTeamMemberCommand>())).ReturnsAsync(true);
            mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(1);

            var sut = new ItineraryController(mockMediator.Object, null);
            sut.SetClaims(new List<Claim>
            {
                new Claim(AllReady.Security.ClaimTypes.UserType, UserType.SiteAdmin.ToString())
            });

            await sut.AddTeamMember(itineraryId, 0);

            mockMediator.Verify(x => x.SendAsync(It.Is<OrganizationIdQuery>(y => y.ItineraryId == itineraryId)), Times.Once);
        }
开发者ID:dpaquette,项目名称:allReady,代码行数:18,代码来源:ItineraryAdminControllerTests.cs

示例4: AddTeamMemberSendsAddTeamMemberCommandWithCorrectParameters

        public async Task AddTeamMemberSendsAddTeamMemberCommandWithCorrectParameters()
        {
            const int itineraryId = 1;
            const int selectedTeamMember = 1;

            var mockMediator = new Mock<IMediator>();
            mockMediator.Setup(x => x.SendAsync(It.IsAny<AddTeamMemberCommand>())).ReturnsAsync(true);
            mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(1);

            var sut = new ItineraryController(mockMediator.Object, MockSuccessValidation().Object);
            sut.SetClaims(new List<Claim>
            {
                new Claim(AllReady.Security.ClaimTypes.UserType, UserType.SiteAdmin.ToString())
            });

            await sut.AddTeamMember(1, 1);

            mockMediator.Verify(x => x.SendAsync(It.Is<AddTeamMemberCommand>(y => y.ItineraryId == itineraryId && y.TaskSignupId == selectedTeamMember)), Times.Once);
        }
开发者ID:yobenzima,项目名称:allReady,代码行数:19,代码来源:ItineraryAdminControllerTests.cs

示例5: ItineraryController

        public async Task AddTeamMemberRedirectsToCorrectActionWithCorrectRouteValuesWhenOrganizationIdIsNotZero_AndUserIsOrgAdmin_AndIdOrSelectedTeamMemberIsNotZero()
        {
            const int id = 1;

            var mockMediator = new Mock<IMediator>();
            mockMediator.Setup(x => x.SendAsync(It.IsAny<AddTeamMemberCommand>())).ReturnsAsync(true);
            mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(1);

            var sut = new ItineraryController(mockMediator.Object, MockSuccessValidation().Object);
            sut.SetClaims(new List<Claim>
            {
                new Claim(AllReady.Security.ClaimTypes.UserType, UserType.OrgAdmin.ToString()),
                new Claim(AllReady.Security.ClaimTypes.Organization, "1")
            });
            var result = await sut.AddTeamMember(id, 1) as RedirectToActionResult;

            Assert.Equal(result.ActionName, nameof(ItineraryController.Details));
            Assert.Equal(result.RouteValues, new Dictionary<string, object> { ["id"] = id });
        }
开发者ID:yobenzima,项目名称:allReady,代码行数:19,代码来源:ItineraryAdminControllerTests.cs

示例6: AddTeamMemberDoesNotCallAddTeamMemberCommand_WhenSelectedTeamMemberIsZero

        public async Task AddTeamMemberDoesNotCallAddTeamMemberCommand_WhenSelectedTeamMemberIsZero()
        {
            var mockMediator = new Mock<IMediator>();
            mockMediator.Setup(x => x.SendAsync(It.IsAny<AddTeamMemberCommand>())).ReturnsAsync(true);

            var sut = new ItineraryController(mockMediator.Object, MockSuccessValidation().Object);
            await sut.AddTeamMember(1, 0);

            mockMediator.Verify(x => x.SendAsync(It.IsAny<AddTeamMemberCommand>()), Times.Never);
        }
开发者ID:joelhulen,项目名称:allReady,代码行数:10,代码来源:ItineraryAdminControllerTests.cs

示例7: AddTeamMemberCallsAddTeamMemberCommand

        public async Task AddTeamMemberCallsAddTeamMemberCommand()
        {
            var mockMediator = new Mock<IMediator>();
            mockMediator.Setup(x => x.SendAsync(It.IsAny<AddTeamMemberCommand>())).ReturnsAsync(true);

            var sut = new ItineraryController(mockMediator.Object, MockSuccessValidation().Object);
            await sut.AddTeamMember(1, 1);

            mockMediator.Verify(x => x.SendAsync(It.IsAny<AddTeamMemberCommand>()), Times.Once);
        }
开发者ID:joelhulen,项目名称:allReady,代码行数:10,代码来源:ItineraryAdminControllerTests.cs

示例8: ItineraryController

        public async Task AddTeamMemberReturnsCorrectJsonWhenOrganizationIdIsNotZero_AndUserIsOrgAdmin_AndIdOrSelectedTeamMemberIsNotZero()
        {
            const int itineraryId = 1;
            const int orgId = 1;
            const int teamMemberId = 1;
            string volunteerEmail = "[email protected]";

            var mockMediator = new Mock<IMediator>();
            var itineraryDetailsViewModel = new ItineraryDetailsViewModel
            {
                PotentialTeamMembers = new List<SelectListItem>(),
                TeamMembers = new List<TeamListViewModel>
                {
                    new TeamListViewModel {VolunteerEmail = volunteerEmail}
                }
            };
            mockMediator.Setup(x => x.SendAsync(It.IsAny<AddTeamMemberCommand>())).ReturnsAsync(true);
            mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(orgId);
            mockMediator.Setup(x => x.SendAsync(It.IsAny<ItineraryDetailQuery>())).ReturnsAsync(itineraryDetailsViewModel);

            var sut = new ItineraryController(mockMediator.Object, null);
            sut.MakeUserAnOrgAdmin(orgId.ToString());
            var jsonResult = await sut.AddTeamMember(itineraryId, teamMemberId) as JsonResult;

            var successStatus = jsonResult.GetValueForProperty<bool>("isSuccess");
            var teamMembers = jsonResult.GetValueForProperty<IEnumerable<TeamListViewModel>>("teamMembers").ToList();
            var potentialMembers = jsonResult.GetValueForProperty<IEnumerable<SelectListItem>>("potentialTeamMembers").ToList();

            Assert.True(successStatus);
            Assert.NotNull(teamMembers);
            Assert.NotNull(potentialMembers);
            Assert.Equal(1, teamMembers.Count);
            Assert.Equal(volunteerEmail, teamMembers[0].VolunteerEmail);
        }
开发者ID:stevejgordon,项目名称:allReady,代码行数:34,代码来源:ItineraryAdminControllerTests.cs

示例9: AddTeamMemberReturnsCorrectJsonWhenIdIsZeroOrSelectedTeamMemberIsZero

        public async Task AddTeamMemberReturnsCorrectJsonWhenIdIsZeroOrSelectedTeamMemberIsZero()
        {
            const int itineraryId = 0;
            const int orgId = 1;

            var mockMediator = new Mock<IMediator>();
            mockMediator.Setup(x => x.SendAsync(It.IsAny<AddTeamMemberCommand>())).ReturnsAsync(true);
            mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(orgId);

            var sut = new ItineraryController(mockMediator.Object, null);
            sut.MakeUserAnOrgAdmin(orgId.ToString());
            var jsonResult = await sut.AddTeamMember(itineraryId, 0) as JsonResult;

            var successStatus = jsonResult.GetValueForProperty<bool>("isSuccess");
            var errors = jsonResult.GetValueForProperty<string[]>("errors");

            Assert.False(successStatus);
            Assert.NotNull(errors);
            Assert.Equal(1, errors.Length);
            Assert.Equal("Invalid selection.", errors[0]);
        }
开发者ID:stevejgordon,项目名称:allReady,代码行数:21,代码来源:ItineraryAdminControllerTests.cs

示例10: AddTeamMemberSendsAddTeamMemberCommandWithCorrectParameters

        public async Task AddTeamMemberSendsAddTeamMemberCommandWithCorrectParameters()
        {
            const int itineraryId = 1;
            const int selectedTeamMember = 1;
            string volunteerEmail = "[email protected]";

            var mockMediator = new Mock<IMediator>();
            var itineraryDetailsViewModel = new ItineraryDetailsViewModel
            {
                PotentialTeamMembers = new List<SelectListItem>(),
                TeamMembers = new List<TeamListViewModel>
                {
                    new TeamListViewModel {VolunteerEmail = volunteerEmail}
                }
            };
            mockMediator.Setup(x => x.SendAsync(It.IsAny<AddTeamMemberCommand>())).ReturnsAsync(true);
            mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(1);
            mockMediator.Setup(x => x.SendAsync(It.IsAny<ItineraryDetailQuery>())).ReturnsAsync(itineraryDetailsViewModel);

            var sut = new ItineraryController(mockMediator.Object, null);
            sut.SetClaims(new List<Claim>
            {
                new Claim(AllReady.Security.ClaimTypes.UserType, UserType.SiteAdmin.ToString())
            });

            await sut.AddTeamMember(1, 1);

            mockMediator.Verify(x => x.SendAsync(It.Is<AddTeamMemberCommand>(y => y.ItineraryId == itineraryId && y.TaskSignupId == selectedTeamMember)), Times.Once);
            mockMediator.Verify(x => x.SendAsync(It.Is<ItineraryDetailQuery>(y => y.ItineraryId == itineraryId)), Times.Once);
        }
开发者ID:stevejgordon,项目名称:allReady,代码行数:30,代码来源:ItineraryAdminControllerTests.cs


注:本文中的AllReady.Areas.Admin.Controllers.ItineraryController.AddTeamMember方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。