public void PropertyTests() { string[] array = { "abc", "bca", "xyz", "qrs" }; string[] array2 = { "a", "ab", "abc" }; ArrayList list = new ArrayList(array); // Not available using the classic syntax // Helper syntax Assert.That(list, Has.Property("Count")); Assert.That(list, Has.No.Property("Length")); Assert.That("Hello", Has.Property("Length", 5)); Assert.That("Hello", Has.Length(5)); Assert.That("Hello", Has.Property("Length").EqualTo(5)); Assert.That("Hello", Has.Property("Length").GreaterThan(3)); Assert.That(array, Has.Property("Length", 4)); Assert.That(array, Has.Length(4)); Assert.That(array, Has.Property("Length").LessThan(10)); Assert.That(array, Has.All.Property("Length", 3)); Assert.That(array, Has.All.Length(3)); Assert.That(array, Is.All.Length(3)); Assert.That(array, Has.All.Property("Length").EqualTo(3)); Assert.That(array, Is.All.Property("Length").EqualTo(3)); Assert.That(array, Has.None.Property("Length").Not.EqualTo(3)); Assert.That(array2, Has.Some.Property("Length", 2)); Assert.That(array2, Has.Some.Length(2)); Assert.That(array2, Has.Some.Property("Length").GreaterThan(2)); Assert.That(array2, Has.No.Property("Length").GreaterThan(3)); Assert.That(array2, Is.Not.Property("Length", 4)); Assert.That(array2, Is.Not.Length(4)); Assert.That(array2, Has.No.Property("Length").GreaterThan(3)); Assert.That(List.Map(array2).Property("Length"), Is.EqualTo(new int[] { 1, 2, 3 })); Assert.That(List.Map(array2).Property("Length"), Is.EquivalentTo(new int[] { 3, 2, 1 })); Assert.That(List.Map(array2).Property("Length"), Is.SubsetOf(new int[] { 1, 2, 3, 4, 5 })); Assert.That(List.Map(array2).Property("Length"), Is.Unique); Assert.That(list, Has.Count(4)); // Inherited syntax Expect(list, Property("Count")); Expect(list, Not.Property("Nada")); Expect("Hello", Property("Length", 5)); Expect("Hello", Length(5)); Expect("Hello", Property("Length").EqualTo(5)); Expect("Hello", Property("Length").GreaterThan(0)); Expect(array, Property("Length", 4)); Expect(array, Length(4)); Expect(array, Property("Length").LessThan(10)); Expect(array, All.Property("Length", 3)); Expect(array, All.Length(3)); Expect(array, All.Property("Length").EqualTo(3)); Expect(array2, Some.Property("Length", 2)); Expect(array2, Some.Length(2)); Expect(array2, Some.Property("Length").GreaterThan(2)); Expect(array2, None.Property("Length", 4)); Expect(array2, None.Length(4)); Expect(array2, None.Property("Length").GreaterThan(3)); Expect(Map(array2).Property("Length"), EqualTo(new int[] { 1, 2, 3 })); Expect(Map(array2).Property("Length"), EquivalentTo(new int[] { 3, 2, 1 })); Expect(Map(array2).Property("Length"), SubsetOf(new int[] { 1, 2, 3, 4, 5 })); Expect(Map(array2).Property("Length"), Unique); Expect(list, Count(4)); }
public void RelativeFilePathsAreMadeAbsolute() { var result = TestBuilder.RunTestCase(typeof(TestAttachmentsTests), nameof(TestAttachmentsTests.AttachmentWithRelativePath)); Assert.That(result.TestAttachments, Has.Exactly(1).Property(nameof(TestAttachment.FilePath)).EqualTo(_tempFilePath)); }
public async Task Columns_WhenViewContainsSingleColumn_ContainsOneValueOnly() { var view = await GetViewAsync("mview_view_test_view_2").ConfigureAwait(false); Assert.That(view.Columns, Has.Exactly(1).Items); }
public void Validate_InvalidDate_Fail() { Assert.That(new ComparedToDateValidator().Validate(JObject.Parse("{ left: '2016-01-01 10:16', right: 'No Date' }"), null) , Has.Property("IsValid").EqualTo(false)); }
public ComparedToIntegerValidator() { When(Field("left", Has.Value()) & Field("right", Has.Value())) .Then("left", ComparedTo("right", t => Must.Be.LessOrEqualTo((int)t))); }
public void FilterOutNonSagaTypes() { var model = GetModel(typeof(MySaga), typeof(string), typeof(AbstractSaga)).ToList(); Assert.That(model, Has.Exactly(1).Matches <SagaMetadata>(x => x.SagaType == typeof(MySaga))); }
public void Test_MoveMultipleStackedNodesAction_ToDifferentStack([Values] TestingMode mode) { var stack0 = GraphModel.CreateStack(string.Empty, Vector2.zero); var nodeA = stack0.CreateStackedNode <Type0FakeNodeModel>("A"); var nodeB = stack0.CreateStackedNode <Type0FakeNodeModel>("B"); var nodeC = stack0.CreateStackedNode <Type0FakeNodeModel>("C"); var stack1 = GraphModel.CreateStack(string.Empty, Vector2.zero); var nodeD = stack1.CreateStackedNode <Type0FakeNodeModel>("D"); var nodeE = stack1.CreateStackedNode <Type0FakeNodeModel>("E"); var nodeF = stack1.CreateStackedNode <Type0FakeNodeModel>("F"); TestPrereqActionPostreq(mode, () => { Assert.That(stack0.NodeModels.Count(), Is.EqualTo(3)); Assert.That(nodeA, Has.IndexInStack(0, stack0)); Assert.That(nodeB, Has.IndexInStack(1, stack0)); Assert.That(nodeC, Has.IndexInStack(2, stack0)); Assert.That(stack1.NodeModels.Count(), Is.EqualTo(3)); Assert.That(nodeD, Has.IndexInStack(0, stack1)); Assert.That(nodeE, Has.IndexInStack(1, stack1)); Assert.That(nodeF, Has.IndexInStack(2, stack1)); return(new MoveStackedNodesAction(new [] { nodeA, nodeC }, stack1, 1)); }, () => { Assert.That(stack0.NodeModels.Count(), Is.EqualTo(1)); Assert.That(nodeB, Has.IndexInStack(0, stack0)); Assert.That(stack1.NodeModels.Count(), Is.EqualTo(5)); Assert.That(nodeD, Has.IndexInStack(0, stack1)); Assert.That(nodeA, Has.IndexInStack(1, stack1)); Assert.That(nodeC, Has.IndexInStack(2, stack1)); Assert.That(nodeE, Has.IndexInStack(3, stack1)); Assert.That(nodeF, Has.IndexInStack(4, stack1)); }); TestPrereqActionPostreq(mode, () => { Assert.That(stack0.NodeModels.Count(), Is.EqualTo(1)); Assert.That(nodeB, Has.IndexInStack(0, stack0)); Assert.That(stack1.NodeModels.Count(), Is.EqualTo(5)); Assert.That(nodeD, Has.IndexInStack(0, stack1)); Assert.That(nodeA, Has.IndexInStack(1, stack1)); Assert.That(nodeC, Has.IndexInStack(2, stack1)); Assert.That(nodeE, Has.IndexInStack(3, stack1)); Assert.That(nodeF, Has.IndexInStack(4, stack1)); return(new MoveStackedNodesAction(new [] { nodeF, nodeD }, stack0, 0)); }, () => { Assert.That(stack0.NodeModels.Count(), Is.EqualTo(3)); Assert.That(nodeF, Has.IndexInStack(0, stack0)); Assert.That(nodeD, Has.IndexInStack(1, stack0)); Assert.That(nodeB, Has.IndexInStack(2, stack0)); Assert.That(stack1.NodeModels.Count(), Is.EqualTo(3)); Assert.That(nodeA, Has.IndexInStack(0, stack1)); Assert.That(nodeC, Has.IndexInStack(1, stack1)); Assert.That(nodeE, Has.IndexInStack(2, stack1)); }); TestPrereqActionPostreq(mode, () => { Assert.That(stack0.NodeModels.Count(), Is.EqualTo(3)); Assert.That(nodeF, Has.IndexInStack(0, stack0)); Assert.That(nodeD, Has.IndexInStack(1, stack0)); Assert.That(nodeB, Has.IndexInStack(2, stack0)); Assert.That(stack1.NodeModels.Count(), Is.EqualTo(3)); Assert.That(nodeA, Has.IndexInStack(0, stack1)); Assert.That(nodeC, Has.IndexInStack(1, stack1)); Assert.That(nodeE, Has.IndexInStack(2, stack1)); return(new MoveStackedNodesAction(new [] { nodeF, nodeC }, stack1, 2)); }, () => { Assert.That(stack0.NodeModels.Count(), Is.EqualTo(2)); Assert.That(nodeD, Has.IndexInStack(0, stack0)); Assert.That(nodeB, Has.IndexInStack(1, stack0)); Assert.That(stack1.NodeModels.Count(), Is.EqualTo(4)); Assert.That(nodeA, Has.IndexInStack(0, stack1)); Assert.That(nodeE, Has.IndexInStack(1, stack1)); Assert.That(nodeF, Has.IndexInStack(2, stack1)); Assert.That(nodeC, Has.IndexInStack(3, stack1)); }); }
public void Should_contain_404_NotFound() { Assert.That(_swaggerResponses.Keys, Has.Member("NotFound")); }
public void Should_contain_409_Conflict() { Assert.That(_swaggerResponses.Keys, Has.Member("Conflict")); }
public void Should_contain_401_Unauthorized() { Assert.That(_swaggerResponses.Keys, Has.Member("Unauthorized")); }
public void Should_contain_403_Forbidden() { Assert.That(_swaggerResponses.Keys, Has.Member("Forbidden")); }
public void Should_contain_400_BadRequest() { Assert.That(_swaggerResponses.Keys, Has.Member("BadRequest")); }
public void Should_contain_304_NotModified() { Assert.That(_swaggerResponses.Keys, Has.Member("NotModified")); }
public void Should_contain_204_Deleted() { Assert.That(_swaggerResponses.Keys, Has.Member("Deleted")); }
/// <summary> /// Returns a new AttributeConstraint checking for the /// presence of a particular attribute on an object. /// </summary> public ResolvableConstraintExpression Attribute(Type expectedType) { return(Has.Attribute(expectedType)); }
public void Should_contain_412_PreconditionFailed() { Assert.That(_swaggerResponses.Keys, Has.Member("PreconditionFailed")); }
/// <summary> /// Returns a ConstraintExpression, which will apply /// the following constraint to all members of a collection, /// succeeding only if a specified number of them succeed. /// </summary> public static ConstraintExpression Exactly(int expectedCount) { return(Has.Exactly(expectedCount)); }
public void Should_contain_500_Error() { Assert.That(_swaggerResponses.Keys, Has.Member("Error")); }
public void Test_MoveMultipleStackedNodesAction_ToSameStack([Values] TestingMode mode) { var stack = GraphModel.CreateStack(string.Empty, Vector2.zero); var nodeA = stack.CreateStackedNode <Type0FakeNodeModel>("A"); var nodeB = stack.CreateStackedNode <Type0FakeNodeModel>("B"); var nodeC = stack.CreateStackedNode <Type0FakeNodeModel>("C"); var nodeD = stack.CreateStackedNode <Type0FakeNodeModel>("D"); TestPrereqActionPostreq(mode, () => { Assert.That(stack.NodeModels.Count(), Is.EqualTo(4)); Assert.That(nodeA, Has.IndexInStack(0, stack)); Assert.That(nodeB, Has.IndexInStack(1, stack)); Assert.That(nodeC, Has.IndexInStack(2, stack)); Assert.That(nodeD, Has.IndexInStack(3, stack)); return(new MoveStackedNodesAction(new [] { nodeA, nodeC }, stack, 2)); }, () => { Assert.That(stack.NodeModels.Count(), Is.EqualTo(4)); Assert.That(nodeB, Has.IndexInStack(0, stack)); Assert.That(nodeD, Has.IndexInStack(1, stack)); Assert.That(nodeA, Has.IndexInStack(2, stack)); Assert.That(nodeC, Has.IndexInStack(3, stack)); }); TestPrereqActionPostreq(mode, () => { Assert.That(stack.NodeModels.Count(), Is.EqualTo(4)); Assert.That(nodeB, Has.IndexInStack(0, stack)); Assert.That(nodeD, Has.IndexInStack(1, stack)); Assert.That(nodeA, Has.IndexInStack(2, stack)); Assert.That(nodeC, Has.IndexInStack(3, stack)); return(new MoveStackedNodesAction(new [] { nodeD, nodeC }, stack, 0)); }, () => { Assert.That(stack.NodeModels.Count(), Is.EqualTo(4)); Assert.That(nodeD, Has.IndexInStack(0, stack)); Assert.That(nodeC, Has.IndexInStack(1, stack)); Assert.That(nodeB, Has.IndexInStack(2, stack)); Assert.That(nodeA, Has.IndexInStack(3, stack)); }); TestPrereqActionPostreq(mode, () => { Assert.That(stack.NodeModels.Count(), Is.EqualTo(4)); Assert.That(nodeD, Has.IndexInStack(0, stack)); Assert.That(nodeC, Has.IndexInStack(1, stack)); Assert.That(nodeB, Has.IndexInStack(2, stack)); Assert.That(nodeA, Has.IndexInStack(3, stack)); return(new MoveStackedNodesAction(new [] { nodeA, nodeB, nodeC, nodeD }, stack, 0)); }, () => { Assert.That(stack.NodeModels.Count(), Is.EqualTo(4)); Assert.That(nodeA, Has.IndexInStack(0, stack)); Assert.That(nodeB, Has.IndexInStack(1, stack)); Assert.That(nodeC, Has.IndexInStack(2, stack)); Assert.That(nodeD, Has.IndexInStack(3, stack)); }); }
private void AssertClicked(StubElement linkToBeClicked) { Assert.That(driver.ClickedElements, Has.Member(linkToBeClicked)); }
public void Validate_RightEmpty_Pass() { Assert.That(new ComparedToIntegerValidator().Validate(JObject.Parse("{ left: 1, right: '' }"), null) , Has.Property("IsValid").EqualTo(true)); }
public void SetUp() { parseTree = "<attributeexists NUnit.Framework.TestFixtureAttribute>"; staticSyntax = Has.Attribute(typeof(TestFixtureAttribute)); builderSyntax = Builder().Attribute(typeof(TestFixtureAttribute)); }
public void Validate_LeftNoRightEqualSum_Pass() { Assert.That(new ComparedToSumValidator().Validate(JObject.Parse("{ right: 2, sum: 42 }"), null) , Has.Property("IsValid").EqualTo(false)); }
public void SetUp() { parseTree = @"<attribute NUnit.Framework.TestFixtureAttribute <property Description <not <null>>>>"; staticSyntax = Has.Attribute(typeof(TestFixtureAttribute)).Property("Description").Not.Null; builderSyntax = Builder().Attribute(typeof(TestFixtureAttribute)).Property("Description").Not.Null; }
public ComparedToDateValidator() { When(Field("left", Has.Value()) & Field("right", Has.Value())) .Then("left", ComparedTo("right", t => Must.Be.LessOrEqualTo((DateTime)t))); }
public void should_delete_expired_consumable_items_on_merchants() { var lindella = new PlayerBuilder() .With(p => p.Id, 1).BuildAndSave(); var skaldyr = new PlayerBuilder() .With(p => p.Id, 2).BuildAndSave(); var consumable = new ItemSourceBuilder() .With(i => i.ItemType, PvPStatics.ItemType_Consumable) .With(i => i.Id, 7) .BuildAndSave(); var pet = new ItemSourceBuilder() .With(i => i.ItemType, PvPStatics.ItemType_Pet) .With(i => i.Id, 8) .BuildAndSave(); var dungeonArtifact = new ItemSourceBuilder() .With(i => i.ItemType, PvPStatics.ItemType_Consumable) .With(i => i.Id, PvPStatics.ItemType_DungeonArtifact_Id) .BuildAndSave(); // eligible -- owned by lindella new ItemBuilder() .With(p => p.Id, 1) .With(i => i.Owner, lindella) .With(i => i.ItemSource, consumable) .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-9)) .BuildAndSave(); // eligible -- owned by skaldyr new ItemBuilder() .With(p => p.Id, 2) .With(i => i.Owner, skaldyr) .With(i => i.ItemSource, consumable) .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-9)) .BuildAndSave(); // ineligible -- dropped too recently new ItemBuilder() .With(p => p.Id, 3) .With(i => i.Owner, lindella) .With(i => i.ItemSource, consumable) .With(i => i.TimeDropped, DateTime.UtcNow) .BuildAndSave(); // ineligible -- not owned new ItemBuilder() .With(p => p.Id, 4) .With(i => i.Owner, null) .With(i => i.ItemSource, consumable) .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-9)) .BuildAndSave(); // ineligible -- not a consumable type new ItemBuilder() .With(p => p.Id, 5) .With(i => i.Owner, lindella) .With(i => i.ItemSource, pet) .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-9)) .BuildAndSave(); // ineligible -- dungeon artifact new ItemBuilder() .With(p => p.Id, 6) .With(i => i.Owner, lindella) .With(i => i.ItemSource, dungeonArtifact) .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-9)) .BuildAndSave(); var cmd = new DeleteExpiredConsumablesOnMerchants { LindellaId = 1, LorekeeperId = 2 }; Repository.Execute(cmd); var idsRemaining = DataContext.AsQueryable <Item>().Select(i => i.Id); Assert.That(idsRemaining, Has.Member(3)); Assert.That(idsRemaining, Has.Member(4)); Assert.That(idsRemaining, Has.Member(5)); Assert.That(idsRemaining, Has.Member(6)); Assert.That(idsRemaining, Has.No.Member(1)); Assert.That(idsRemaining, Has.No.Member(2)); }
public void AttachmentWithNoDescriptionResolvesToNull() { var result = TestBuilder.RunTestCase(typeof(TestAttachmentsTests), nameof(TestAttachmentsTests.AttachmentWithNoDescription)); Assert.That(result.TestAttachments, Has.Exactly(1).Property(nameof(TestAttachment.Description)).Null); }
/// <summary> /// Returns a new PropertyConstraintExpression, which will either /// test for the existence of the named property on the object /// being tested or apply any following constraint to that property. /// </summary> public ResolvableConstraintExpression Property(string name) { return(Has.Property(name)); }
private static bool VerifyTemplate(ITemplate t) { Assert.That(t, Has.Property("Alias").EqualTo("niceTemplate").And.Property("Name").EqualTo("A nice template")); return(true); }
public void Registration() { var handlers = Factory.Current.Resolve <IEnumerable <ITaskHandler> >().Select(h => h.GetType()); Assert.That(handlers, Has.Member(typeof(RunTriggersHandler))); }