• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Controllers.EventApiController类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中AllReady.Controllers.EventApiController的典型用法代码示例。如果您正苦于以下问题:C# EventApiController类的具体用法?C# EventApiController怎么用?C# EventApiController使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EventApiController类属于AllReady.Controllers命名空间,在下文中一共展示了EventApiController类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetSendsEventsWithUnlockedCampaignsQuery

        public void GetSendsEventsWithUnlockedCampaignsQuery()
        {
            var mediator = new Mock<IMediator>();
            var sut = new EventApiController(mediator.Object, null);
            sut.Get();

            mediator.Verify(x => x.Send(It.IsAny<EventsWithUnlockedCampaignsQuery>()), Times.Once);
        }
开发者ID:gftrader,项目名称:allReady,代码行数:8,代码来源:EventApiControllerTests.cs


示例2: GetByIdReturnsCorrectViewModel

        public void GetByIdReturnsCorrectViewModel()
        {
            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.Send(It.IsAny<EventByIdQuery>())).Returns(new Event { Campaign = new Campaign { ManagingOrganization = new Organization() }});
            var sut = new EventApiController(mediator.Object, null);
            var result = sut.Get(It.IsAny<int>());

            Assert.IsType<EventViewModel>(result);
        }
开发者ID:gftrader,项目名称:allReady,代码行数:9,代码来源:EventApiControllerTests.cs


示例3: GetReturnsCorrectModel

        public void GetReturnsCorrectModel()
        {
            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.Send(It.IsAny<EventsWithUnlockedCampaignsQuery>())).Returns(new List<EventViewModel>());

            var sut = new EventApiController(mediator.Object, null);
            var results = sut.Get();

            Assert.IsType<List<EventViewModel>>(results);
        }
开发者ID:gftrader,项目名称:allReady,代码行数:10,代码来源:EventApiControllerTests.cs


示例4: GetByIdSendsEventByEventIdQueryWithCorrectData

        public void GetByIdSendsEventByEventIdQueryWithCorrectData()
        {
            const int eventId = 1;

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.Send(It.IsAny<EventByIdQuery>())).Returns(new Event { Campaign = new Campaign { ManagingOrganization = new Organization() }});
            var sut = new EventApiController(mediator.Object, null);

            sut.Get(eventId);

            mediator.Verify(x => x.Send(It.Is<EventByIdQuery>(y => y.EventId == eventId)), Times.Once);
        }
开发者ID:gftrader,项目名称:allReady,代码行数:12,代码来源:EventApiControllerTests.cs


示例5: RegisterEventHasHttpPostAttributeWithCorrectTemplate

 public void RegisterEventHasHttpPostAttributeWithCorrectTemplate()
 {
     var sut = new EventApiController(null, null);
     var attribute = (HttpPostAttribute)sut.GetAttributesOn(x => x.RegisterEvent(It.IsAny<EventSignupViewModel>())).SingleOrDefault(x => x.GetType() == typeof(HttpPostAttribute));
     Assert.NotNull(attribute);
     Assert.Equal(attribute.Template, "signup");
 }
开发者ID:gftrader,项目名称:allReady,代码行数:7,代码来源:EventApiControllerTests.cs


示例6: RegisterEventHasValidateAntiForgeryTokenAttribute

 public void RegisterEventHasValidateAntiForgeryTokenAttribute()
 {
     var sut = new EventApiController(null, null);
     var attribute = (ValidateAntiForgeryTokenAttribute)sut.GetAttributesOn(x => x.RegisterEvent(It.IsAny<EventSignupViewModel>())).SingleOrDefault(x => x.GetType() == typeof(ValidateAntiForgeryTokenAttribute));
     Assert.NotNull(attribute);
 }
开发者ID:gftrader,项目名称:allReady,代码行数:6,代码来源:EventApiControllerTests.cs


示例7: GetEventsByGeographySendsEventsByGeographyQueryWithCorrectLatitudeLongitudeAndMiles

        public void GetEventsByGeographySendsEventsByGeographyQueryWithCorrectLatitudeLongitudeAndMiles()
        {
            const double latitude = 1;
            const double longitude = 2;
            const int miles = 100;

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.Send(It.IsAny<EventsByGeographyQuery>())).Returns(new List<Event>());

            var sut = new EventApiController(mediator.Object, null);
            sut.GetEventsByGeography(latitude, longitude, miles);

            mediator.Verify(x => x.Send(It.Is<EventsByGeographyQuery>(y => y.Latitude == latitude && y.Longitude == longitude && y.Miles == miles)), Times.Once);
        }
开发者ID:gftrader,项目名称:allReady,代码行数:14,代码来源:EventApiControllerTests.cs


