コード例 #1
0
        public void AbortWriteIfAbortIsCalled()
        {
            var transmission = new Transmission(TransmissionType.DOWNLOAD_MODIFIED_FILE, "path");

            using (var inputStream = new MemoryStream(new byte[1024 * 1024 * 10]))
                using (var stream = new Mock <MemoryStream>()
                {
                    CallBase = true
                }.Object)
                    using (var underTest = new TransmissionStream(stream, transmission)) {
                        transmission.Abort();
                        Assert.Throws <AbortException>(() => inputStream.CopyTo(underTest));
                        Mock.Get(stream).Verify(s => s.WriteByte(It.IsAny <byte>()), Times.Never());
                        Mock.Get(stream).Verify(s => s.Write(It.IsAny <byte[]>(), It.IsAny <int>(), It.IsAny <int>()), Times.Never());
                    }
        }
コード例 #2
0
        public void AbortReadIfAbortIsCalled()
        {
            var transmission = new Transmission(TransmissionType.DOWNLOAD_MODIFIED_FILE, "path");

            byte[] content = new byte[1024];
            using (var outputStream = new MemoryStream())
                using (var stream = new Mock <MemoryStream>()
                {
                    CallBase = true
                }.Object)
                    using (var underTest = new TransmissionStream(stream, transmission)) {
                        transmission.Abort();
                        Assert.Throws <AbortException>(() => underTest.CopyTo(outputStream));
                        Mock.Get(stream).Verify(s => s.ReadByte(), Times.Never());
                        Mock.Get(stream).Verify(s => s.Read(It.IsAny <byte[]>(), It.IsAny <int>(), It.IsAny <int>()), Times.Never());
                    }
        }
コード例 #3
0
        public void Resume()
        {
            var underTest = new Transmission(TransmissionType.DOWNLOAD_NEW_FILE, this.path);

            underTest.Resume();
            Assert.That(underTest.Status == TransmissionStatus.TRANSMITTING);
            underTest.Pause();
            underTest.Resume();
            Assert.That(underTest.Status == TransmissionStatus.TRANSMITTING);

            underTest.Abort();
            underTest.Resume();
            Assert.That(underTest.Status == TransmissionStatus.ABORTING);
            underTest.Status = TransmissionStatus.ABORTED;
            underTest.Resume();
            Assert.That(underTest.Status == TransmissionStatus.ABORTED);
        }