Ejemplo n.º 1
0
        public void BlobDownloadOptionsDeepCopyDefault()
        {
            BlobDownloadOptions original = default;
            BlobDownloadOptions deepCopy = BlobDownloadOptions.CloneOrDefault(original);

            Assert.IsNull(deepCopy);
        }
Ejemplo n.º 2
0
        public void BlobDownloadOptionsDeepCopy()
        {
            // note these are all non-default values
            BlobDownloadOptions MakeOriginal()
            {
                return(new BlobDownloadOptions
                {
                    Conditions = new BlobRequestConditions
                    {
                        IfModifiedSince = DateTime.Now,
                        IfUnmodifiedSince = DateTime.Now,
                        IfMatch = new ETag("foo"),
                        IfNoneMatch = new ETag("bar")
                    },
                    Range = new HttpRange(offset: 1, length: 1),
                    TransactionalHashingOptions = new DownloadTransactionalHashingOptions
                    {
                        Algorithm = TransactionalHashAlgorithm.MD5,
                        Validate = true
                    }
                });
            }

            var original = MakeOriginal();
            var deepCopy = BlobDownloadOptions.CloneOrDefault(original);

            // test deep copy successful equality
            Assert.IsTrue(ReflectiveValueEqual(original, deepCopy), "deep copy did not properly clone");

            // test deep copy no longer equal when one value changed
            deepCopy.Range = new HttpRange(offset: 1, length: 2);
            Assert.IsFalse(ReflectiveValueEqual(original, deepCopy), "change to deep copy affected original");

            // TODO perhaps come up with exhaustive test to ensure this is true for all possible changes
        }