示例8: GetByIdHasHttpGetAttributeWithCorrectTemplate

 public void GetByIdHasHttpGetAttributeWithCorrectTemplate()
 {
     var sut = new EventApiController(null, null);
     var attribute = sut.GetAttributesOn(x => x.Get(It.IsAny<int>())).OfType<HttpGetAttribute>().SingleOrDefault();
     Assert.NotNull(attribute);
     Assert.Equal(attribute.Template, "{id}");
 }
开发者ID:gftrader,项目名称:allReady,代码行数:7,代码来源:EventApiControllerTests.cs


示例9: GetCheckinReturnsTheCorrectView

        public void GetCheckinReturnsTheCorrectView()
        {
            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.Send(It.IsAny<EventByIdQuery>())).Returns(new Event { Campaign = new Campaign { ManagingOrganization = new Organization() }});

            var sut = new EventApiController(mediator.Object, null);
            var result = (ViewResult)sut.GetCheckin(It.IsAny<int>());

            Assert.Equal("NoUserCheckin", result.ViewName);
        }
开发者ID:gftrader,项目名称:allReady,代码行数:10,代码来源:EventApiControllerTests.cs


示例10: PutCheckinHasHttpPutAttributeWithCorrectTemplate

 public void PutCheckinHasHttpPutAttributeWithCorrectTemplate()
 {
     var sut = new EventApiController(null, null);
     var attribute = (HttpPutAttribute)sut.GetAttributesOn(x => x.PutCheckin(It.IsAny<int>())).SingleOrDefault(x => x.GetType() == typeof(HttpPutAttribute));
     Assert.NotNull(attribute);
     Assert.Equal(attribute.Template, "{id}/checkin");
 }
开发者ID:gftrader,项目名称:allReady,代码行数:7,代码来源:EventApiControllerTests.cs


示例11: UnregisterEventSendsUnregisterEventWithCorrectEventSignupId

        public async Task UnregisterEventSendsUnregisterEventWithCorrectEventSignupId()
        {
            const int eventId = 1;
            const int eventSignupId = 1;

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.Send(It.IsAny<EventSignupByEventIdAndUserIdQuery>()))
                .Returns(new EventSignup { Id = eventSignupId, Event = new Event(), User = new ApplicationUser() });

            var controller = new EventApiController(mediator.Object, null);
            controller.SetDefaultHttpContext();

            await controller.UnregisterEvent(eventId);

            mediator.Verify(x => x.SendAsync(It.Is<UnregisterEvent>(y => y.EventSignupId == eventSignupId)));
        }
开发者ID:gftrader,项目名称:allReady,代码行数:16,代码来源:EventApiControllerTests.cs


示例12: Event

        public async Task PutCheckinSendsAddEventSignupCommandAsyncWithCorrectDataWhenUsersSignedUpIsNotNullAndCheckinDateTimeIsNull()
        {
            const string userId = "userId";
            var utcNow = DateTime.UtcNow;

            var campaignEvent = new Event();
            var eventSignup = new EventSignup { User = new ApplicationUser { Id = userId } };
            campaignEvent.UsersSignedUp.Add(eventSignup);

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.Send(It.IsAny<EventByIdQuery>())).Returns(campaignEvent);

            var sut = new EventApiController(mediator.Object, null) { DateTimeUtcNow = () => utcNow };
            sut.SetFakeUser(userId);
            await sut.PutCheckin(It.IsAny<int>());

            mediator.Verify(x => x.SendAsync(It.Is<AddEventSignupCommandAsync>(y => y.EventSignup == eventSignup)));
            mediator.Verify(x => x.SendAsync(It.Is<AddEventSignupCommandAsync>(y => y.EventSignup.CheckinDateTime == utcNow)));
        }
开发者ID:gftrader,项目名称:allReady,代码行数:19,代码来源:EventApiControllerTests.cs


示例13: PutCheckinReturnsCorrectJsonWhenUsersSignedUpIsNullAndCheckinDateTimeIsNotNull

        public async Task PutCheckinReturnsCorrectJsonWhenUsersSignedUpIsNullAndCheckinDateTimeIsNotNull()
        {
            const string userId = "userId";
            var campaignEvent = new Event { Name = "EventName", Description = "EventDescription" };

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.Send(It.IsAny<EventByIdQuery>())).Returns(campaignEvent);

            var sut = new EventApiController(mediator.Object, null);
            sut.SetFakeUser(userId);

            var expected = $"{{ NeedsSignup = True, Event = {{ Name = {campaignEvent.Name}, Description = {campaignEvent.Description} }} }}";

            var result = (JsonResult)await sut.PutCheckin(It.IsAny<int>());

            Assert.IsType<JsonResult>(result);
            Assert.Equal(expected, result.Value.ToString());
        }
