本文整理汇总了C#中Newtonsoft.Json.Linq.JArray.ShouldNotBeNull方法的典型用法代码示例。如果您正苦于以下问题:C# JArray.ShouldNotBeNull方法的具体用法?C# JArray.ShouldNotBeNull怎么用?C# JArray.ShouldNotBeNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.Linq.JArray
的用法示例。
在下文中一共展示了JArray.ShouldNotBeNull方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RetrievingACustomerAddressByType
public void RetrievingACustomerAddressByType(JArray addresses)
{
const int CustomerId = 346760;
"Given existing addresses".
f(() =>
{
MockAddressesStore.Setup(i => i.GetCustomerAddresses(It.Is<int>(customerId => customerId == CustomerId), It.Is<AddressesFilter>(addressFilter => addressFilter.Type.Contains(this.AddressTypes[1])))).Returns((int customerId, AddressesFilter addressFilter) =>
{
var filteredAddresses = from n in this.FakeAddresses
where n.Value<int>("OwnerId") == customerId &&
addressFilter.Type.Contains(n.Value<string>("Type"))
select n;
return Task.FromResult<dynamic>(filteredAddresses);
});
});
"When a GET 'address type for a customer' request is sent".
f(() =>
{
Response = Client.GetAsync(new Uri(string.Format(_customerAddressesFormat, CustomerId) + "?Type=" + this.AddressTypes[1])).Result;
});
"Then the request is received by the API Controller".
f(() => MockAddressesStore.Verify(i => i.GetCustomerAddresses(It.Is<int>(customerId => customerId == CustomerId), It.Is<AddressesFilter>(addressFilter => addressFilter.Type.Contains(this.AddressTypes[1])))));
"Then a response is received by the HTTP client".
f(() =>
{
Response.Content.ShouldNotBeNull();
});
"Then content should be returned".
f(() =>
{
addresses = Response.Content.ReadAsAsync<JArray>().Result;
addresses.ShouldNotBeNull();
});
"Then a '200 OK' status is returned".
f(() => Response.StatusCode.ShouldEqual(HttpStatusCode.OK));
"Then an address is returned".
f(() => addresses.Count().ShouldEqual(1));
"Then each address references the queried customer".
f(() => addresses.ToList().ForEach(address => CustomerId.ShouldEqual(address.Value<int>("OwnerId"))));
"Then each address references the queried type".
f(() => addresses.ToList().ForEach(address => address.Value<string>("Type").ShouldEqual(this.AddressTypes[1])));
}
示例2: RetrievingAddressesByCity
public void RetrievingAddressesByCity(JArray addresses)
{
const string City = "Denver";
"Given existing addresses".
f(() =>
{
MockAddressesStore.Setup(i => i.GetAddresses(It.Is<AddressesFilter>(addressFilter => addressFilter.City == City))).Returns((AddressesFilter addressFilter) =>
{
var filteredAddresses = from n in this.FakeAddresses
where n.Value<string>("City").ToLowerInvariant().Contains(City.ToLowerInvariant())
select n;
return Task.FromResult<dynamic>(filteredAddresses);
});
});
"When a GET 'addresses by city' request is sent".
f(() =>
{
Response = Client.GetAsync(_addressesUri + "/?City=" + City).Result;
});
"Then the request is received by the API Controller".
f(() => MockAddressesStore.Verify(i => i.GetAddresses(It.Is<AddressesFilter>(addressFilter => addressFilter.City == City))));
"Then a response is received by the HTTP client".
f(() =>
{
Response.Content.ShouldNotBeNull();
});
"Then content should be returned".
f(() =>
{
addresses = Response.Content.ReadAsAsync<JArray>().Result;
addresses.ShouldNotBeNull();
});
"Then a '200 OK' status is returned".
f(() => Response.StatusCode.ShouldEqual(HttpStatusCode.OK));
"Then addresses are returned".
f(() => addresses.Count().ShouldEqual(3));
"Then each address's city references the queried city".
f(() => addresses.ToList().ForEach(address => address.Value<string>("City").ToLowerInvariant().ShouldContain(City.ToLowerInvariant())));
}
示例3: RetrievingCustomerAddressesByZipCode
public void RetrievingCustomerAddressesByZipCode(JArray addresses)
{
const int CustomerId = 346760;
const string ZipCode = "802";
"Given existing addresses".
f(() =>
{
MockAddressesStore.Setup(i => i.GetCustomerAddresses(It.Is<int>(customerId => customerId == CustomerId), It.Is<AddressesFilter>(addressFilter => addressFilter.Zip.Contains(ZipCode)))).Returns((int customerId, AddressesFilter addressFilter) =>
{
var filteredAddresses = from n in this.FakeAddresses
where n.Value<string>("ZipCode").Contains(addressFilter.Zip) &&
n.Value<int>("OwnerId") == CustomerId
select n;
return Task.FromResult<dynamic>(filteredAddresses);
});
});
"When a GET 'addresses for a customer by zip code' request is sent".
f(() =>
{
Response = Client.GetAsync(new Uri(string.Format(_customerAddressesFormat, CustomerId) + "/?Zip=" + ZipCode)).Result;
});
"Then the request is received by the API Controller".
f(() => MockAddressesStore.Verify(i => i.GetCustomerAddresses(It.Is<int>(customerId => customerId == CustomerId), It.Is<AddressesFilter>(addressFilter => addressFilter.Zip.Contains(ZipCode)))));
"Then a response is received by the HTTP client".
f(() =>
{
Response.Content.ShouldNotBeNull();
});
"Then content should be returned".
f(() =>
{
addresses = Response.Content.ReadAsAsync<JArray>().Result;
addresses.ShouldNotBeNull();
});
"Then a '200 OK' status is returned".
f(() => Response.StatusCode.ShouldEqual(HttpStatusCode.OK));
"Then addresses are returned".
f(() => addresses.Count().ShouldEqual(2));
"Then the address references the queried customer".
f(() => addresses.First().Value<int>("OwnerId").ShouldEqual(CustomerId));
"Then each address references the queried zip code".
f(() => addresses.ToList().ForEach(address => address.Value<string>("ZipCode").ShouldContain(ZipCode)));
}
示例4: RetrievingAllCustomerAddresses
public void RetrievingAllCustomerAddresses(JArray addresses)
{
const int CustomerId = 346760;
"Given existing addresses".
f(() =>
{
MockAddressesStore.Setup(i => i.GetCustomerAddresses(It.Is<int>(customerId => customerId == CustomerId), It.IsAny<AddressesFilter>())).Returns((int customerId, AddressesFilter addressFilter) =>
{
var filteredAddresses = from n in this.FakeAddresses
where customerId == n.Value<int>("OwnerId")
select n;
return Task.FromResult<dynamic>(filteredAddresses);
});
});
"When a GET 'all addresses for a customer' request is sent".
f(() =>
{
Response = Client.GetAsync(new Uri(string.Format(_customerAddressesFormat, CustomerId))).Result;
});
"Then the request is received by the API Controller".
f(() => MockAddressesStore.Verify(i => i.GetCustomerAddresses(It.Is<int>(customerId => customerId == CustomerId), It.IsAny<AddressesFilter>())));
"Then a response is received by the HTTP client".
f(() =>
{
Response.Content.ShouldNotBeNull();
});
"Then content should be returned".
f(() =>
{
addresses = Response.Content.ReadAsAsync<JArray>().Result;
addresses.ShouldNotBeNull();
});
"Then a '200 OK' status is returned".
f(() => Response.StatusCode.ShouldEqual(HttpStatusCode.OK));
"Then all addresses are returned for the owner".
f(() => addresses.Count().ShouldEqual(3));
"Then each address references the expected owner id".
f(() => addresses.ToList().ForEach(address => address.Value<int>("OwnerId").ShouldEqual(CustomerId)));
}
示例5: RetrievingAnAddressTypeForAnOwner
public void RetrievingAnAddressTypeForAnOwner(JArray addresses)
{
const int OwnerIdTest = 346760;
"Given existing addresses".
f(() =>
{
MockAddressesStore.Setup(i => i.GetAddresses(It.Is<AddressesFilter>(addressFilter => addressFilter.OwnerId.Contains(OwnerIdTest) && addressFilter.Type.Contains(this.AddressTypes[2])))).Returns((AddressesFilter addressFilter) =>
{
var filteredAddresses = from n in this.FakeAddresses
where addressFilter.OwnerId.Contains(n.Value<int>("OwnerId")) &&
addressFilter.Type.Contains(n.Value<string>("Type"))
select n;
return Task.FromResult<dynamic>(filteredAddresses);
});
});
"When a GET 'address for owner id and type' request is sent".
f(() =>
{
Response = Client.GetAsync(new Uri(_addressesUri + "/?OwnerId=" + OwnerIdTest + "&Type=" + this.AddressTypes[2])).Result;
});
"Then the request is received by the API Controller".
f(() => MockAddressesStore.Verify(i => i.GetAddresses(It.Is<AddressesFilter>(addressFilter => addressFilter.OwnerId.Contains(OwnerIdTest) && addressFilter.Type.Contains(this.AddressTypes[2])))));
"Then a response is received by the HTTP client".
f(() =>
{
Response.Content.ShouldNotBeNull();
});
"Then content should be returned".
f(() =>
{
addresses = Response.Content.ReadAsAsync<JArray>().Result;
addresses.ShouldNotBeNull();
});
"Then a '200 OK' status is returned".
f(() => Response.StatusCode.ShouldEqual(HttpStatusCode.OK));
"Then an address is returned".
f(() => addresses.Count().ShouldEqual(1));
"Then the address references the queried owner id".
f(() => addresses.ToList().ForEach(address => OwnerIdTest.ShouldEqual(address.Value<int>("OwnerId"))));
"Then the address references the queried type".
f(() => addresses.ToList().ForEach(address => address.Value<string>("Type").ShouldEqual(this.AddressTypes[2])));
}
示例6: RetrievingAllAddressesForOwnerTypes
public void RetrievingAllAddressesForOwnerTypes(JArray addresses)
{
string[] ownerType = { "BUS", "PER" };
"Given existing addresses".
f(() =>
{
MockAddressesStore.Setup(i => i.GetAddresses(It.Is<AddressesFilter>(addressFilter => addressFilter.OwnerType.Contains(ownerType[0]) && addressFilter.OwnerType.Contains(ownerType[1])))).Returns((AddressesFilter addressFilter) =>
{
var filteredAddresses = from n in this.FakeAddresses
where addressFilter.OwnerType.Contains(n.Value<string>("OwnerType"))
select n;
return Task.FromResult<dynamic>(filteredAddresses);
});
});
"When a GET 'addresses for multiple owner types' request is sent".
f(() =>
{
Response = Client.GetAsync(new Uri(_addressesUri + "/?OwnerType=" + ownerType[0] + "&OwnerType=" + ownerType[1])).Result;
});
"Then the request is received by the API Controller".
f(() => MockAddressesStore.Verify(i => i.GetAddresses(It.Is<AddressesFilter>(addressFilter => addressFilter.OwnerType.Contains(ownerType[0]) && addressFilter.OwnerType.Contains(ownerType[1])))));
"Then a response is received by the HTTP client".
f(() =>
{
Response.Content.ShouldNotBeNull();
});
"Then content should be returned".
f(() =>
{
addresses = Response.Content.ReadAsAsync<JArray>().Result;
addresses.ShouldNotBeNull();
});
"Then a '200 OK' status is returned".
f(() => Response.StatusCode.ShouldEqual(HttpStatusCode.OK));
"Then the expected addresses are returned".
f(() => addresses.Count().ShouldEqual(9));
"Then each address references a queried owner type".
f(() => addresses.ToList().ForEach(address => new string[] { ownerType[0], ownerType[1] }.ShouldContain(address.Value<string>("OwnerType"))));
}
示例7: RetrievingAllAddressesForOwnerName
public void RetrievingAllAddressesForOwnerName(JArray addresses)
{
const string OwnerNameTest = "THE DILLION COMPANY";
"Given existing addresses".
f(() =>
{
MockAddressesStore.Setup(i => i.GetAddresses(It.Is<AddressesFilter>(addressFilter => addressFilter.OwnerName.Contains(OwnerNameTest)))).Returns((AddressesFilter addressFilter) =>
{
var filteredAddresses = from n in this.FakeAddresses
where addressFilter.OwnerName.Contains(n.Value<string>("OwnerName"))
select n;
return Task.FromResult<dynamic>(filteredAddresses);
});
});
"When a GET 'all addresses for owner name' request is sent".
f(() =>
{
Response = Client.GetAsync(new Uri(_addressesUri + "/?OwnerName=" + OwnerNameTest)).Result;
});
"Then the request is received by the API Controller".
f(() => MockAddressesStore.Verify(i => i.GetAddresses(It.Is<AddressesFilter>(addressFilter => addressFilter.OwnerName.Contains(OwnerNameTest)))));
"Then a response is received by the HTTP client".
f(() =>
{
Response.Content.ShouldNotBeNull();
});
"Then content should be returned".
f(() =>
{
addresses = Response.Content.ReadAsAsync<JArray>().Result;
addresses.ShouldNotBeNull();
});
"Then a '200 OK' status is returned".
f(() => Response.StatusCode.ShouldEqual(HttpStatusCode.OK));
"Then all addresses are returned for the queried owner name".
f(() => addresses.Count().ShouldEqual(3));
"Then each address references the expected owner name".
f(() => addresses.ToList().ForEach(address => address.Value<string>("OwnerName").ShouldEqual(OwnerNameTest)));
}
示例8: RetrievingAllAddressesForOwnerIds
public void RetrievingAllAddressesForOwnerIds(JArray addresses)
{
const int OwnerId1 = 346760;
const int OwnerId2 = 42165;
"Given existing addresses".
f(() =>
{
MockAddressesStore.Setup(i => i.GetAddresses(It.Is<AddressesFilter>(addressFilter => addressFilter.OwnerId.Contains(OwnerId1) && addressFilter.OwnerId.Contains(OwnerId2)))).Returns((AddressesFilter addressFilter) =>
{
var filteredAddresses = from n in this.FakeAddresses
where addressFilter.OwnerId.Contains(n.Value<int>("OwnerId"))
select n;
return Task.FromResult<dynamic>(filteredAddresses);
});
});
"When a GET 'addresses for multiple owner ids' request is sent".
f(() =>
{
Response = Client.GetAsync(new Uri(_addressesUri + "/?OwnerId=" + OwnerId1 + "&OwnerId=" + OwnerId2)).Result;
});
"Then the request is received by the API Controller".
f(() => MockAddressesStore.Verify(i => i.GetAddresses(It.Is<AddressesFilter>(addressFilter => addressFilter.OwnerId.Contains(OwnerId1) && addressFilter.OwnerId.Contains(OwnerId2)))));
"Then a response is received by the HTTP client".
f(() =>
{
Response.Content.ShouldNotBeNull();
});
"Then content should be returned".
f(() =>
{
addresses = Response.Content.ReadAsAsync<JArray>().Result;
addresses.ShouldNotBeNull();
});
"Then a '200 OK' status is returned".
f(() => Response.StatusCode.ShouldEqual(HttpStatusCode.OK));
"Then the expected addresses are returned".
f(() => addresses.Count().ShouldEqual(4));
"Then each address references a queried owner".
f(() => addresses.ToList().ForEach(address => new int[] { OwnerId1, OwnerId2 }.ShouldContain(address.Value<int>("OwnerId"))));
}
示例9: RetrievingAllAddresses
public void RetrievingAllAddresses(JArray addresses)
{
"Given existing addresses".
f(() =>
{
MockAddressesStore.Setup(i => i.GetAddresses(It.Is<AddressesFilter>(filter => filter == null))).Returns<dynamic>(filter =>
{
return Task.FromResult<dynamic>(this.FakeAddresses);
});
});
"When a GET addresses request is sent".
f(() =>
{
Response = Client.GetAsync(_addressesUri).Result;
});
"Then the request is received by the API Controller".
f(() => MockAddressesStore.Verify(i => i.GetAddresses(It.IsAny<AddressesFilter>())));
"Then a response is received by the HTTP client".
f(() =>
{
Response.Content.ShouldNotBeNull();
});
"Then content should be returned".
f(() =>
{
addresses = Response.Content.ReadAsAsync<JArray>().Result;
addresses.ShouldNotBeNull();
});
"Then a '200 OK' status is returned".
f(() => Response.StatusCode.ShouldEqual(HttpStatusCode.OK));
"Then all addresses are returned for all customers".
f(() => addresses.Count().ShouldEqual(this.FakeAddresses.Count()));
}
示例10: RetrievingAddressesByTypes
public void RetrievingAddressesByTypes(JArray addresses)
{
"Given existing addresses".
f(() =>
{
MockAddressesStore.Setup(i => i.GetAddresses(It.Is<AddressesFilter>(addressFilter => addressFilter.Type.Contains(this.AddressTypes[0]) && addressFilter.Type.Contains(this.AddressTypes[1])))).Returns((AddressesFilter addressFilter) =>
{
var filteredAddresses = from n in this.FakeAddresses
where addressFilter.Type.Contains(n.Value<string>("Type"))
select n;
return Task.FromResult<dynamic>(filteredAddresses);
});
});
"When a GET 'addresses by multiple types' request is sent".
f(() =>
{
Response = Client.GetAsync(_addressesUri + "/?Type=" + this.AddressTypes[0] + "&Type=" + this.AddressTypes[1]).Result;
});
"Then the request is received by the API Controller".
f(() => MockAddressesStore.Verify(i => i.GetAddresses(It.Is<AddressesFilter>(addressFilter => addressFilter.Type.Contains(this.AddressTypes[1]) && addressFilter.Type.Contains(this.AddressTypes[1])))));
"Then a response is received by the HTTP client".
f(() =>
{
Response.Content.ShouldNotBeNull();
});
"Then content should be returned".
f(() =>
{
addresses = Response.Content.ReadAsAsync<JArray>().Result;
addresses.ShouldNotBeNull();
});
"Then a '200 OK' status is returned".
f(() => Response.StatusCode.ShouldEqual(HttpStatusCode.OK));
"Then addresses are returned".
f(() => addresses.Count().ShouldEqual(6));
"Then each address references a queried type".
f(() => addresses.ToList().ForEach(address => new string[] { this.AddressTypes[0], this.AddressTypes[1] }.Contains(address.Value<string>("Type"))));
}
示例11: RetrievingAddressesByStreet2
public void RetrievingAddressesByStreet2(JArray addresses)
{
const string Street2 = "VOGELWEIHERSTR";
"Given existing addresses".
f(() =>
{
MockAddressesStore.Setup(i => i.GetAddresses(It.Is<AddressesFilter>(addressFilter => addressFilter.Street2.Contains(Street2)))).Returns((AddressesFilter addressFilter) =>
{
var filteredAddresses = from n in this.FakeAddresses
where n.Value<string>("Street2") != null &&
n.Value<string>("Street2").Contains(addressFilter.Street2)
select n;
return Task.FromResult<dynamic>(filteredAddresses);
});
});
"When a GET 'addresses by street2' request is sent".
f(() =>
{
Response = Client.GetAsync(_addressesUri + "/?Street2=" + Street2).Result;
});
"Then the request is received by the API Controller".
f(() => MockAddressesStore.Verify(i => i.GetAddresses(It.Is<AddressesFilter>(addressFilter => addressFilter.Street2.Contains(Street2)))));
"Then a response is received by the HTTP client".
f(() =>
{
Response.Content.ShouldNotBeNull();
});
"Then content should be returned".
f(() =>
{
addresses = Response.Content.ReadAsAsync<JArray>().Result;
addresses.ShouldNotBeNull();
});
"Then a '200 OK' status is returned".
f(() => Response.StatusCode.ShouldEqual(HttpStatusCode.OK));
"Then addresses are returned".
f(() => addresses.Count().ShouldEqual(1));
"Then each address references the queried street2".
f(() => addresses.ToList().ForEach(address => address.Value<string>("Street2").ShouldContain(Street2)));
}