public void IndexHasRouteAttributeWithCorrectRoute()
 {
     var sut = new OrganizationController(null);
     var routeAttribute = sut.GetAttributesOn(x => x.Index()).OfType<RouteAttribute>().SingleOrDefault();
     Assert.NotNull(routeAttribute);
     Assert.Equal(routeAttribute.Template, "Organizations/");
 }
 public void ShowOrganizationHasRouteAttributeWithCorrectRoute()
 {
     var sut = new OrganizationController(null);
     var routeAttribute = (RouteAttribute)sut.GetAttributesOn(x => x.ShowOrganization(It.IsAny<int>())).SingleOrDefault(x => x.GetType() == typeof(RouteAttribute));
     Assert.NotNull(routeAttribute);
     Assert.Equal(routeAttribute.Template, "Organization/{id}/");
 }
        public void IndexReturnsAView()
        {
            var controller = new OrganizationController(Mock.Of<IMediator>());
            var result = controller.Index();

            Assert.IsType<ViewResult>(result);
        }
        public void IndexSendsOrganizationsQuery()
        {
            var mockedMediator = new Mock<IMediator>();
            var controller = new OrganizationController(mockedMediator.Object);
            controller.Index();

            mockedMediator.Verify(x => x.Send(It.IsAny<OrganizationsQuery>()), Times.Once());
        }
 private static void MockMediatorOrganizationPrivacyPolicyQueryNullResult(out OrganizationController controller)
 {
     var mockMediator = new Mock<IMediator>();
     mockMediator.Setup(mock => mock.SendAsync(It.IsAny<OrganizationPrivacyPolicyQuery>())).Returns(() => Task.FromResult((OrganizationPrivacyPolicyViewModel)null)).Verifiable();
     controller = new OrganizationController(mockMediator.Object);
 }
        private static void MockMediatorOrganizationPrivacyPolicyQuery(out OrganizationController controller, OrganizationPrivacyPolicyViewModel model = null)
        {
            if (model == null) model = new OrganizationPrivacyPolicyViewModel { OrganizationName = "Org 1", Content = null };

            var mockMediator = new Mock<IMediator>();
            mockMediator.Setup(mock => mock.SendAsync(It.IsAny<OrganizationPrivacyPolicyQuery>())).Returns(() => Task.FromResult(model)).Verifiable();
            controller = new OrganizationController(mockMediator.Object);
        }
        private static void MockMediatorOrganizationDetailsQuery(out OrganizationController controller, OrganizationViewModel model = null)
        {
            if (model == null)
                model = new OrganizationViewModel { Id = 1, Name = "Org 1" };

            var mockMediator = new Mock<IMediator>();
            mockMediator.Setup(mock => mock.SendAsync(It.IsAny<OrganizationDetailsQueryAsync>())).Returns(() => Task.FromResult(model)).Verifiable();
            controller = new OrganizationController(mockMediator.Object);
        }