Ejemplo n.º 1
0
        public void Dispose()
        {
            // Act
            _textFile.Dispose();

            // Verify
            Assert.False(_memoryStream.CanRead);
            Assert.False(_memoryStream.CanWrite);
        }
Ejemplo n.º 2
0
        public void Dispose_ReturnNotThowException()
        {
            var    file   = new TextFile();
            Action action = () => file.Dispose();

            action.Should().NotThrow <Exception>();
        }
Ejemplo n.º 3
0
        public void CountTexts()
        {
            var textFile = new TextFile(TextFilePath);

            Assert.NotNull(textFile);
            Assert.NotEqual(0, textFile.Count);

            textFile.Dispose();
        }
Ejemplo n.º 4
0
        public void GetTextValueWithSpacesFromIndexer()
        {
            var textFile = new TextFile(TextFilePath);

            Assert.NotNull(textFile);

            string text = textFile[TextKeyWithSpaces];

            Assert.Equal(TextValueWithSpaces, text);

            textFile.Dispose();
        }
Ejemplo n.º 5
0
        public void GetTextValueWithTabsFromMethod()
        {
            var textFile = new TextFile(TextFilePath);

            Assert.NotNull(textFile);

            string text = textFile.GetText(TextKeyWithTabs);

            Assert.Equal(TextValueWithTabs, text);

            textFile.Dispose();
        }
Ejemplo n.º 6
0
        public void TryGetSingleCommentedTextFromMethod()
        {
            var textFile = new TextFile(TextFilePath);

            Assert.NotNull(textFile);

            var exception = Assert.Throws <KeyNotFoundException>(() =>
            {
                string value = textFile.GetText(TextSingleCommentedKey);
            });

            Assert.NotNull(exception);
            Assert.Equal(typeof(KeyNotFoundException), exception.GetType());

            textFile.Dispose();
        }
Ejemplo n.º 7
0
        public void TextFileContentEqualsNullAfterDisposable()
        {
            TestSetup();

            TextFile file = new TextFile("./file.txt");

            file.Dispose();

            Assert.IsNull(file.Content);

            // TestTool Code
            UnitTest test = Factory.CreateTest();
            TestVariable <TextFile> _file = test.CreateVariable <TextFile>();

            test.Arrange(_file, Expr(() => new TextFile("./file.txt")));
            test.Act(Expr(_file, f => f.Dispose()));
            test.Assert.IsNull(Expr(_file, f => f.Content));
            test.Execute();
        }
Ejemplo n.º 8
0
        public void TestFileContentReadsFileContentCorrectly()
        {
            TestSetup();

            TextFile file = new TextFile("./file.txt");

            Assert.AreEqual("content of file", file.Content);
            file.Dispose();

            // TestTools Code
            UnitTest test = Factory.CreateTest();
            TestVariable <TextFile> _file = test.CreateVariable <TextFile>();

            TestSetup();
            test.Arrange(_file, Expr(() => new TextFile("./file.txt")));
            test.Assert.AreEqual(Const("content of file"), Expr(_file, f => f.Content));
            test.Act(Expr(_file, f => f.Dispose()));
            test.Execute();
        }