本文整理汇总了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类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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>();
}
示例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>();
}
示例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));
}
示例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);
}
示例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);
}
示例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");
}
示例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.");
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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 );
}
示例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();
}
示例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.");
}