public void Using_Assertion_with_other_Assertions_on_same_member_should_be_add_filter_items(string @operator, string[] allowedOperators) { foreach (var allowedOperator in allowedOperators) { var guid = Guid.NewGuid(); var filters = new List <FilterItem>(new [] { new FilterItem("guidMember", @operator, "foo") }); Expression <Func <GuidAssertionsTestEntity, Guid> > expression = p => p.GuidMember; var subject = new GuidAssertions(expression, filters); if (allowedOperator == "=") { subject.Be(guid); } if (allowedOperator == "!=") { subject.NotBe(guid); } filters.Should().HaveCount(2); filters[0].Name.Should().Be("guidMember"); filters[0].Operator.Should().Be(@operator); filters[0].Value.Should().Be("foo"); filters[1].Name.Should().Be("guidMember"); filters[1].Operator.Should().Be(allowedOperator); filters[1].Value.Should().Be(guid.ToString()); } }
public void Using_Assertion_with_other_Assertions_on_other_member_should_not_be_throw_api_exception(string @operator) { GuidAssertions subject = null; var assertions = new Action[] { () => subject.Be(Guid.NewGuid()), () => subject.NotBe(Guid.NewGuid()) }; foreach (var assertion in assertions) { var filters = new List <FilterItem>(new [] { new FilterItem("guidMember1", @operator, "foo") }); Expression <Func <GuidAssertionsTestEntity, Guid> > expression = p => p.GuidMember; subject = new GuidAssertions(expression, filters); assertion.Should().NotThrow <ApiException>(); } }
public void If_operator_is_not_supported_then_assertion_should_throw_api_exception(string @operator) { var guid = Guid.NewGuid(); var filters = new List <FilterItem>(); Expression <Func <GuidAssertionsTestEntity, Guid> > expression = p => p.OverriddenOperatorsMember; var subject = new GuidAssertions(expression, filters); Action assertion = null; if (@operator != "=") { assertion = () => subject.Be(guid); } if (@operator != "!=") { assertion = () => subject.NotBe(guid); } assertion.Should().Throw <ApiException>(); }
public void Assertion_should_add_filter(string @operator) { var guid = Guid.NewGuid(); var filters = new List <FilterItem>(); Expression <Func <GuidAssertionsTestEntity, Guid> > expression = p => p.GuidMember; var subject = new GuidAssertions(expression, filters); if (@operator == "=") { subject.Be(guid); } else if (@operator == "!=") { subject.NotBe(guid); } filters.Should().HaveCount(1); filters[0].Name.Should().Be("guidMember"); filters[0].Operator.Should().Be(@operator); filters[0].Value.Should().Be(guid.ToString()); }
public void Using_Assertion_with_other_Assertions_on_same_member_should_be_throw_api_exception(string @operator) { var guid = Guid.NewGuid(); var filters = new List <FilterItem>(new [] { new FilterItem("guidMember", @operator, "foo") }); Expression <Func <GuidAssertionsTestEntity, Guid> > expression = p => p.GuidMember; var subject = new GuidAssertions(expression, filters); Action assertion = null; // operators '=' and '!=' can be used with other operators on the same field. if (@operator != "=") { assertion = () => subject.Be(guid); } if (@operator != "!=") { assertion = () => subject.NotBe(guid); } assertion.Should().Throw <ApiException>(); }
public void If_AllowContinueConstraint_not_allowed_then_Assertion_with_other_Assertions_on_same_member_should_throw_api_exception(string @operator, string[] allowedOperators) { foreach (var allowedOperator in allowedOperators) { var guid = Guid.NewGuid(); var filters = new List <FilterItem>(new [] { new FilterItem("notAllowedContinueConstraintMember", @operator, "foo") }); Expression <Func <GuidAssertionsTestEntity, Guid> > expression = p => p.NotAllowedContinueConstraintMember; var subject = new GuidAssertions(expression, filters); Action assertion = null; if (allowedOperator == "=") { assertion = () => subject.Be(guid); } if (allowedOperator == "!=") { assertion = () => subject.NotBe(guid); } assertion.Should().Throw <ApiException>(); } }