Beispiel #1
0
        public async Task ContentEqualsAsync_ThrowsForNullStreamTaskFactory()
        {
            var exception = await Assert.ThrowsAsync <ArgumentNullException>(
                () => FileSystemUtility.ContentEqualsAsync(
                    path: "a",
                    streamTaskFactory: null));

            Assert.Equal("streamTaskFactory", exception.ParamName);
        }
Beispiel #2
0
        public async Task ContentEqualsAsync_ThrowsForNullOrEmptyPath(string path)
        {
            var exception = await Assert.ThrowsAsync <ArgumentException>(
                () => FileSystemUtility.ContentEqualsAsync(
                    path: null,
                    streamTaskFactory: () => Task.FromResult(Stream.Null)));

            Assert.Equal("path", exception.ParamName);
        }
Beispiel #3
0
        public async Task ContentEqualsAsync_ReturnsFalseIfNotEqual()
        {
            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes("a")))
                using (var testDirectory = TestDirectory.Create())
                {
                    var filePath = Path.Combine(testDirectory.Path, "file");

                    File.WriteAllText(filePath, "b");

                    var areEqual = await FileSystemUtility.ContentEqualsAsync(
                        filePath,
                        () => Task.FromResult <Stream>(stream));

                    Assert.False(areEqual);
                }
        }