本文整理汇总了C#中AllReady.Controllers.EventApiController类的典型用法代码示例。如果您正苦于以下问题:C# EventApiController类的具体用法?C# EventApiController怎么用?C# EventApiController使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EventApiController类属于AllReady.Controllers命名空间,在下文中一共展示了EventApiController类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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);
}
示例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);
}
示例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");
}
示例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);
}
示例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);
}
示例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}");
}
示例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);
}
示例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");
}
示例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)));
}
示例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)));
}
示例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());
}
示例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);
}
示例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);
}