Beispiel #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);
        }
        public void GetHasHttpGetAttribute()
        {
            var sut       = new EventApiController(null);
            var attribute = sut.GetAttributesOn(x => x.Get()).OfType <HttpGetAttribute>().SingleOrDefault();

            Assert.NotNull(attribute);
        }
Beispiel #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);
        }
        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}");
        }
        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");
        }
        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");
        }
        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}");
        }
Beispiel #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");
        }
Beispiel #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");
        }
Beispiel #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");
        }
        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));
        }
        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");
        }