Exemplo n.º 1
0
        public async Task WriteAsync_ThrowsArgumentNullException_WhenStreamIsNull()
        {
            //Arrange
            var file = new LocalFile(@"C:\TestPath");

            //Act
            await file.WriteAsync(null); //Exception
        }
Exemplo n.º 2
0
        public async Task WriteAsync_ThrowsArgumentException_WhenStreamIsntReadable()
        {
            //Arrange
            Mock<Stream> streamMock = new Mock<Stream>();
            streamMock.Setup(m => m.CanRead).Returns(false);

            Stream stream = streamMock.Object;
            var file = new LocalFile(@"C:\TestPath");

            //Act & Assert
            await file.WriteAsync(stream); //Exception
        }
Exemplo n.º 3
0
        public async Task WriteAsync_WritesText123_ToFile()
        {
            //Arrange
            string expected = "123";
            string actual;
            var file = new LocalFile(_path);
            byte[] text = expected.Select(Convert.ToByte).ToArray();

            //Act
            using (var memoryStream = new MemoryStream(text))
            {
                await file.WriteAsync(memoryStream);
            }

            actual = File.ReadAllText(_path);

            //Assert
            Assert.AreEqual(expected, actual);
        }