Exemplo n.º 1
0
        public void ReadContentReturnsFileDataTest()
        {
            var name     = Guid.NewGuid().ToString();
            var value    = Path.GetTempFileName();
            var expected = Guid.NewGuid().ToString();

            try
            {
                File.WriteAllText(value, expected);

                var target = new PostFileEntry(name, value);

                using (var stream = target.ReadContent())
                {
                    using (var reader = new StreamReader(stream))
                    {
                        var actual = reader.ReadToEnd();

                        actual.Should().Be(expected);
                    }
                }

                target.IsValid.Should().BeTrue();
            }
            finally
            {
                File.Delete(value);
            }
        }
Exemplo n.º 2
0
        public void IsValidReturnsFalseWhenValueIsNullTest()
        {
            var name = Guid.NewGuid().ToString();

            var target = new PostFileEntry(name, null);

            target.IsValid.Should().BeFalse();
        }
Exemplo n.º 3
0
        public void IsValidReturnsFalseWhenValueIsWhiteSpaceTest()
        {
            var name = Guid.NewGuid().ToString();

            var target = new PostFileEntry(name, "  ");

            target.IsValid.Should().BeFalse();
        }
Exemplo n.º 4
0
        public void IsValidReturnsFalseWhenValueIsEmptyTest()
        {
            var name = Guid.NewGuid().ToString();

            var target = new PostFileEntry(name, string.Empty);

            target.IsValid.Should().BeFalse();
        }
Exemplo n.º 5
0
        public void IsValidReturnsFalseWhenFileDoesNotExistTest()
        {
            var name = Guid.NewGuid().ToString();
            var value = Guid.NewGuid().ToString();

            var target = new PostFileEntry(name, value);

            target.IsValid.Should().BeFalse();
        }
Exemplo n.º 6
0
        public void CanCreateWithNullValueTest()
        {
            var name = Guid.NewGuid().ToString();

            var target = new PostFileEntry(name, null);

            target.Name.Should().Be(name);
            target.Value.Should().BeNull();
        }
Exemplo n.º 7
0
        public void IsValidReturnsFalseWhenFileDoesNotExistTest()
        {
            var name  = Guid.NewGuid().ToString();
            var value = Guid.NewGuid().ToString();

            var target = new PostFileEntry(name, value);

            target.IsValid.Should().BeFalse();
        }
Exemplo n.º 8
0
        public void CanCreateWithNullValueTest()
        {
            var name = Guid.NewGuid().ToString();

            var target = new PostFileEntry(name, null);

            target.Name.Should().Be(name);
            target.Value.Should().BeNull();
        }
Exemplo n.º 9
0
        public void CanCreateWithValueDataTest()
        {
            var name = Guid.NewGuid().ToString();
            var value = Guid.NewGuid().ToString();

            var target = new PostFileEntry(name, value);

            target.Name.Should().Be(name);
            target.Value.Should().Be(value);
        }
Exemplo n.º 10
0
        public void CanCreateWithValueDataTest()
        {
            var name  = Guid.NewGuid().ToString();
            var value = Guid.NewGuid().ToString();

            var target = new PostFileEntry(name, value);

            target.Name.Should().Be(name);
            target.Value.Should().Be(value);
        }
Exemplo n.º 11
0
        public void IsValidReturnsTrueForValidFilePathValueTest()
        {
            var name  = Guid.NewGuid().ToString();
            var value = Path.GetTempFileName();

            try
            {
                var target = new PostFileEntry(name, value);

                target.IsValid.Should().BeTrue();
            }
            finally
            {
                File.Delete(value);
            }
        }
Exemplo n.º 12
0
        public void ReadContentReturnsFileDataTest()
        {
            var name = Guid.NewGuid().ToString();
            var value = Path.GetTempFileName();
            var expected = Guid.NewGuid().ToString();

            try
            {
                File.WriteAllText(value, expected);

                var target = new PostFileEntry(name, value);

                using (var stream = target.ReadContent())
                {
                    using (var reader = new StreamReader(stream))
                    {
                        var actual = reader.ReadToEnd();

                        actual.Should().Be(expected);
                    }
                }

                target.IsValid.Should().BeTrue();
            }
            finally
            {
                File.Delete(value);
            }
        }
Exemplo n.º 13
0
        public void IsValidReturnsTrueForValidFilePathValueTest()
        {
            var name = Guid.NewGuid().ToString();
            var value = Path.GetTempFileName();

            try
            {
                var target = new PostFileEntry(name, value);

                target.IsValid.Should().BeTrue();
            }
            finally
            {
                File.Delete(value);
            }
        }