Beispiel #1
0
        public void Returns_ValidationResult_If_Not_Required_But_Still_Invalid()
        {
            var invalidFile = IFormFileBuilder.CreateMockFormFile("hi.exe");
            var model       = new Model()
            {
                NotRequiredFile = invalidFile
            };

            Assert.True(ModelValidator.ValidateModel(model).Count > 0);
        }
        public void Returns_ValidationResult_If_Leading_Decimal(string fileName)
        {
            var justExtensions = IFormFileBuilder.CreateMockFormFile(fileName);
            var model          = new Model()
            {
                RequiredFile = justExtensions
            };

            Assert.True(ModelValidator.ValidateModel(model).Count > 0);
        }
        public void Returns_ValidationResult_If_Invalid_Extension(string fileName)
        {
            var invalidFile = IFormFileBuilder.CreateMockFormFile(fileName);
            var model       = new Model()
            {
                RequiredFile = invalidFile
            };

            Assert.True(ModelValidator.ValidateModel(model).Count > 0);
        }
        public void Returns_ValidationResult_If_No_Extension()
        {
            var noExtFile = IFormFileBuilder.CreateMockFormFile("sneaky");
            var model     = new Model()
            {
                RequiredFile = noExtFile
            };

            Assert.True(ModelValidator.ValidateModel(model).Count > 0);
        }
        public void Returns_ValidationSuccess_If_Extensions_Match()
        {
            var validFile = IFormFileBuilder.CreateMockFormFile("valid.jpg");
            var model     = new Model()
            {
                RequiredFile = validFile
            };

            Assert.True(ModelValidator.ValidateModel(model).Count == 0);
        }
        public async Task Returns_Unchanged_Part_If_IFormFile_Extension_Invalid(string fileName)
        {
            var expectedImagePath = _mockPart.ImagePath;
            var expectedThumbPath = _mockPart.ImageThumbPath;
            var invalidFile       = IFormFileBuilder.CreateMockFormFile(fileName);

            var modifiedPart = await _fileHandler.SetPartImage(_mockPart, invalidFile);

            Assert.Equal(expectedImagePath, modifiedPart.ImagePath);
            Assert.Equal(expectedThumbPath, modifiedPart.ImageThumbPath);
        }
        public async Task Returns_Unchanged_Part_If_IFormFile_Null()
        {
            var expectedImagePath = _mockPart.ImagePath;
            var expectedThumbPath = _mockPart.ImageThumbPath;
            var nullFile          = IFormFileBuilder.CreateNullFormFile();

            var modifiedPart = await _fileHandler.SetPartImage(_mockPart, nullFile);

            Assert.Equal(expectedImagePath, modifiedPart.ImagePath);
            Assert.Equal(expectedThumbPath, modifiedPart.ImageThumbPath);
        }
Beispiel #8
0
        public void Returns_ValidationResult_If_Size_Exceeds_Spec()
        {
            var oneByteOver5Mb = 5242881;
            var largeFile      = IFormFileBuilder.CreateMockFormFile("Foo", oneByteOver5Mb);

            var invalidModel = new Model()
            {
                File = largeFile
            };

            Assert.True(ModelValidator.ValidateModel(invalidModel).Count > 0);
        }