public void NormalUploadTest()
        {
            this.mockedDocument.Setup(doc => doc.SetContentStream(It.IsAny <IContentStream>(), It.Is <bool>(b => b == true), It.Is <bool>(b => b == true)))
            .Callback <IContentStream, bool, bool>((s, b, r) => s.Stream.CopyTo(this.mockedMemStream.Object))
            .Returns(new Mock <IObjectId>().Object);
            using (IFileUploader uploader = new SimpleFileUploader()) {
                transmission.AddLengthConstraint(Is.EqualTo(0).Or.EqualTo(this.localContent.Length));
                transmission.AddPositionConstraint(Is.LessThanOrEqualTo(this.localContent.Length));

                IDocument result = uploader.UploadFile(this.mockedDocument.Object, this.localFileStream, this.transmission, this.hashAlg);

                Assert.AreEqual(result, this.mockedDocument.Object);
                Assert.AreEqual(this.localContent.Length, this.mockedMemStream.Object.Length);
                Assert.AreEqual(SHA1Managed.Create().ComputeHash(this.localContent), this.hashAlg.Hash);
                this.mockedMemStream.Object.Seek(0, SeekOrigin.Begin);
                Assert.AreEqual(SHA1Managed.Create().ComputeHash(this.mockedMemStream.Object), this.hashAlg.Hash);
            }
        }
Exemple #2
0
 public static Transmission AddDefaultConstraints(this Transmission transmission)
 {
     return(transmission.AddLengthConstraint(Is.GreaterThanOrEqualTo(0)).AddPercentConstraint(Is.InRange(0, 100)).AddPositionConstraint(Is.GreaterThanOrEqualTo(0)));
 }