當前位置: 首頁>>代碼示例>>C#>>正文


C# List.Should方法代碼示例

本文整理匯總了C#中NUnit.Framework.List.Should方法的典型用法代碼示例。如果您正苦於以下問題:C# List.Should方法的具體用法?C# List.Should怎麽用?C# List.Should使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NUnit.Framework.List的用法示例。


在下文中一共展示了List.Should方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OriginalThing_DoesThing

 public void OriginalThing_DoesThing()
 {
     var strings = new List<string>();
     new OriginalThing().DoesThing(strings);
     strings.Should().NotBeEmpty();
     strings.Should().HaveCount(1);
     strings.ElementAt(0).Should().Contain("Original");
 }
開發者ID:pauldambra,項目名稱:methodHiding,代碼行數:8,代碼來源:WithoutMoq.cs

示例2: ProvidedOriginalThing_DoesThing

 public void ProvidedOriginalThing_DoesThing()
 {
     var strings = new List<string>();
     var thingServer = new Mock<IThingFactory>();
     thingServer.Setup(ts => ts.GetThing()).Returns(new OriginalThing());
     thingServer.Object.GetThing().DoesThing(strings);
     strings.Should().NotBeEmpty();
     strings.Should().HaveCount(1);
     strings.ElementAt(0).Should().Contain("Original");
 }
開發者ID:pauldambra,項目名稱:methodHiding,代碼行數:10,代碼來源:WithMoq.cs

示例3: given_guarantor_with_no_first_name_when_validating_should_return_result_with_resource_value

		public void given_guarantor_with_no_first_name_when_validating_should_return_result_with_resource_value()
		{
			var guarantor = new GuarantorWithGlobalResources { LastName = "Meinershagen" };

			var results = new List<ValidationResult>();
			guarantor.TryValidate(results);

			results.Should().Contain(r => r.ErrorMessage == Resources.GuarantorFirstNameRequired);
			results.Should().NotContain(r => r.ErrorMessage == Resources.ResourceManager.GetString("GuarantorLastNameRequired"));
		}
開發者ID:toddmeinershagen,項目名稱:Demo.Domain,代碼行數:10,代碼來源:GuarantorWithGlobalResourcesTests.cs

示例4: TestAddToCollection

        public void TestAddToCollection()
        {
            var collection = new List<string> {"a", "b", "c"};
            var command = new AddToCollection<string>(collection, "d");

            command.Execute();
            collection.Should().Contain("d");

            command.Undo();
            collection.Should().NotContain("d");
        }
開發者ID:nano-byte,項目名稱:common,代碼行數:11,代碼來源:CollectionTest.cs

示例5: given_valid_person_when_trying_to_validate_should_return_true_and_empty_results

        public void given_valid_person_when_trying_to_validate_should_return_true_and_empty_results()
        {
			var results = new List<ValidationResult>();
            var complexPerson = new PersonWithBuiltInValidation{FirstName = "Todd", LastName = "Meinershagen", EmailAddress = "[email protected]"};
            complexPerson.TryValidate(results).Should().BeTrue();
			results.Should().BeEmpty();

            var simplePerson = new PersonWithCustomValidation { FirstName = "Todd", LastName = "Meinershagen", EmailAddress = "[email protected]" };
            simplePerson.TryValidate(results).Should().BeTrue();
			results.Should().BeEmpty();
        }
開發者ID:toddmeinershagen,項目名稱:Demo.Domain,代碼行數:11,代碼來源:PersonTests.cs

示例6: TestExecute

        public void TestExecute()
        {
            var list = new List<string> {"a", "b", "c"};
            var command = new ReplaceInList<string>(list, "b", "x");

            command.Execute();
            list.Should().Equal("a", "x", "c");

            command.Undo();
            list.Should().Equal("a", "b", "c");
        }
開發者ID:nano-byte,項目名稱:common,代碼行數:11,代碼來源:ReplaceInListTest.cs

示例7: TestAddIfNew

        public void TestAddIfNew()
        {
            var list = new List<string> {"a", "b", "c"};

            list.AddIfNew("b").Should().BeFalse();
            list.Should().Equal("a", "b", "c");

            list.AddIfNew("d").Should().BeTrue();
            list.Should().Equal("a", "b", "c", "d");

            list.Invoking(x => x.RemoveLast(-1)).ShouldThrow<ArgumentOutOfRangeException>();
        }
開發者ID:nano-byte,項目名稱:common,代碼行數:12,代碼來源:CollectionExtensionsTest.cs

示例8: ProvidedOriginalThing_DoesThing

        public void ProvidedOriginalThing_DoesThing()
        {
            var strings = new List<string>();
            var factory = new OriginalThingFactory();
            var originalThing = factory.GetThing();

            originalThing.Should().BeOfType<OriginalThing>();

            originalThing.DoesThing(strings);
            strings.Should().NotBeEmpty();
            strings.Should().HaveCount(1);
            strings.ElementAt(0).Should().Contain("Original");
        }
