本文整理汇总了C#中Microsoft.VisualStudio.TestPlatform.UnitTestFramework类的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.VisualStudio.TestPlatform.UnitTestFramework类的具体用法?C# Microsoft.VisualStudio.TestPlatform.UnitTestFramework怎么用?C# Microsoft.VisualStudio.TestPlatform.UnitTestFramework使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Microsoft.VisualStudio.TestPlatform.UnitTestFramework类属于命名空间,在下文中一共展示了Microsoft.VisualStudio.TestPlatform.UnitTestFramework类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Should_fail_when_asserting_collection_with_items_is_empty
public void Should_fail_when_asserting_collection_with_items_is_empty()
{
IEnumerable<string> collection = new[] { "one", "two", "three" };
Action act = () => collection.Should().BeEmpty();
act.ShouldThrow<AssertFailedException>();
}
开发者ID:rodrigolessa,项目名称:fluentassertions,代码行数:7,代码来源:GenericCollectionAssertionOfStringSpecs.cs
示例2: Should_fail_when_asserting_collection_has_a_count_that_is_different_from_the_number_of_items
public void Should_fail_when_asserting_collection_has_a_count_that_is_different_from_the_number_of_items()
{
IEnumerable<string> collection = new[] { "one", "two", "three" };
Action act = () => collection.Should().HaveCount(4);
act.ShouldThrow<AssertFailedException>();
}
开发者ID:rodrigolessa,项目名称:fluentassertions,代码行数:7,代码来源:GenericCollectionAssertionOfStringSpecs.cs
示例3: MessageQueueThread_HandlesException
public async Task MessageQueueThread_HandlesException()
{
var exception = new Exception();
var countdown = new CountdownEvent(1);
var handler = new Action<Exception>(ex =>
{
Assert.AreSame(exception, ex);
countdown.Signal();
});
var uiThread = await CallOnDispatcherAsync(() => MessageQueueThread.Create(MessageQueueThreadSpec.DispatcherThreadSpec, handler));
var backgroundThread = MessageQueueThread.Create(MessageQueueThreadSpec.Create("background", MessageQueueThreadKind.BackgroundSingleThread), handler);
var taskPoolThread = MessageQueueThread.Create(MessageQueueThreadSpec.Create("any", MessageQueueThreadKind.BackgroundAnyThread), handler);
var queueThreads = new[]
{
uiThread,
backgroundThread,
taskPoolThread
};
countdown.AddCount(queueThreads.Length - 1);
foreach (var queueThread in queueThreads)
{
queueThread.RunOnQueue(() => { throw exception; });
}
Assert.IsTrue(countdown.Wait(5000));
}
开发者ID:chukcha-wtf,项目名称:react-native-windows,代码行数:30,代码来源:MessageQueueThreadTests.cs
示例4: AsyncStorageModule_InvalidKeyValue_Method
public void AsyncStorageModule_InvalidKeyValue_Method()
{
var module = new AsyncStorageModule();
var waitHandle = new AutoResetEvent(false);
var error = default(JObject);
var result = default(JArray);
var callback = new MockCallback(res =>
{
error = res.Length > 0 ? (JObject)res[0] : null;
result = res.Length > 1 ? (JArray)res[1] : null;
waitHandle.Set();
});
var array = new[]
{
new[] { "5", "5", "5" },
};
module.clear(callback);
Assert.IsTrue(waitHandle.WaitOne());
Assert.IsNull(error);
Assert.IsNull(result);
module.multiSet(array, callback);
Assert.IsTrue(waitHandle.WaitOne());
Assert.AreEqual(error["message"], "Invalid Value");
Assert.IsNull(result);
}
开发者ID:chukcha-wtf,项目名称:react-native-windows,代码行数:29,代码来源:AsyncStorageModuleTests.cs
示例5: MessageQueueThread_IsOnThread
public async Task MessageQueueThread_IsOnThread()
{
var thrown = 0;
var uiThread = await CallOnDispatcherAsync(() => MessageQueueThread.Create(MessageQueueThreadSpec.DispatcherThreadSpec, ex => thrown++));
var backgroundThread = MessageQueueThread.Create(MessageQueueThreadSpec.Create("background", MessageQueueThreadKind.BackgroundSingleThread), ex => thrown++);
var taskPoolThread = MessageQueueThread.Create(MessageQueueThreadSpec.Create("any", MessageQueueThreadKind.BackgroundAnyThread), ex => thrown++);
var queueThreads = new[]
{
uiThread,
backgroundThread,
taskPoolThread
};
var countdown = new CountdownEvent(queueThreads.Length);
foreach (var queueThread in queueThreads)
{
queueThread.RunOnQueue(() =>
{
Assert.IsTrue(queueThread.IsOnThread());
countdown.Signal();
});
}
Assert.IsTrue(countdown.Wait(5000));
Assert.AreEqual(0, thrown);
}
开发者ID:chukcha-wtf,项目名称:react-native-windows,代码行数:27,代码来源:MessageQueueThreadTests.cs
示例6: Icon
public async Task Icon ()
{
var size = new Size (64);
var canvas = Platforms.Current.CreateImageCanvas (size, scale: 2);
canvas.SaveState ();
canvas.Scale (size);
canvas.Translate (1 / 8.0, 0);
var p = new Path ();
p.MoveTo (0, 1);
p.LineTo (0, 0);
p.LineTo (0.5, 1);
p.LineTo (0.5, 0);
var colors = new [] {
"#DCDCDD",
"#C5C3C6",
"#46494C",
"#4C5C68",
"#68A5E2",
};
foreach (var c in colors) {
p.Pen = new Pen (c, 1 / 4.0);
p.Draw (canvas);
canvas.Translate (1 / 16.0, 0);
}
await SaveImage (canvas, "Icon.png");
}
开发者ID:michaelstonis,项目名称:NGraphics,代码行数:29,代码来源:ReadmeTests.cs
示例7: Should_fail_with_descriptive_message_when_asserting_collection_with_items_is_empty
public void Should_fail_with_descriptive_message_when_asserting_collection_with_items_is_empty()
{
IEnumerable<string> collection = new[] { "one", "two", "three" };
var assertions = collection.Should();
assertions.Invoking(x => x.BeEmpty("because we want to test the failure {0}", "message"))
.ShouldThrow<AssertFailedException>()
.WithMessage("Expected collection to be empty because we want to test the failure message, but found 3.");
}
开发者ID:rodrigolessa,项目名称:fluentassertions,代码行数:8,代码来源:GenericCollectionAssertionOfStringSpecs.cs
示例8: UtmeEncoder_Compress_No_Missing_Values_Correctly
public void UtmeEncoder_Compress_No_Missing_Values_Correctly()
{
var original = new[] { "a", "b", "c", "d", "e" };
var compressed = UtmeEncoder.Compress(original);
CollectionAssert.AreEqual(original, compressed);
}
开发者ID:bayramucuncu,项目名称:CSharpAnalytics,代码行数:8,代码来源:UtmeEncoderTests.cs
示例9: UtmeDecoder_Decompress_Does_Nothing_When_No_Missing_Values
public void UtmeDecoder_Decompress_Does_Nothing_When_No_Missing_Values()
{
var original = new[] { "a", "b", "c", "d", "e" };
var compressed = UtmeDecoder.Decompress(original);
CollectionAssert.AreEqual(original, compressed);
}
开发者ID:bayramucuncu,项目名称:CSharpAnalytics,代码行数:8,代码来源:UtmeDecoderTests.cs
示例10: UrchinActivityTracker_GetParameter_For_CampaignActivity_Returns_Correct_Keys_When_Not_IsNewVisit
public void UrchinActivityTracker_GetParameter_For_CampaignActivity_Returns_Correct_Keys_When_Not_IsNewVisit()
{
var activity = new CampaignActivity("source");
var results = UrchinActivityTracker.GetParameters(activity).ToDictionary(k => k.Key, v => v);
var expectedKeys = new[] { "utmcsr", "utmcr" };
CollectionAssert.AreEquivalent(expectedKeys, results.Keys);
}
开发者ID:sroney,项目名称:CSharpAnalytics,代码行数:9,代码来源:UrchinActivityTrackerTests.cs
示例11: SetUp
public void SetUp()
{
db = new TestDb();
db.CreateTable<Product>();
var prods = new[] {
new Product { Name = "Foo" },
new Product { Name = "Bar" },
new Product { Name = "Foobar" },
};
db.InsertAll(prods);
}
开发者ID:Banane9,项目名称:sqlite-net,代码行数:13,代码来源:StringQueryTest.cs
示例12: AsyncStorageModule_GetAllKeys_SpecialCharacters
public void AsyncStorageModule_GetAllKeys_SpecialCharacters()
{
var module = new AsyncStorageModule();
var waitHandle = new AutoResetEvent(false);
var error = default(JObject);
var result = default(JArray);
var callback = new MockCallback(res =>
{
error = res.Length > 0 ? (JObject)res[0] : null;
result = res.Length > 1 ? (JArray)res[1] : null;
waitHandle.Set();
});
module.clear(callback);
Assert.IsTrue(waitHandle.WaitOne());
Assert.IsNull(error);
Assert.IsNull(result);
var pairs = new[]
{
new[] { "\\", "1" },
new[] { "/", "2" },
new[] { ":", "3" },
new[] { "*", "4" },
new[] { "?", "5" },
new[] { "<", "6" },
new[] { ">", "7" },
new[] { "|", "8" },
new[] { "\"", "9" },
new[] { ".", "10" },
new[] { "{", "11" },
new[] { "}", "12" },
new[] { "\\/:*?<>|\".{}", "13" },
new[] { "abc\\abc/abc:abc*abc?abc<abc>abc|abc\"abc.abc{abc}abc", "13" },
new[] { "foo:bar", "14" },
};
module.multiSet(pairs, callback);
Assert.IsTrue(waitHandle.WaitOne());
Assert.IsNull(error);
Assert.IsNull(result);
module.getAllKeys(callback);
Assert.IsTrue(waitHandle.WaitOne());
Assert.IsNull(error);
var expectedKeys = pairs.Select(arr => arr[0]).OrderBy(s => s);
var actualKeys = result.ToObject<string[]>().OrderBy(s => s);
Assert.IsTrue(expectedKeys.SequenceEqual(actualKeys));
}
开发者ID:chukcha-wtf,项目名称:react-native-windows,代码行数:50,代码来源:AsyncStorageModuleTests.cs
示例13: ReferenceMappingTest
public void ReferenceMappingTest()
{
var queue = new Queue<string[]>();
queue.Enqueue( new[]
{
"FirstName",
"LastName",
"HomeStreet",
"HomeCity",
"HomeState",
"HomeZip",
"WorkStreet",
"WorkCity",
"WorkState",
"WorkZip"
} );
var row = new[]
{
"John",
"Doe",
"1234 Home St",
"Home Town",
"Home State",
"12345",
"5678 Work Rd",
"Work City",
"Work State",
"67890"
};
queue.Enqueue( row );
queue.Enqueue( null );
var parserMock = new ParserMock( queue );
var reader = new CsvReader( parserMock );
reader.Read();
var person = reader.GetRecord<Person>();
Assert.AreEqual( "John", person.FirstName );
Assert.AreEqual( "Doe", person.LastName );
Assert.AreEqual( "1234 Home St", person.HomeAddress.Street );
Assert.AreEqual( "Home Town", person.HomeAddress.City );
Assert.AreEqual( "Home State", person.HomeAddress.State );
Assert.AreEqual( "12345", person.HomeAddress.Zip );
Assert.AreEqual( "5678 Work Rd", person.WorkAddress.Street );
Assert.AreEqual( "Work City", person.WorkAddress.City );
Assert.AreEqual( "Work State", person.WorkAddress.State );
Assert.AreEqual( "67890", person.WorkAddress.Zip );
}
开发者ID:sethwebster,项目名称:CsvHelper,代码行数:48,代码来源:ReferenceMappingAttributeTests.cs
示例14: Then_it_should_ignore_small_differences_without_the_need_of_local_options
public void Then_it_should_ignore_small_differences_without_the_need_of_local_options()
{
var actual = new
{
Value = (1D/3D)
};
var expected = new
{
Value = 0.33D
};
Action act = () => actual.ShouldBeEquivalentTo(expected);
act.ShouldNotThrow();
}
开发者ID:9swampy,项目名称:fluentassertions,代码行数:16,代码来源:AssertionOptionSpecs.cs
示例15: Should_fail_when_asserting_collection_is_not_subset_of_a_superset_collection
public void Should_fail_when_asserting_collection_is_not_subset_of_a_superset_collection()
{
//-----------------------------------------------------------------------------------------------------------
// Arrange
//-----------------------------------------------------------------------------------------------------------
IEnumerable<string> subject = new [] { "one", "two" };
IEnumerable<string> otherSet = new [] { "one", "two", "three" };
//-----------------------------------------------------------------------------------------------------------
// Act
//-----------------------------------------------------------------------------------------------------------
Action act = () => subject.Should().NotBeSubsetOf(otherSet, "because I'm {0}", "mistaken");
//-----------------------------------------------------------------------------------------------------------
// Assert
//-----------------------------------------------------------------------------------------------------------
act.ShouldThrow<AssertFailedException>().WithMessage(
"Did not expect collection {\"one\", \"two\"} to be a subset of {\"one\", \"two\", \"three\"} because I'm mistaken.");
}
开发者ID:rodrigolessa,项目名称:fluentassertions,代码行数:19,代码来源:GenericCollectionAssertionOfStringSpecs.cs
示例16: HSL
public async Task HSL()
{
// http://en.wikipedia.org/wiki/HSL_and_HSV#Examples
var tests = new[] {
Tuple.Create (new Color (1.000, 1.000, 1.000), Color.FromHSL ( 0.0/360.0, 0.000, 1.000)),
Tuple.Create (new Color (0.500, 0.500, 0.500), Color.FromHSL ( 0.0/360.0, 0.000, 0.500)),
Tuple.Create (new Color (0.000, 0.000, 0.000), Color.FromHSL ( 0.0/360.0, 0.000, 0.000)),
Tuple.Create (new Color (1.000, 0.000, 0.000), Color.FromHSL ( 0.0/360.0, 1.000, 0.500)),
Tuple.Create (new Color (0.750, 0.750, 0.000), Color.FromHSL ( 60.0/360.0, 1.000, 0.375)),
Tuple.Create (new Color (0.000, 0.500, 0.000), Color.FromHSL (120.0/360.0, 1.000, 0.250)),
Tuple.Create (new Color (0.500, 1.000, 1.000), Color.FromHSL (180.0/360.0, 1.000, 0.750)),
Tuple.Create (new Color (0.500, 0.500, 1.000), Color.FromHSL (240.0/360.0, 1.000, 0.750)),
Tuple.Create (new Color (0.750, 0.250, 0.750), Color.FromHSL (300.0/360.0, 0.500, 0.500)),
Tuple.Create (new Color (0.628, 0.643, 0.142), Color.FromHSL ( 61.8/360.0, 0.638, 0.393)),
Tuple.Create (new Color (0.255, 0.104, 0.918), Color.FromHSL (251.1/360.0, 0.832, 0.511)),
Tuple.Create (new Color (0.116, 0.675, 0.255), Color.FromHSL (134.9/360.0, 0.707, 0.396)),
Tuple.Create (new Color (0.941, 0.785, 0.053), Color.FromHSL ( 49.5/360.0, 0.893, 0.497)),
Tuple.Create (new Color (0.704, 0.187, 0.897), Color.FromHSL (283.7/360.0, 0.775, 0.542)),
Tuple.Create (new Color (0.931, 0.463, 0.316), Color.FromHSL ( 14.3/360.0, 0.817, 0.624)),
Tuple.Create (new Color (0.998, 0.974, 0.532), Color.FromHSL ( 56.9/360.0, 0.991, 0.765)),
Tuple.Create (new Color (0.099, 0.795, 0.591), Color.FromHSL (162.4/360.0, 0.779, 0.447)),
Tuple.Create (new Color (0.211, 0.149, 0.597), Color.FromHSL (248.3/360.0, 0.601, 0.373)),
Tuple.Create (new Color (0.495, 0.493, 0.721), Color.FromHSL (240.5/360.0, 0.290, 0.607)),
};
var s = 32;
var canvas = Platforms.Current.CreateImageCanvas(new Size(s * tests.Length, s));
foreach (var t in tests)
{
var rect = new Rect(0, 0, s, s);
canvas.FillRectangle(rect, t.Item2);
canvas.Translate(s, 0);
AssertInRange(t.Item2.R, t.Item1.R - 1, t.Item1.R + 1);
AssertInRange(t.Item2.G, t.Item1.G - 1, t.Item1.G + 1);
AssertInRange(t.Item2.B, t.Item1.B - 1, t.Item1.B + 1);
}
await SaveImage(canvas, "Color.HSL.png");
}
开发者ID:JoshuaNovak919,项目名称:NGraphics,代码行数:40,代码来源:ColorTests.cs
示例17: When_rendering_time_spans_to_string_it_should_only_include_the_nonzero_parts
public void When_rendering_time_spans_to_string_it_should_only_include_the_nonzero_parts()
{
//-----------------------------------------------------------------------------------------------------------
// Arrange
//-----------------------------------------------------------------------------------------------------------
var testCases = new[]
{
new { Input = TimeSpan.FromDays(2), Output = "2d" },
new { Input = new TimeSpan(0, 3, 20, 10, 58), Output = "3h, 20m and 10.058s" },
new { Input = new TimeSpan(2, 0, 0, 12, 0), Output = "2d and 12s" },
new { Input = TimeSpan.FromSeconds(90), Output = "1m and 30s" },
new { Input = TimeSpan.FromMilliseconds(10), Output = "0.010s" }
};
//-----------------------------------------------------------------------------------------------------------
// Act
//-----------------------------------------------------------------------------------------------------------
foreach (var testCase in testCases)
{
When_rendering_a_time_span_it_should_include_the_non_zero_parts_of(testCase.Input, testCase.Output);
}
}
开发者ID:rodolfograve,项目名称:fluentassertions,代码行数:22,代码来源:TimeSpanFormatterSpecs.cs
示例18: AsyncStorageModule_testGetAllKeys
public void AsyncStorageModule_testGetAllKeys()
{
var mStorage = new AsyncStorageModule();
var waitHandle = new AutoResetEvent(false);
var error = default(JObject);
var result = default(JArray);
var callback = new MockCallback(res =>
{
error = res.Length > 0 ? (JObject)res[0] : null;
result = res.Length > 1 ? (JArray)res[1] : null;
waitHandle.Set();
});
mStorage.clear(callback);
Assert.IsTrue(waitHandle.WaitOne());
Assert.IsNull(error);
Assert.IsNull(result);
var keys = new[] { "foo", "foo2" };
var values = new[] { "bar", "bar2" };
var keyValues = new[]
{
new[]
{
keys[0],
values[0],
},
new[]
{
keys[1],
values[1],
},
};
mStorage.multiSet(keyValues, callback);
Assert.IsTrue(waitHandle.WaitOne());
Assert.IsNull(error);
Assert.IsNull(result);
mStorage.getAllKeys(callback);
Assert.IsTrue(waitHandle.WaitOne());
Assert.IsNull(error);
var storedKeys = new JArray
{
keys[0],
keys[1],
};
var set = new SortedSet<string>();
IEnumerable<string> enumerator = storedKeys.Values<string>();
foreach (var value in enumerator)
{
set.Add(value);
}
set.SymmetricExceptWith(result.Values<string>());
Assert.AreEqual(set.Count, 0);
mStorage.multiRemove(keys, callback);
Assert.IsTrue(waitHandle.WaitOne());
Assert.IsNull(error);
Assert.IsNull(result);
mStorage.getAllKeys(callback);
Assert.IsTrue(waitHandle.WaitOne());
Assert.IsNull(error);
Assert.AreEqual(result.Count, 0);
}
开发者ID:chukcha-wtf,项目名称:react-native-windows,代码行数:72,代码来源:AsyncStorageModuleTests.cs
示例19: AsyncStorageModule_testMultiMerge
public void AsyncStorageModule_testMultiMerge()
{
var mStorage = new AsyncStorageModule();
var waitHandle = new AutoResetEvent(false);
var error = default(JObject);
var result = default(JArray);
var callback = new MockCallback(res =>
{
error = res.Length > 0 ? (JObject)res[0] : null;
result = res.Length > 1 ? (JArray)res[1] : null;
waitHandle.Set();
});
mStorage.clear(callback);
Assert.IsTrue(waitHandle.WaitOne());
Assert.IsNull(error);
Assert.IsNull(result);
var mergeKey = "mergeTest";
var value = new JObject();
value.Add("foo1", "bar1");
value.Add("foo2", new JArray
{
"val1",
"val2",
3,
});
value.Add("foo3", 1001);
var val = new JObject();
val.Add("key1", "randomValueThatWillNeverBeUsed");
value.Add("foo4", val);
var array = new[]
{
new[]
{
mergeKey,
value.ToString(Formatting.None)
},
};
mStorage.multiSet(array, callback);
Assert.IsTrue(waitHandle.WaitOne());
Assert.IsNull(error);
Assert.IsNull(result);
var str = new string[] { mergeKey };
mStorage.multiGet(str, callback);
Assert.IsTrue(waitHandle.WaitOne());
Assert.IsNull(error);
var expected = JToken.FromObject(array);
Assert.IsTrue(JToken.DeepEquals(result, expected));
value.Remove("foo1");
value.Remove("foo2");
value.Remove("foo3");
value.Remove("foo4");
value.Add("foo1", 1001);
var val2 = new JObject();
val2.Add("key1", "val1");
value.Add("foo2", val2);
value.Add("foo3", "bar1");
value.Add("foo4", new JArray
{
"val1",
"val2",
3
});
var newValue = new JObject();
var val3 = new JObject();
val3.Add("key2", "val2");
newValue.Add("foo2", val3);
var newValue2 = new JObject();
var val4 = new JObject();
val4.Add("key1", "val3");
newValue2.Add("foo2", val4);
var array2 = new[]
{
new[]
{
mergeKey,
value.ToString(Formatting.None)
},
};
mStorage.multiMerge(array2, callback);
Assert.IsTrue(waitHandle.WaitOne());
//.........这里部分代码省略.........
开发者ID:chukcha-wtf,项目名称:react-native-windows,代码行数:101,代码来源:AsyncStorageModuleTests.cs
示例20: AsyncStorageModule_multiMerge_NullValue
public void AsyncStorageModule_multiMerge_NullValue()
{
var module = new AsyncStorageModule();
var waitHandle = new AutoResetEvent(false);
var error = default(JObject);
var result = default(JArray);
var callback = new MockCallback(res =>
{
error = res.Length > 0 ? (JObject)res[0] : null;
result = res.Length > 1 ? (JArray)res[1] : null;
waitHandle.Set();
});
module.clear(callback);
Assert.IsTrue(waitHandle.WaitOne());
Assert.IsNull(error);
Assert.IsNull(result);
var array = new[]
{
new[] { "testKey", string.Join("", Enumerable.Repeat("a", 1024 * 16)) },
};
module.multiMerge(array, callback);
Assert.IsTrue(waitHandle.WaitOne());
Assert.IsNull(error);
Assert.IsNull(result);
}
开发者ID:chukcha-wtf,项目名称:react-native-windows,代码行数:29,代码来源:AsyncStorageModuleTests.cs
注:本文中的Microsoft.VisualStudio.TestPlatform.UnitTestFramework类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论