public void Validate_WhenStreamLengthIsTooLarge_Throws()
        {
            using (var stream = new CustomLengthStream(MaximumSizeInBytes + 1))
            {
                var file      = new StubHttpPostedFile(contentLength: 1024, fileName: "a.cer", inputStream: stream);
                var exception = Assert.Throws <UserSafeException>(() => new CertificateValidator().Validate(file));

                Assert.Equal($"The file exceeds the size limit of {MaximumSizeInBytes} bytes.", exception.Message);
            }
        }
        public void Validate_WhenStreamLengthIsTooSmall_Throws(long streamLength)
        {
            using (var stream = new CustomLengthStream(streamLength))
            {
                var file      = new StubHttpPostedFile(contentLength: 1024, fileName: "a.cer", inputStream: stream);
                var exception = Assert.Throws <UserSafeException>(() => new CertificateValidator().Validate(file));

                Assert.Equal("The file length is invalid.", exception.Message);
            }
        }