当前位置: 首页>>代码示例>>C#>>正文


C# TestPlatform.UnitTestFramework类代码示例

本文整理汇总了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>();
        }
开发者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


注:本文中的Microsoft.VisualStudio.TestPlatform.UnitTestFramework类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。