开发者ID:gftrader,项目名称:allReady,代码行数:18,代码来源:EventApiControllerTests.cs


示例14: PutCheckinSendsEventByEventIdQueryWithCorrectEventId

        public async Task PutCheckinSendsEventByEventIdQueryWithCorrectEventId()
        {
            const int eventId = 1;

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.Send(It.IsAny<EventByIdQuery>())).Returns(new Event());

            var sut = new EventApiController(mediator.Object, null);
            await sut.PutCheckin(eventId);

            mediator.Verify(x => x.Send(It.Is<EventByIdQuery>(y => y.EventId == eventId)), Times.Once);
        }
开发者ID:gftrader,项目名称:allReady,代码行数:12,代码来源:EventApiControllerTests.cs


示例15: PutCheckinReturnsHttpNotFoundWhenUnableToFindEventByEventId

        public async Task PutCheckinReturnsHttpNotFoundWhenUnableToFindEventByEventId()
        {
            var sut = new EventApiController(Mock.Of<IMediator>(), null);
            var result = await sut.PutCheckin(It.IsAny<int>());

            Assert.IsType<NotFoundResult>(result);
        }
开发者ID:gftrader,项目名称:allReady,代码行数:7,代码来源:EventApiControllerTests.cs


示例16: GetEventsByGeographyReturnsCorrectViewModel

        public void GetEventsByGeographyReturnsCorrectViewModel()
        {
            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.Send(It.IsAny<EventsByGeographyQuery>())).Returns(new List<Event>());

            var sut = new EventApiController(mediator.Object, null);
            var result = sut.GetEventsByGeography(It.IsAny<double>(), It.IsAny<double>(), It.IsAny<int>());

            Assert.IsType<List<EventViewModel>>(result);
        }
开发者ID:gftrader,项目名称:allReady,代码行数:10,代码来源:EventApiControllerTests.cs


示例17: UnregisterEventReturnsHttpNotFoundWhenUnableToGetEventSignupByEventSignupIdAndUserId

        public async Task UnregisterEventReturnsHttpNotFoundWhenUnableToGetEventSignupByEventSignupIdAndUserId()
        {
            var controller = new EventApiController(Mock.Of<IMediator>(), null);
            controller.SetDefaultHttpContext();

            var result = await controller.UnregisterEvent(It.IsAny<int>());
            Assert.IsType<NotFoundResult>(result);
        }
开发者ID:gftrader,项目名称:allReady,代码行数:8,代码来源:EventApiControllerTests.cs


示例18: UnregisterEventHasHttpDeleteAttributeWithCorrectTemplate

 public void UnregisterEventHasHttpDeleteAttributeWithCorrectTemplate()
 {
     var sut = new EventApiController(null, null);
     var attribute = (HttpDeleteAttribute)sut.GetAttributesOn(x => x.UnregisterEvent(It.IsAny<int>())).SingleOrDefault(x => x.GetType() == typeof(HttpDeleteAttribute));
     Assert.NotNull(attribute);
     Assert.Equal(attribute.Template, "{id}/signup");
 }
开发者ID:gftrader,项目名称:allReady,代码行数:7,代码来源:EventApiControllerTests.cs


示例19: UnregisterEventSendsEventSignupByEventIdAndUserIdQueryWithCorrectEventIdAndUserId

        public async Task UnregisterEventSendsEventSignupByEventIdAndUserIdQueryWithCorrectEventIdAndUserId()
        {
            const int eventId = 1;
            const string userId = "1";

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.Send(It.IsAny<EventSignupByEventIdAndUserIdQuery>()))
                .Returns(new EventSignup { Event = new Event(), User = new ApplicationUser() });

            var controller = new EventApiController(mediator.Object, null);
            controller.SetFakeUser(userId);

            await controller.UnregisterEvent(eventId);

            mediator.Verify(x => x.Send(It.Is<EventSignupByEventIdAndUserIdQuery>(y => y.EventId == eventId && y.UserId == userId)));
        }
开发者ID:gftrader,项目名称:allReady,代码行数:16,代码来源:EventApiControllerTests.cs


示例20: ControllerHasRouteAtttributeWithTheCorrectRoute

 public void ControllerHasRouteAtttributeWithTheCorrectRoute()
 {
     var sut = new EventApiController(null, null);
     var attribute = sut.GetAttributes().OfType<RouteAttribute>().SingleOrDefault();
     Assert.NotNull(attribute);
     Assert.Equal(attribute.Template, "api/event");
 }
开发者ID:gftrader,项目名称:allReady,代码行数:7,代码来源:EventApiControllerTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Controllers.TaskApiController类代码示例发布时间:2022-05-24
下一篇:
C# Controllers.AdminController类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap