public void BlobStreamUriRefresh()
        {
            string xml = FeedStart +
                         MediaEntry(
                id: "http://localhost/eset(1)",
                editLink: "eset(1)",
                readStreamUrl: "http://media-entry/v1/",
                mediaType: "text/plain",
                properties: "<d:ID>1</d:ID>",
                editStreamUrl: "http://edit-media-link/v1/") +
                         "</feed>";

            string xmlV2 = xml.Replace("/v1/", "/v2/");
            CombinatorialEngine engine = CombinatorialEngine.FromDimensions(
                new Dimension("StartingState", EntityStateData.Values),
                new Dimension("MergeOption", MergeOptionData.Values));

            TestUtil.RunCombinatorialEngineFail(engine, (values) =>
            {
                this.ClearContext();

                EntityStateData startingState = (EntityStateData)values["StartingState"];
                MergeOptionData option        = (MergeOptionData)values["MergeOption"];

                // Set up the entity to match the identity on the sample XML.
                Photo entity = new Photo();
                entity.ID    = 1;
                startingState.ApplyToObject(this.context, entity, "eset");
                if (startingState.State != EntityStates.Detached)
                {
                    Uri identity = this.context.Entities.Single().Identity;
                    Trace.WriteLine("Identity: " + (identity == null ? String.Empty : identity.AbsoluteUri));
                }

                this.context.MergeOption = option.Option;
                var response             = QueryResponse(xml, this.context.CreateQuery <Photo>("eset"));
                foreach (var item in response)
                {
                    Assert.IsNotNull(item);
                    Assert.AreEqual(1, item.ID, "item.ID");
                }

                if (option.IsTracking)
                {
                    // If we started off detached, then the context created its own copy.
                    if (startingState.State == EntityStates.Detached)
                    {
                        entity = (Photo)this.context.Entities.Single().Entity;
                    }

                    EntityStates expectedState = startingState.ExpectedStateAfterRefresh(option.Option);
                    EntityStates actualState   = EntityStateData.GetStateForEntity(this.context, entity);
                    Assert.AreEqual(expectedState, actualState, "state of entity after reading");
                    if (startingState.State != EntityStates.Added)
                    {
                        AssertEntityCount(1, "single tracked entity at this point");
                    }
                    else
                    {
                        AssertEntityCount(2, "two tracked entities at this point");

                        // Get the entity that was loaded, not the one that we originally created.
                        entity = (Photo)this.context.Entities.Where(o => o.Entity != entity).Single().Entity;
                    }
                }
                else
                {
                    if (startingState.State == EntityStates.Detached)
                    {
                        // Nothing else to do in this test, as effectively nothing changes.
                        AssertEntityCount(0, "nothing tracked, nothing attached.");
                        return;
                    }
                    else
                    {
                        AssertEntityCount(1, "nothing tracked, but we did attach something during test setup.");
                    }
                }

                Uri readStreamUri           = this.context.GetReadStreamUri(entity);
                EntityDescriptor descriptor = this.context.GetEntityDescriptor(entity);
                if (option.IsTracking)
                {
                    Assert.IsNotNull(readStreamUri, "readStreamUri");
                    Assert.AreEqual("http://media-entry/v1/", readStreamUri.OriginalString, "readStreamUri.OriginalString");

                    Assert.IsNotNull(descriptor.EditLink, "descriptor.EditLink");
                    Assert.AreEqual("http://localhost/eset(1)", descriptor.EditLink.OriginalString, "descriptor.EditLink.OriginalString");

                    Assert.IsNotNull(descriptor.EditStreamUri, "descriptor.EditStreamUri");
                    Assert.AreEqual("http://edit-media-link/v1/", descriptor.EditStreamUri.OriginalString, "descriptor.EditStreamUri.OriginalString");

                    Assert.IsNotNull(descriptor.ReadStreamUri, "descriptor.ReadStreamUri");
                    Assert.AreEqual(readStreamUri, descriptor.ReadStreamUri, "GetReadStreamUri and descriptor.ReadStreamUri");
                }
                else
                {
                    Assert.AreEqual(startingState.State, descriptor.State, "descriptor.State");
                    AssertDescriptorForNonTrackedRefresh(readStreamUri, descriptor);
                }

                response = QueryResponse(xmlV2, this.context.CreateQuery <Photo>("eset"));
                foreach (var item in response)
                {
                    Assert.IsNotNull(item);
                    Assert.AreEqual(1, item.ID, "item.ID");
                }

                readStreamUri = this.context.GetReadStreamUri(entity);
                descriptor    = this.context.GetEntityDescriptor(entity);
                if (option.IsTracking)
                {
                    Assert.IsNotNull(readStreamUri, "readStreamUri");
                    Assert.AreEqual("http://media-entry/v2/", readStreamUri.OriginalString, "readStreamUri.OriginalString");

                    Assert.IsNotNull(descriptor.EditLink, "descriptor.EditLink");
                    Assert.AreEqual("http://localhost/eset(1)", descriptor.EditLink.OriginalString, "descriptor.EditLink.OriginalString");

                    Assert.IsNotNull(descriptor.EditStreamUri, "descriptor.EditStreamUri");
                    Assert.AreEqual("http://edit-media-link/v2/", descriptor.EditStreamUri.OriginalString, "descriptor.EditStreamUri.OriginalString");

                    Assert.IsNotNull(descriptor.ReadStreamUri, "descriptor.ReadStreamUri");
                    Assert.AreEqual(readStreamUri, descriptor.ReadStreamUri, "GetReadStreamUri and descriptor.ReadStreamUri");
                }
                else
                {
                    AssertDescriptorForNonTrackedRefresh(readStreamUri, descriptor);
                }
            });
        }