Пример #1
0
        public void TestCreation()
        {
            string testPath = Path.Combine(Path.GetTempPath(), "DataDirTests", "creation");

            var d1 = new DataDir(testPath);

            Assert.AreEqual(testPath, d1.Path);
            Assert.AreEqual(testPath, d1.ToString());

            var d2 = new DataDir(testPath);

            Assert.IsTrue(d1.Equals(d2));
            Assert.IsTrue(d2.Equals(d1));

            var d3 = new DataDir(Path.Combine(Path.GetTempPath(), "DataDirTests", "other"));

            Assert.IsFalse(d1.Equals(d3));
            Assert.IsFalse(d3.Equals(d1));

            Assert.ThrowsException <ArgumentException>(() => new DataDir(null));
            Assert.ThrowsException <ArgumentException>(() => new DataDir(string.Empty));
            Assert.ThrowsException <ArgumentException>(() => new DataDir(testPath + Path.GetInvalidPathChars()[0]));
        }