public void ControllerHasProducesAtttributeWithTheCorrectContentType() { var sut = new OrganizationApiController(null); var attribute = sut.GetAttributes().OfType<ProducesAttribute>().SingleOrDefault(); Assert.NotNull(attribute); Assert.Equal(attribute.ContentTypes.Select(x => x).First(), "application/json"); }
public void ControllerHasAreaAtttributeWithTheCorrectAreaName() { var sut = new OrganizationApiController(null); var attribute = sut.GetAttributes().OfType<AreaAttribute>().SingleOrDefault(); Assert.NotNull(attribute); Assert.Equal(attribute.RouteValue, "Admin"); }
public void ControllerHasRouteAtttributeWithTheCorrectRoute() { var sut = new OrganizationApiController(null); var attribute = sut.GetAttributes().OfType<RouteAttribute>().SingleOrDefault(); Assert.NotNull(attribute); Assert.Equal(attribute.Template, "admin/api/organization"); }
public void RegisterTaskHasProducesAttributeWithCorrectContentType() { var sut = new OrganizationApiController(null); var attribute = sut.GetAttributesOn(x => x.GetContact(It.IsAny<int>())).OfType<ProducesAttribute>().SingleOrDefault(); Assert.NotNull(attribute); Assert.Equal(attribute.Type, typeof (ContactInformationModel)); Assert.Equal(attribute.ContentTypes.Select(x => x).First(), "application/json"); }
public async Task GetContactReturnsCorrectModel() { var mediator = new Mock<IMediator>(); mediator.Setup(x => x.SendAsync(It.IsAny<OrganizationContactQueryAsync>())).ReturnsAsync(new ContactInformationModel()); var sut = new OrganizationApiController(mediator.Object); var result = await sut.GetContact(It.IsAny<int>()); Assert.IsType<ContactInformationModel>(result); }
public async Task GetContactSendsOrganizationContactQueryWithCorrectData() { const int organizationId = 1; var mediator = new Mock<IMediator>(); var sut = new OrganizationApiController(mediator.Object); await sut.GetContact(organizationId); mediator.Verify(x => x.SendAsync(It.Is<OrganizationContactQueryAsync>(y => y.OrganizationId == organizationId && y.ContactType == ContactTypes.Primary))); }
public void ControllerHasAuthorizeAtttributeWithCorrectPolicy() { var sut = new OrganizationApiController(null); var attribute = sut.GetAttributes().OfType<AuthorizeAttribute>().SingleOrDefault(); Assert.NotNull(attribute); Assert.Equal(attribute.Policy, "OrgAdmin"); }
public void RegisterTaskHasHttpGetAttribute() { var sut = new OrganizationApiController(null); var attribute = sut.GetAttributesOn(x => x.GetContact(It.IsAny<int>())).OfType<HttpGetAttribute>().SingleOrDefault(); Assert.NotNull(attribute); }