本文整理汇总了C#中Get类的典型用法代码示例。如果您正苦于以下问题:C# Get类的具体用法?C# Get怎么用?C# Get使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Get类属于命名空间,在下文中一共展示了Get类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_DecrementOperation
public void Test_DecrementOperation()
{
const string key = "Test_DecrementOperation";
//delete key if exists
var delete = new Delete(key, GetVBucket(), Transcoder, OperationLifespanTimeout);
var result = IOService.Execute(delete);
Console.WriteLine("Deleting key {0}: {1}", key, result.Success);
//increment the key
var operation = new Increment(key, 1, 1, 0, GetVBucket(), Transcoder, OperationLifespanTimeout);
var result1 = IOService.Execute(operation);
Assert.IsTrue(result1.Success);
Assert.AreEqual(result1.Value, 1);
//key should be 1
var get = new Get<string>(key, GetVBucket(), Transcoder, OperationLifespanTimeout);
var result3 = IOService.Execute(get);
Assert.AreEqual(result1.Value.ToString(CultureInfo.InvariantCulture), result3.Value);
//decrement the key
var decrement = new Decrement(key, 1, 1, 0, GetVBucket(), Transcoder, OperationLifespanTimeout);
var result2 = IOService.Execute(decrement);
Assert.IsTrue(result2.Success);
Assert.AreEqual(result2.Value, 0);
//key should be 0
get = new Get<string>(key, GetVBucket(), Transcoder, OperationLifespanTimeout);
result3 = IOService.Execute(get);
Assert.AreEqual(0.ToString(CultureInfo.InvariantCulture), result3.Value);
}
示例2: When_Document_Exists_Replace_Succeeds
public void When_Document_Exists_Replace_Succeeds()
{
const string key = "Replace.When_Document_Exists_Replace_Succeeds";
//delete the value if it exists
var delete = new Delete(key, GetVBucket(), Transcoder, OperationLifespanTimeout);
var result = IOService.Execute(delete);
Console.WriteLine(result.Message);
//add the new doc
var add = new Add<dynamic>(key, new { foo = "foo" }, GetVBucket(), Transcoder, OperationLifespanTimeout);
var result1 = IOService.Execute(add);
Assert.IsTrue(result1.Success);
//replace it the old doc with a new one
var replace = new Replace<dynamic>(key, new { bar = "bar" }, GetVBucket(), Transcoder, OperationLifespanTimeout);
var result2 = IOService.Execute(replace);
Assert.IsTrue(result2.Success);
//check that doc has been updated
var get = new Get<dynamic>(key, GetVBucket(), Transcoder, OperationLifespanTimeout);
var result3 = IOService.Execute(get);
Assert.IsTrue(result3.Success);
Assert.AreEqual(result3.Value.bar.Value, "bar");
}
示例3: Test_Timed_Execution
public void Test_Timed_Execution()
{
var converter = new DefaultConverter();
var transcoder = new DefaultTranscoder(converter);
var vbucket = GetVBucket();
int n = 1000; //set to a higher # if needed
using (new OperationTimer())
{
var key = string.Format("key{0}", 111);
for (var i = 0; i < n; i++)
{
var set = new Set<int?>(key, 111, vbucket, transcoder, OperationLifespanTimeout);
var get = new Get<int?>(key, vbucket, transcoder, OperationLifespanTimeout);
var result = IOService.Execute(set);
Assert.IsTrue(result.Success);
var result1 = IOService.Execute(get);
Assert.IsTrue(result1.Success);
Assert.AreEqual(111, result1.Value);
}
}
}
示例4: When_Key_Exists_Append_Succeeds
public void When_Key_Exists_Append_Succeeds()
{
const string key = "Hello";
const string expected = "Hello!";
//clean up old keys
var deleteOperation = new Delete(key, GetVBucket(), Converter, Serializer);
IOStrategy.Execute(deleteOperation);
deleteOperation = new Delete(key + "!", GetVBucket(), Converter, Serializer);
IOStrategy.Execute(deleteOperation);
//create the key
var set = new Set<string>(key, "Hello", GetVBucket(), Converter);
var addResult = IOStrategy.Execute(set);
Assert.IsTrue(addResult.Success);
var append = new Append<string>(key, "!", Serializer, GetVBucket(), Converter);
var result = IOStrategy.Execute(append);
Assert.IsTrue(result.Success);
Assert.AreEqual(string.Empty, result.Value);
var get = new Get<string>(key, GetVBucket(), Converter, Serializer);
var getResult = IOStrategy.Execute(get);
Assert.AreEqual(expected, getResult.Value);
}
示例5: Test_OperationResult_Returns_Defaults
public void Test_OperationResult_Returns_Defaults()
{
var op = new Get<string>("Key", GetVBucket(), Transcoder, OperationLifespanTimeout);
var result = op.GetResultWithValue();
Assert.IsNull(result.Value);
Assert.IsEmpty(result.Message);
}
示例6: Test_Integrated_With_Common_Log
public void Test_Integrated_With_Common_Log()
{
var op = new Get<string>("key", null, _transcoder, OperationLifespan);
using (new OperationTimer(TimingLevel.One, op, new CommonLogStore(Log)))
{
Thread.Sleep(1000);
}
}
示例7: Test_OperationResult_Returns_Defaults
public void Test_OperationResult_Returns_Defaults()
{
var op = new Get<string>("Key", GetVBucket(), new AutoByteConverter(),
new TypeSerializer(new AutoByteConverter()));
var result = op.GetResult();
Assert.IsNull(result.Value);
Assert.IsEmpty(result.Message);
}
示例8: Because
protected override void Because()
{
SourceControl.ClearDownLoadedPackages();
get = new Get(fileSystemProvider);
destinationPath = get.From(sourceControl)
.ExportTo(packageTree)
.RetrievePackage("horn").WorkingDirectory.FullName;
}
示例9: Get
public async Task<IActionResult> Get(Get.Query query)
{
var results = await _mediator.SendAsync(query);
if (results == null)
{
return NotFound();
}
return Ok(results);
}
示例10: When_TimingLevel_Is_None_Log_Message_Contains_No_Level
public void When_TimingLevel_Is_None_Log_Message_Contains_No_Level()
{
var log = new FakeLog("mylogger", LogLevel.Info, true, true, true, "yyyy/MM/dd HH:mm:ss:fff");
var op = new Get<string>("key", null, _transcoder, OperationLifespan);
using (new OperationTimer(TimingLevel.None, op, new CommonLogStore(log)))
{
Thread.Sleep(100);
}
var loggedString = log.LogStore.ToString();
Assert.IsFalse(loggedString.Contains("Level"));
}
示例11: Test_ReadExtras_When_Type_Is_Binary
public void Test_ReadExtras_When_Type_Is_Binary()
{
var key = "binkey";
var expected = new byte[]
{
0x81, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x04, 0x0e, 0xa2, 0x9d, 0x32, 0xdb, 0xb5, 0x03, 0x00, 0x00, 0x02, 0x01, 0x02, 0x03, 0x04
};
var get = new Get<byte[]>(key, GetVBucket(), Transcoder, OperationLifespanTimeout);
get.ReadExtras(expected);
Assert.AreEqual(DataFormat.Binary, get.Format);
}
示例12: When_Type_Is_String_DateFormat_Is_String
public void When_Type_Is_String_DateFormat_Is_String()
{
const string key = "OperationBaseTests.When_Type_Is_String_DateFormat_Is_String";
var set = new Set<string>(key, "somestring", GetVBucket(), Transcoder, OperationLifespanTimeout);
var result = IOService.Execute(set);
Assert.IsTrue(result.Success);
Assert.AreEqual(set.Format, DataFormat.String);
var get = new Get<string>(key, GetVBucket(), Transcoder, OperationLifespanTimeout);
var getResult = IOService.Execute(get);
Assert.IsTrue(getResult.Success);
Assert.AreEqual(DataFormat.String, get.Format);
Assert.AreEqual(Compression.None, get.Compression);
}
示例13: When_Type_Is_Int_DateFormat_Is_Json
public void When_Type_Is_Int_DateFormat_Is_Json()
{
const string key = "OperationBaseTests.When_Type_Is_Int_DateFormat_Is_Json";
var set = new Set<int?>(key, 100, GetVBucket(), Transcoder, OperationLifespanTimeout);
var result = IOStrategy.Execute(set);
Assert.IsTrue(result.Success);
Assert.AreEqual(set.Format, DataFormat.Json);
var get = new Get<int>(key, GetVBucket(), Transcoder, OperationLifespanTimeout);
var getResult = IOStrategy.Execute(get);
Assert.IsTrue(getResult.Success);
Assert.AreEqual(DataFormat.Json, get.Format);
Assert.AreEqual(Compression.None, get.Compression);
}
示例14: actionGenerator
/// Action generator
/// @todo Implement lookup table or a design pattern for easier/automatic function generation
public void actionGenerator( List<GameObject[]> combinations )
{
iThinkAction action;
//printEverything(combinations);
foreach ( GameObject[] matrix in combinations )
{
switch ( schemaElements[0] )
{
case "get" :
action = new Get( "Get", matrix[0], matrix[1] );
tempActionList.Add(action);
break;
case "buy" :
action = new Buy( "Buy", matrix[0], matrix[1], matrix[2] );
tempActionList.Add(action);
break;
case "store" :
action = new Store( "Store", matrix[0], matrix[1]);
tempActionList.Add(action);
break;
case "hunt" :
action = new Hunt( "Hunt", matrix[0], matrix[1], matrix[2], matrix[3]);
tempActionList.Add(action);
break;
case "make" :
action = new Make( "Make", matrix[0], matrix[1], matrix[2]);
tempActionList.Add(action);
break;
case "harvest" :
action = new Harvest( "Harvest", matrix[0], matrix[1], matrix[2]);
tempActionList.Add(action);
break;
case "produce" :
action = new Produce( "Produce", matrix[0], matrix[1], matrix[2]);
tempActionList.Add(action);
break;
case "craftSpell" :
action = new CraftSpell ("CraftSpell", matrix[0], matrix[1], matrix[2]);
tempActionList.Add(action);
break;
case "craftSimpleWeapon" :
action = new CraftSimpleWeapon("CraftSimpleWeapon", matrix[0], matrix[1], matrix[2]);
tempActionList.Add(action);
break;
}
}
}
示例15: When_Key_Exists_Get_Returns_Value
public void When_Key_Exists_Get_Returns_Value()
{
var key = "When_Key_Exists_Get_Returns_Value";
//delete the value if it exists
var delete = new Delete(key, GetVBucket(), Transcoder, OperationLifespanTimeout);
IOStrategy.Execute(delete);
//Add the key
var add = new Add<dynamic>(key, new { foo = "foo" }, GetVBucket(), Transcoder, OperationLifespanTimeout);
Assert.IsTrue(IOStrategy.Execute(add).Success);
var get = new Get<dynamic>(key, GetVBucket(), Transcoder, OperationLifespanTimeout);
var result = IOStrategy.Execute(get);
Assert.IsTrue(result.Success);
var expected = new {foo = "foo"};
Assert.AreEqual(result.Value.foo.Value, expected.foo);
}