当前位置: 首页>>代码示例>>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;未经允许,请勿转载。