開發者ID:pauldambra,項目名稱:methodHiding,代碼行數:13,代碼來源:WithoutMoq.cs

示例9: ProvidedFakeThing_DoesThing

        public void ProvidedFakeThing_DoesThing()
        {
            var strings = new List<string>();
            var factory = new FakeThingFactory();
            var fakeThing = factory.GetThing();

            fakeThing.Should().BeOfType<FakeThing>();

            fakeThing.DoesThing(strings);

            strings.Should().NotBeEmpty();
            strings.Should().HaveCount(1);
            strings.ElementAt(0).Should().Contain("Fake");
        }
開發者ID:pauldambra,項目名稱:methodHiding,代碼行數:14,代碼來源:WithoutMoq.cs

示例10: Activity_is_notified_when_a_command_is_scheduled

        public async Task Activity_is_notified_when_a_command_is_scheduled()
        {
            // arrange
            var order = CommandSchedulingTests_EventSourced.CreateOrder();

            var activity = new List<ICommandSchedulerActivity>();

            using (Configuration.Current
                                .Container
                                .Resolve<SqlCommandScheduler>()
                                .Activity
                                .Subscribe(activity.Add))
            {
                // act
                order.Apply(new ShipOn(Clock.Now().Add(TimeSpan.FromDays(2))));
                await orderRepository.Save(order);

                //assert 
                activity.Should()
                        .ContainSingle(a => a.ScheduledCommand
                                             .IfTypeIs<IScheduledCommand<Order>>()
                                             .Then(c => c.TargetId == order.Id.ToString())
                                             .ElseDefault() &&
                                            a is CommandScheduled);
            }
        }
開發者ID:commonsensesoftware,項目名稱:Its.Cqrs,代碼行數:26,代碼來源:SqlCommandSchedulerTests_Legacy.cs

示例11: given_trip_with_date_not_after_today_when_checking_is_valid_should_be_false

        public void given_trip_with_date_not_after_today_when_checking_is_valid_should_be_false()
        {
	        var results = new List<ValidationResult>();
            var trip = new Trip { Date = 23.November(1972) };
            trip.TryValidate(results).Should().BeFalse();
	        results.Should().NotBeEmpty();
        }
開發者ID:toddmeinershagen,項目名稱:Demo.Domain,代碼行數:7,代碼來源:TripTests.cs

示例12: ArgumentStaticPassedByReference

 public void ArgumentStaticPassedByReference()
 {
     var assignTo = new List<string>();
     var expectedList = new[] { "newItemForStatic" };
     typeof(TestClass).Invoke("ProtectedStaticMethod", NoTypeArguments, assignTo);
     assignTo.Should().BeEquivalentTo(expectedList).And.HaveSameCount(expectedList);
 }
開發者ID:garrypas,項目名稱:EasyReflection,代碼行數:7,代碼來源:TypeExtensionsTests.cs

示例13: ArgumentInstancePassedByReference

 public void ArgumentInstancePassedByReference()
 {
     var assignTo = new List<string>();
     var expectedList = new[] { "newItem" };
     new TestClass().Call("ProtectedMethod", null, assignTo);
     assignTo.Should().BeEquivalentTo(expectedList).And.HaveSameCount(expectedList);
 }
開發者ID:garrypas,項目名稱:EasyReflection,代碼行數:7,代碼來源:ObjectExtensionsTests.cs

示例14: TestMatch1

 public void TestMatch1()
 {
     var filter = new SubstringFilter("Foobar", true);
     var matches = new List<LogLineMatch>();
     new Action(() => filter.Match(new LogLine(0, 0, null, LevelFlags.All), matches)).ShouldNotThrow();
     matches.Should().BeEmpty();
 }
開發者ID:Kittyfisto,項目名稱:Tailviewer,代碼行數:7,代碼來源:SubstringFilterTest.cs

示例15: when_attempting_to_restore_an_externally_tracked_list

        public void when_attempting_to_restore_an_externally_tracked_list()
        {
            var mementor = new Mementor(isEnabled: true);

            var collection = new List<string>();
            var item = "hey!";
            mementor.ElementAdd(collection, item);//this is an extension method? Oh I see, he didnt want to put custom-list logic on Mementor. Nice.
            //it also doesnt actually add the element to the list:
            collection.Add(item);
            collection.Should().HaveCount(1);

            mementor.Undo();
            //hmm, so it expects the caller to do the Add but it will handle the remove?

            collection.Should().BeEmpty();
        }
開發者ID:Groostav,項目名稱:VersionCommander,代碼行數:16,代碼來源:TestingBuusMementoPackage.cs


注:本文中的NUnit.Framework.List.Should方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。