public void Execute_BlockListWithContent_ContentSetProperly() { var expectedContainer = "test-container"; var expectedBlob = "test-blob"; var expectedUri = String.Format("{0}/{1}/{2}?comp=blocklist", _settings.BlobEndpoint, expectedContainer, expectedBlob); var expectedRawRequest = new TestableWebRequest(new Uri(expectedUri)) .EnqueueResponse(new HttpResponseSettings((HttpStatusCode)201, "Created", "", false, new Dictionary <string, string>() { { "ETag", "\"123\"" }, { "Date", DateTime.UtcNow.ToString() }, { "Last-Modified", DateTime.UtcNow.ToString() }, { "Content-MD5", "123-MD5" } })); TestableWebRequestCreateFactory.GetFactory().AddRequest(expectedRawRequest); var id1 = Base64Converter.ConvertToBase64("id1"); var id2 = Base64Converter.ConvertToBase64("id2"); var id3 = Base64Converter.ConvertToBase64("id3"); var expectedData = string.Format( @"<?xml version=""1.0"" encoding=""utf-8""?><BlockList><Committed>{0}</Committed><Uncommitted>{1}</Uncommitted><Latest>{2}</Latest></BlockList>", id1, id2, id3); var givenData = new BlockListBlockIdList { new BlockListBlockId { Id = id1, ListType = PutBlockListListType.Committed }, new BlockListBlockId { Id = id2, ListType = PutBlockListListType.Uncommitted }, new BlockListBlockId { Id = id3, ListType = PutBlockListListType.Latest } }; var request = new PutBlockListRequest(_settings, expectedContainer, expectedBlob, givenData); request.Execute(); Assert.AreEqual(expectedData, Encoding.UTF8.GetString(givenData.AsXMLByteArray())); }
public void Execute_BlockListWithContent_ContentSetProperly() { var expectedContainer = "test-container"; var expectedBlob = "test-blob"; var expectedUri = String.Format("{0}/{1}/{2}?comp=blocklist", _settings.BlobEndpoint, expectedContainer, expectedBlob); var expectedRawRequest = new TestableWebRequest(new Uri(expectedUri)) .EnqueueResponse(new HttpResponseSettings((HttpStatusCode)201, "Created", "", false, new Dictionary<string, string>(){ {"ETag", "\"123\""}, {"Date", DateTime.UtcNow.ToString() }, {"Last-Modified", DateTime.UtcNow.ToString() }, {"Content-MD5", "123-MD5" } })); TestableWebRequestCreateFactory.GetFactory().AddRequest(expectedRawRequest); var id1 = Base64Converter.ConvertToBase64("id1"); var id2 = Base64Converter.ConvertToBase64("id2"); var id3 = Base64Converter.ConvertToBase64("id3"); var expectedData = string.Format( @"<?xml version=""1.0"" encoding=""utf-8""?><BlockList><Committed>{0}</Committed><Uncommitted>{1}</Uncommitted><Latest>{2}</Latest></BlockList>", id1, id2, id3); var givenData = new BlockListBlockIdList { new BlockListBlockId { Id = id1, ListType = PutBlockListListType.Committed}, new BlockListBlockId { Id = id2, ListType = PutBlockListListType.Uncommitted}, new BlockListBlockId { Id = id3, ListType = PutBlockListListType.Latest} }; var request = new PutBlockListRequest(_settings, expectedContainer, expectedBlob, givenData); request.Execute(); Assert.AreEqual(expectedData, Encoding.UTF8.GetString(givenData.AsXMLByteArray())); }