public void EmptyResourceShouldCreateValidationErrors()
        {
            IServiceBehavior behavior = new ValidationBehavior();

            var resource = new Model();

            behavior.OnMethodExecuting(m_context, new MethodExecutingContext(m_service, m_method, resource));

            Assert.That(m_context.Request.ResourceState.IsValid, Is.False);
            Assert.That(m_context.Request.ResourceState.Count, Is.GreaterThan(0));
        }
        public void ValidResourceShouldNotCreateValidationErrors()
        {
            IServiceBehavior behavior = new ValidationBehavior();

            var resource = new Model
            {
                Id = 1,
                Name = "Joe Bloe"
            };

            behavior.OnMethodExecuting(m_context, new MethodExecutingContext(m_service, m_method, resource));

            Assert.That(m_context.Request.ResourceState.IsValid, Is.True);
            Assert.That(m_context.Request.ResourceState.Count, Is.EqualTo(0));
        }
        public void ResourceWithNameOver25CharactersShouldCreateValidationErrors()
        {
            IServiceBehavior behavior = new ValidationBehavior();

            var resource = new Model
            {
                Id = 1,
                Name = "Abcdefghijklmnopqrstuvwxyz"
            };

            behavior.OnMethodExecuting(m_context, new MethodExecutingContext(m_service, m_method, resource));

            Assert.That(m_context.Request.ResourceState.IsValid, Is.False);
            Assert.That(m_context.Request.ResourceState.Count, Is.GreaterThan(0));
        }