public void IsSatisfiedByWithNullRequestShouldThrowArgumentNullException() { // Arrange var sut = new PropertySpecification(typeof(object), "someName"); // Act & assert Assert.Throws <ArgumentNullException>(() => sut.IsSatisfiedBy(null)); }
public void IsSatisfiedByWithNullRequestShouldThrowArgumentNullException() { // Fixture setup var sut = new PropertySpecification(typeof(object), "someName"); // Exercise system and verify outcome Assert.Throws <ArgumentNullException>(() => sut.IsSatisfiedBy(null)); // Teardown }
public void TrueSpecification_ReturnTrue <T>(FakeType candidate, Expression <Func <FakeType, T> > selector) { var specification = MockSpecification <T> .True(); var sut = new PropertySpecification <FakeType, T>(selector, specification); var result = sut.IsSatisfiedBy(candidate); Assert.True(result); }
public void IsSatisfiedByWithInvalidRequestShouldReturnFalse(object request) { // Arrange var sut = new PropertySpecification(typeof(object), "someName"); // Act var result = sut.IsSatisfiedBy(request); // Assert Assert.False(result); }
public void IsSatisfiedByWithInvalidRequestShouldReturnFalse(object request) { // Fixture setup var sut = new PropertySpecification(typeof(object), "someName"); // Exercise system var result = sut.IsSatisfiedBy(request); // Verify outcome Assert.False(result); // Teardown }
public void FalseSpecification_ReturnFalse <T>(FakeType candidate, Expression <Func <FakeType, T> > selector) { candidate = candidate.Second != "null" ? candidate : null; var specification = MockSpecification <T> .False(); var sut = new PropertySpecification <FakeType, T>(selector, specification); var result = sut.IsSatisfiedBy(candidate); Assert.False(result); }
public void TrueSpecification_ReturnExpectedResultObject <T>(FakeType candidate, Expression <Func <FakeType, T> > selector, SpecificationResult expected) { ISpecification <T> specification = MockValidationSpecification <T> .True(); var sut = new PropertySpecification <FakeType, T>(selector, specification); var overall = sut.IsSatisfiedBy(candidate, out var result); Assert.True(overall); Assert.Equal(expected, result, new SpecificationResultComparer()); }
public void RelatedTypes_NoException() { var specification = MockSpecification <IEnumerable <char> > .True(); var exception = Record.Exception(() => { var sut = new PropertySpecification <FakeType, string>( ft => ft.Second, specification); sut.IsSatisfiedBy(new FakeType(), out _); }); Assert.Null(exception); }
public void IsSatisfiedByWithRequestForReadOnlyPropertyWithSameNameShouldReturnTrue() { // Arrange var propertyName = "Property"; var requestedName = "Property"; var sut = new PropertySpecification(typeof(object), propertyName); var request = typeof(ReadOnlyPropertyHolder <object>).GetProperty(requestedName); // Act var result = sut.IsSatisfiedBy(request); // Assert Assert.True(result); }
public void IsSatisfiedByWithRequestForMemberOtherThanPropertyWithSameNameShouldReturnFalse() { // Arrange var propertyName = "Field"; var requestedName = "Field"; var sut = new PropertySpecification(typeof(object), propertyName); var request = typeof(FieldHolder <object>).GetField(requestedName); // Act var result = sut.IsSatisfiedBy(request); // Assert Assert.False(result); }
public void IsSatisfiedByWithRequestForPropertyWithSameNameAndIncompatibleTypeShouldReturnFalse() { // Arrange var propertyName = "Property"; var requestedName = "Property"; var sut = new PropertySpecification(typeof(object), propertyName); var request = typeof(PropertyHolder <int>).GetProperty(requestedName); // Act var result = sut.IsSatisfiedBy(request); // Assert Assert.False(result); }
public void IsSatisfiedByWithRequestForPropertyWithSameNameAndIncompatibleTypeShouldReturnFalse() { // Fixture setup var propertyName = "Property"; var requestedName = "Property"; var sut = new PropertySpecification(typeof(object), propertyName); var request = typeof(PropertyHolder <int>).GetProperty(requestedName); // Exercise system var result = sut.IsSatisfiedBy(request); // Verify outcome Assert.False(result); // Teardown }
public void IsSatisfiedByWithRequestForReadOnlyPropertyWithSameNameShouldReturnTrue() { // Fixture setup var propertyName = "Property"; var requestedName = "Property"; var sut = new PropertySpecification(typeof(object), propertyName); var request = typeof(ReadOnlyPropertyHolder <object>).GetProperty(requestedName); // Exercise system var result = sut.IsSatisfiedBy(request); // Verify outcome Assert.True(result); // Teardown }
public void IsSatisfiedByWithRequestForPropertyShouldReturnCorrectResult( string propertyName, string requestedName, bool expectedResult) { // Arrange var sut = new PropertySpecification(typeof(object), propertyName); var request = typeof(PropertyHolder <object>).GetProperty(requestedName); // Act var result = sut.IsSatisfiedBy(request); // Assert Assert.Equal(expectedResult, result); }
public void IsSatisfiedByWithRequestForMemberOtherThanPropertyWithSameNameShouldReturnFalse() { // Fixture setup var propertyName = "Field"; var requestedName = "Field"; var sut = new PropertySpecification(typeof(object), propertyName); var request = typeof(FieldHolder <object>).GetField(requestedName); // Exercise system var result = sut.IsSatisfiedBy(request); // Verify outcome Assert.False(result); // Teardown }
public void IsSatisfiedByWithRequestForPropertyShouldReturnCorrectResult( string propertyName, string requestedName, bool expectedResult) { // Fixture setup var sut = new PropertySpecification(typeof(object), propertyName); var request = typeof(PropertyHolder <object>).GetProperty(requestedName); // Exercise system var result = sut.IsSatisfiedBy(request); // Verify outcome Assert.Equal(expectedResult, result); // Teardown }
public void FalseSpecification_ReturnExpectedResultObject <T>(FakeType candidate, Expression <Func <FakeType, T> > selector, SpecificationResult expected) { candidate = candidate.Second != "null" ? candidate : null; ISpecification <T> specification = MockComplexSpecification <T> .False(); var sut = new PropertySpecification <FakeType, T>(selector, specification); var overall = sut.IsSatisfiedBy(candidate, out var result); Assert.False(overall); Assert.Equal(expected, result, new SpecificationResultComparer( parameters: new Dictionary <string, object> { { "PropertySpecification", specification } })); }
public void IsSatisfiedByReturnsCorrectResultAccordingToTarget( bool expected) { var prop = typeof(string).GetProperty("Length"); var target = new DelegatingCriterion <PropertyInfo> { OnEquals = p => { Assert.Equal(prop, p); return(expected); } }; var sut = new PropertySpecification(target); var actual = sut.IsSatisfiedBy(prop); Assert.Equal(expected, actual); }
public void ItWorks(string artist, bool result) { specification.Expect(x => x.IsSatisfiedBy(artist)).Return(result); Assert.AreEqual(sut.IsSatisfiedBy(testAlbum), result); }
public void ReturnsCorrectResultForLambdaExpression(TestObject testObject, bool expectedResult) { var specification = new PropertySpecification <TestObject, TestObject>(p => p.Property, new ExpressionSpecification <TestObject>(p => p.BooleanProperty)); specification.IsSatisfiedBy(testObject).ShouldBe(expectedResult); }