tisdag 7 september 2021

dynamic stuff = JsonConvert.DeserializeObject("{ 'Name': 'Jon Smith', 'Address': { 'City': 'New York', 'State': 'NY' }, 'Age': 42 }");

string name = stuff.Name;
string address = stuff.Address.City;
https://stackoverflow.com/questions/3142495/deserialize-json-into-c-sharp-dynamic-object

tisdag 13 april 2021

Token

var data = pm.response.json();
pm.environment.set("Token", "Bearer "+ data.access_token);

torsdag 18 mars 2021

Get header value from request

private string GetHeaderValue(string key)
{
    Request.Headers.TryGetValue(key, out var value);
    if (string.IsNullOrWhiteSpace(value))
        throw new ArgumentException($"Key missing: {key}");
    return value;
}

torsdag 14 maj 2020

TryParse

var x = int.TryParse(ValueToParse, out var number) ? number : default(int?)

onsdag 24 oktober 2018

Sökväg för testfiler

var basepath = TestContext.CurrentContext.TestDirectory;

torsdag 24 maj 2018

Mongo Select

Exitst
{"identifier": { $exists: true }}

Contains
{ "identifier": /.*name.*/I }
{ "identifier" : { $regex : /Name/i } }

Starts with
{ "identifier": /^true.*/I }

Ends with
{ "identifier": /.*true$/I }

Equal (== 1)
{ "identifier": "1" }

Not equal (!=1)
{ "identifier": { $ne: "1" } }

In
{ "identifier": { $in: [1,2] } }

Not in
{ "identifier": { $nin: [1,2] } }

All
{ "identifier": { $all: [1] } }

More than
{ "identifier": { $gt: 1 } }

More than or equal
{ "identifier": { $gte: 1 } }

More than… less than …
{ "identifier": { $gte: 1, $lte: 2 } }