public void GivenValidType_WhenIValidate_ThenTrueIsReturned()
        {
            var file = MockRepository.GenerateStub<HttpPostedFileBase>();
            file.Expect(f => f.FileName).Return("myfile.test");

            var target = new FileTypesAttribute("test,testing");

            Assert.IsTrue(target.IsValid(file));
        }
        public void WhenICallFormateErrorMessage_ThenAFriendlyErrorMessageIsReturned()
        {
            var file = MockRepository.GenerateStub<HttpPostedFileBase>();
            file.Expect(f => f.FileName).Return("myfile.test");

            var target = new FileTypesAttribute("test,testing");

            Assert.AreEqual("The file uploaded is of an invalid format. Please use the recommended (test, testing) format.",
                target.FormatErrorMessage(null));
        }
Example #3
0
        public void GivenInvalidType_WhenIValidate_ThenFalseIsReturned()
        {
            var file = MockRepository.GenerateStub <HttpPostedFileBase>();

            file.Expect(f => f.FileName).Return("myfile.blah");

            var target = new FileTypesAttribute("test,testing");

            Assert.IsFalse(target.IsValid(file));
        }
Example #4
0
        public void WhenICallFormateErrorMessage_ThenAFriendlyErrorMessageIsReturned()
        {
            var file = MockRepository.GenerateStub <HttpPostedFileBase>();

            file.Expect(f => f.FileName).Return("myfile.test");

            var target = new FileTypesAttribute("test,testing");

            Assert.AreEqual("The file uploaded is of an invalid format. Please use the recommended (test, testing) format.",
                            target.FormatErrorMessage(null));
        }
        public void GivenNull_WhenIValidate_ThenTrueIsReturned()
        {
            var target = new FileTypesAttribute("test,testing");

            Assert.IsTrue(target.IsValid(null));
        }
Example #6
0
        public void GivenNull_WhenIValidate_ThenTrueIsReturned()
        {
            var target = new FileTypesAttribute("test,testing");

            Assert.IsTrue(target.IsValid(null));
        }