コード例 #1
0
        public void UnregisterEventHasAuthorizeAttribute()
        {
            var sut       = new EventApiController(null);
            var attribute = (AuthorizeAttribute)sut.GetAttributesOn(x => x.UnregisterEvent(It.IsAny <int>())).SingleOrDefault(x => x.GetType() == typeof(AuthorizeAttribute));

            Assert.NotNull(attribute);
        }
コード例 #2
0
        public void GetHasHttpGetAttribute()
        {
            var sut       = new EventApiController(null);
            var attribute = sut.GetAttributesOn(x => x.Get()).OfType <HttpGetAttribute>().SingleOrDefault();

            Assert.NotNull(attribute);
        }
コード例 #3
0
        public void RegisterEventHasValidateAntiForgeryTokenAttribute()
        {
            var sut       = new EventApiController(null);
            var attribute = (ValidateAntiForgeryTokenAttribute)sut.GetAttributesOn(x => x.RegisterEvent(It.IsAny <EventSignupViewModel>())).SingleOrDefault(x => x.GetType() == typeof(ValidateAntiForgeryTokenAttribute));

            Assert.NotNull(attribute);
        }
コード例 #4
0
        public void GetByIdHasHttpGetAttributeWithCorrectTemplate()
        {
            var sut       = new EventApiController(null);
            var attribute = sut.GetAttributesOn(x => x.Get(It.IsAny <int>())).OfType <HttpGetAttribute>().SingleOrDefault();

            Assert.NotNull(attribute);
            Assert.Equal(attribute.Template, "{id}");
        }
コード例 #5
0
        public void GetEventsByLocationHasRouteAttributeWithCorrectRoute()
        {
            var sut       = new EventApiController(null);
            var attribute = sut.GetAttributesOn(x => x.GetEventsByGeography(It.IsAny <double>(), It.IsAny <double>(), It.IsAny <int>())).OfType <RouteAttribute>().SingleOrDefault();

            Assert.NotNull(attribute);
            Assert.Equal(attribute.Template, "searchbylocation");
        }
コード例 #6
0
        public void GetEventsByPostalCodeHasRouteAttributeWithRoute()
        {
            var sut       = new EventApiController(null);
            var attribute = sut.GetAttributesOn(x => x.GetEventsByPostalCode(It.IsAny <string>(), It.IsAny <int>())).OfType <RouteAttribute>().SingleOrDefault();

            Assert.NotNull(attribute);
            Assert.Equal(attribute.Template, "search");
        }
コード例 #7
0
        public void GetEventsByDateRangeHasHttpGetAttributeWithCorrectTemplate()
        {
            var sut       = new EventApiController(null);
            var attribute = sut.GetAttributesOn(x => x.GetEventsByDateRange(It.IsAny <DateTimeOffset>(), It.IsAny <DateTimeOffset>())).OfType <HttpGetAttribute>().SingleOrDefault();

            Assert.NotNull(attribute);
            Assert.Equal(attribute.Template, "{start}/{end}");
        }
コード例 #8
0
        public void UnregisterEventHasHttpDeleteAttributeWithCorrectTemplate()
        {
            var sut       = new EventApiController(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");
        }
コード例 #9
0
        public void RegisterEventHasHttpPostAttributeWithCorrectTemplate()
        {
            var sut       = new EventApiController(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");
        }
コード例 #10
0
        public void PutCheckinHasHttpPutAttributeWithCorrectTemplate()
        {
            var sut       = new EventApiController(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
0
        public void GetEventsByDateRangeHasProducesAttribute()
        {
            var sut       = new EventApiController(null);
            var attribute = sut.GetAttributesOn(x => x.GetEventsByDateRange(It.IsAny <DateTimeOffset>(), It.IsAny <DateTimeOffset>())).OfType <ProducesAttribute>().SingleOrDefault();

            Assert.NotNull(attribute);
            Assert.Equal(attribute.ContentTypes[0], "application/json");
            Assert.Equal(attribute.Type, typeof(EventViewModel));
        }
コード例 #12
0
        public void GetByIdHasProducesAttributeWithCorrectContentTypes()
        {
            var sut       = new EventApiController(null);
            var attribute = sut.GetAttributesOn(x => x.Get(It.IsAny <int>())).OfType <ProducesAttribute>().SingleOrDefault();

            Assert.NotNull(attribute);
            Assert.Equal(attribute.Type, typeof(EventViewModel));
            Assert.Equal(attribute.ContentTypes.Select(x => x).First(), "application/json");
        }