public void PropertiesAreCorrectlyInitialized(ConstructorInitializedMemberAssertion assertion) { // Fixture setup var property = new Properties<JSuccessWithDataResponse<int>>(); // Exercise system and verify outcome assertion.Verify(property.Select(r => r.Data)); assertion.Verify(property.Select(r => r.HttpResponse)); }
public void PropertiesAreCorrectlyInitializer(ConstructorInitializedMemberAssertion assertion) { // Fixture setup var properties = new Properties<JErrorResponse<int>>(); // Exercise system and verify outcome assertion.Verify(properties.Select(r => r.Error)); assertion.Verify(properties.Select(r => r.HttpResponse)); }
public void AllConstructorArgumentsShouldBeExposedAsWellBehavedReadOnlyProperties(IFixture fixture) { // Arrange var assertion = new ConstructorInitializedMemberAssertion(fixture); var type = typeof(AndSpecification<TestType>); // Act var constructors = type.GetConstructors(); var readOnlyProperties = type.GetProperties().Where(x => x.GetSetMethod(nonPublic: true) == null); // Assert assertion.Verify(constructors); assertion.Verify(readOnlyProperties); }
public void CtorParametersAreInitialized(IFixture fixture, Name name) { fixture.Inject<IParameter>(new ParameterTest()); fixture.Inject<ParameterMeta>(ParameterMeta.Create<IParameter>(name)); var assertion = new ConstructorInitializedMemberAssertion(fixture); assertion.Verify(typeof(CmdApplicationConfiguration)); }
public void PropertiesAreCorrectlyInitialized(IFixture fixture, ConstructorInitializedMemberAssertion assertion) { // Fixture setup fixture.Inject(JSendStatus.Error); var properties = typeof (JSendError).GetProperties(); // Exercise system and verify outcome assertion.Verify(properties); }
public void PropertiesAreCorrectlyInitialized( string propertyName, ConstructorInitializedMemberAssertion assertion) { // Fixture setup var property = typeof (ErrorResponse).GetProperty(propertyName); // Exercise system and verify outcome assertion.Verify(property); }
public void VerifyWhenMemberTypeIsComplexDoesNotThrow() { // Arrange var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var ctor = typeof(ReadOnlyPropertiesInitializedViaConstructor <ComplexType, object>) .GetConstructor(new[] { typeof(ComplexType), typeof(object) }); // Act & Assert Assert.Null(Record.Exception(() => sut.Verify(ctor))); }
public void VerifyWhenPropertyTypeIsAssignableFromParameterTypeShouldThrow() { // Arrange var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var ctor = typeof(PropertyIsAssignableFromConstructorArgumentType).GetConstructors().First(); // Act & Assert Assert.Throws <ConstructorInitializedMemberException>(() => sut.Verify(ctor)); }
public void VerifyReadOnlyFieldInitializedViaConstructorWithDifferentTypeThrows() { // Arrange var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var fieldInfo = typeof(ReadOnlyFieldInitializedViaConstructorWithDifferentType).GetField("Field"); // Act & Assert var e = Assert.Throws <ConstructorInitializedMemberException>(() => sut.Verify(fieldInfo)); AssertExceptionPropertiesEqual(e, fieldInfo); }
public void VerifyWritableFieldWithNoMatchingConstructorDoesNotThrow() { // Arrange var composer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(composer); var propertyInfo = typeof(FieldHolder <object>).GetField("Field"); // Act & Assert Assert.Null(Record.Exception(() => sut.Verify(propertyInfo))); }
public void VerifyWhenConstructorArgumentHasWriteOnlyPropertyDoesNotThrow() { // Arrange var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var ctor = typeof(WriteOnlyPropertyHolder <ComplexType>).GetConstructors().First(); // Act & Assert Assert.Null( Record.Exception(() => sut.Verify(ctor))); }
public void VerifyTypeWithPublicWritablePropertyAndNoMatchingConstructorArgumentDoesNotThrow() { // Fixture setup var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var typeToVerify = typeof(PropertyHolder <ComplexType>); // Exercise system and verify outcome Assert.DoesNotThrow(() => sut.Verify(typeToVerify)); // Teardown }
public void VerifyWellBehavedReadOnlyFieldInitializedViaConstructorDoesNotThrow() { // Fixture setup var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var fieldInfo = typeof(ReadOnlyFieldInitializedViaConstructor <object>).GetField("Field"); // Exercise system and verify outcome Assert.DoesNotThrow(() => sut.Verify(fieldInfo)); // Teardown }
public void VerifyTypeWithPublicStaticReadOnlyPropertyAndNoMatchingGuardedConstuctorArgumentDoesNotThrow() { // Fixture setup var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var typeToVerify = typeof(GuardedConstructorHostHoldingStaticReadOnlyProperty <ComplexType, int>); // Exercise system and verify outcome Assert.Null(Record.Exception(() => sut.Verify(typeToVerify))); // Teardown }
public void VerifyWhenPropertyIsWriteOnlyDoesNotThrow() { // Fixture setup var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var propertyInfo = typeof(WriteOnlyPropertyHolder <ComplexType>).GetProperty("WriteOnlyProperty"); // Exercise system and verify outcome Assert.Null(Record.Exception(() => sut.Verify(propertyInfo))); // Teardown }
public void VerifyTypeWithPublicStaticFieldAndNoMatchingConstructorArgumentDoesNotThrow() { // Fixture setup var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var typeToVerify = typeof(StaticFieldHolder <ComplexType>); // Exercise system and verify outcome Assert.Null(Record.Exception(() => sut.Verify(typeToVerify))); // Teardown }
public void VerifyWellBehavedReadOnlyPropertyInitializedViaConstructorDoesNotThrow() { // Fixture setup var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var propertyInfo = typeof(ReadOnlyPropertyInitializedViaConstructor <object>).GetProperty("Property"); // Exercise system and verify outcome Assert.Null(Record.Exception(() => sut.Verify(propertyInfo))); // Teardown }
public void VerifyNullFieldThrows() { // Fixture setup var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); // Exercise system and verify outcome Assert.Throws <ArgumentNullException>(() => sut.Verify((FieldInfo)null)); // Teardown }
public void VerifyWhenPropertyGetterIsInternalDoesNotThrow() { // Fixture setup var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var propertyInfo = typeof(InternalGetterPropertyHolder <ComplexType>).GetProperty("Property"); // Exercise system and verify outcome Assert.DoesNotThrow(() => sut.Verify(propertyInfo)); // Teardown }
public void VerifyWritablePropertyWithNoMatchingConstructorDoesNotThrow() { // Fixture setup var composer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(composer); var propertyInfo = typeof(PropertyHolder <object>).GetProperty("Property"); // Exercise system and verify outcome Assert.Null(Record.Exception(() => sut.Verify(propertyInfo))); // Teardown }
public void VerifyReadOnlyPropertyWithNoSetterAndNoMatchingConstructorThrows() { // Arrange var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var propertyInfo = typeof(ReadOnlyPropertyWithNoSetterHolder <int>).GetProperty("Property"); // Act & Assert var e = Assert.Throws <ConstructorInitializedMemberException>(() => sut.Verify(propertyInfo)); AssertExceptionPropertiesEqual(e, propertyInfo); }
public void ConstructorSetsCorrectInitializedMembers() { var fixture = new Fixture(); var propertyInfo = SutType.GetProperty(nameof(SutAlias.PropertyInfo)); fixture.Inject(propertyInfo); var assertion = new ConstructorInitializedMemberAssertion(fixture); assertion.Verify( SutType.GetProperty(nameof(SutAlias.PropertyInfo))); }
public void VerifyWhenConstructorArgumentHasWriteOnlyPropertyDoesNotThrow() { // Fixture setup var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var ctor = typeof(WriteOnlyPropertyHolder <ComplexType>).GetConstructors().First(); // Exercise system and verify outcome Assert.DoesNotThrow( () => sut.Verify(ctor)); // Teardown }
public void VerifyTypeWithWritablePropertyAndMatchingIllBehavedConstructorArgumentThrows() { // Arrange var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var typeToVerify = typeof(WritablePropertyAndIllBehavedConstructor); // Act & Assert var e = Assert.Throws <ConstructorInitializedMemberException>(() => sut.Verify(typeToVerify)); var expectedFailingProperty = typeToVerify.GetProperties().Single(); AssertExceptionPropertiesEqual(e, expectedFailingProperty); }
public void VerifyDefaultConstructorDoesNotThrow() { // Arrange var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); // Act & Assert var constructorWithNoParameters = typeof(PropertyHolder <object>).GetConstructors().First(); Assert.Empty(constructorWithNoParameters.GetParameters()); Assert.Null(Record.Exception(() => sut.Verify(constructorWithNoParameters))); }
public void VerifyWhenMemberTypeIsComplexDoesNotThrow() { // Fixture setup var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var ctor = typeof(ReadOnlyPropertiesInitializedViaConstructor <ComplexType, object>) .GetConstructor(new[] { typeof(ComplexType), typeof(object) }); // Exercise system and verify outcome Assert.DoesNotThrow(() => sut.Verify(ctor)); // Teardown }
public void VerifyTypeWithPublicReadOnlyFieldsIncorrectlyInitialisedViaConstructorThrows() { // Arrange var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var typeToVerify = typeof(PublicReadOnlyFieldNotInitializedByConstructor); // Act & Assert var e = Assert.Throws <ConstructorInitializedMemberException>(() => sut.Verify(typeToVerify)); var expectedFailingField = typeToVerify.GetFields().First(); AssertExceptionPropertiesEqual(e, expectedFailingField); }
public void VerifyWritableFieldWithNoMatchingConstructorDoesNotThrow() { // Fixture setup var composer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(composer); var propertyInfo = typeof(FieldHolder <object>).GetField("Field"); // Exercise system and verify outcome Assert.DoesNotThrow(() => sut.Verify(propertyInfo)); // Teardown }
public void VerifyReadOnlyFieldInitializedViaConstructorWithDifferentTypeThrows() { // Fixture setup var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var fieldInfo = typeof(ReadOnlyFieldInitializedViaConstructorWithDifferentType).GetField("Field"); // Exercise system and verify outcome var e = Assert.Throws <ConstructorInitializedMemberException>(() => sut.Verify(fieldInfo)); AssertExceptionPropertiesEqual(e, fieldInfo); // Teardown }
public void VerifyWhenConstructorArgumentTypeIsDifferentToFieldThrows() { // Arrange var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var ctor = typeof(ReadOnlyFieldInitializedViaConstructorWithDifferentType).GetConstructors().First(); // Act & Assert var e = Assert.Throws <ConstructorInitializedMemberException>(() => sut.Verify(ctor)); var expectedMissingParam = ctor.GetParameters().Single(p => p.Name == "value"); AssertExceptionPropertiesEqual(e, ctor, expectedMissingParam); }
public void VerifyWhenPropertyTypeIsAssignableFromParameterTypeDoesNotThrow() { // Fixture setup var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var ctor = typeof(PropertyIsAssignableFromConstructorArgumentType).GetConstructors().First(); // Exercise system and verify outcome Assert.DoesNotThrow(() => sut.Verify(ctor)); // Teardown }
public void VerifyWhenNotAllConstructorArgumentsAreExposedAsPropertiesThrows() { // Arrange var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var ctor = typeof(ReadOnlyPropertiesInitializedViaConstructor <object, int>) .GetConstructor(new[] { typeof(object), typeof(int), typeof(TriState) }); // Act & Assert var e = Assert.Throws <ConstructorInitializedMemberException>(() => sut.Verify(ctor)); var expectedMissingParam = ctor.GetParameters().Single(p => p.Name == "noMatchingProperty"); AssertExceptionPropertiesEqual(e, ctor, expectedMissingParam); }
public void VerifyTypeWithReadOnlyPropertyAndIllBehavedConstructorThrows() { // Arrange var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var typeToVerify = typeof(ReadOnlyPropertiesInitializedViaConstructor <int, string>); // Act & Assert var e = Assert.Throws <ConstructorInitializedMemberException>(() => sut.Verify(typeToVerify)); var expectedFailingConstructor = typeToVerify.GetConstructor(new[] { typeof(int), typeof(string), typeof(TriState) }); var expectedFailingParameter = expectedFailingConstructor.GetParameters().Single(p => p.Name == "noMatchingProperty"); AssertExceptionPropertiesEqual(e, expectedFailingConstructor, expectedFailingParameter); }
public void VerifyDefaultConstructorDoesNotThrow() { // Fixture setup var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); // Exercise system and verify outcome var constructorWithNoParameters = typeof(PropertyHolder <object>).GetConstructors().First(); Assert.Equal(0, constructorWithNoParameters.GetParameters().Length); Assert.DoesNotThrow(() => sut.Verify(constructorWithNoParameters)); // Teardown }
public void VerifyReadOnlyPropertyWithNoSetterAndNoMatchingConstructorThrows() { // Fixture setup var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var propertyInfo = typeof(ReadOnlyPropertyWithNoSetterHolder <int>).GetProperty("Property"); // Exercise system and verify outcome var e = Assert.Throws <ConstructorInitializedMemberException>(() => sut.Verify(propertyInfo)); AssertExceptionPropertiesEqual(e, propertyInfo); // Teardown }
public void VerifyWhenNotAllConstructorArgumentsAreExposedAsFieldsThrows() { // Fixture setup var dummyComposer = new Fixture(); var sut = new ConstructorInitializedMemberAssertion(dummyComposer); var ctor = typeof(FieldsInitializedViaConstructor <object, int>) .GetConstructor(new[] { typeof(object), typeof(int), typeof(TriState) }); // Exercise system and verify outcome var e = Assert.Throws <ConstructorInitializedMemberException>(() => sut.Verify(ctor)); var expectedMissingParam = ctor.GetParameters().Single(p => p.Name == "noMatchingField"); AssertExceptionPropertiesEqual(e, ctor, expectedMissingParam); // Teardown }
public void ShouldInitializeReadOnlyPropertiesByConstructor() { var fixture = new Fixture(); var intializeReadOnlyPropertiesAssertion = new ConstructorInitializedMemberAssertion(fixture); var typesToExclude = new[] { typeof(ActivityId), // Does not expose an Id property and doing so is not needed typeof(DeviceId) // Does not expose an Id property and doing so is not needed }; intializeReadOnlyPropertiesAssertion.Verify( DomainTypes() .Except(typesToExclude)); }
public void CtorParametersAreInitialized(IFixture fixture) { var assertion = new ConstructorInitializedMemberAssertion(fixture); assertion.Verify(typeof(JsonCmdApplicationConfigurationRepository).GetConstructors()); }
public void VerifyConstructorParametersCorrectlyInitializeProperties() { var fixture = new Fixture(); var assertion = new ConstructorInitializedMemberAssertion(fixture); var members = typeof(MutableValueType).GetConstructors(); assertion.Verify(members); }
public void PropertiesAreCorrectlyInitializedThroughTheConstructor( string propertyName, ConstructorInitializedMemberAssertion assertion) { // Fixture setup var property = typeof (JSendCreatedAtRouteResult<Model>).GetProperty(propertyName); // Exercise system and verify outcome assertion.Verify(property); }
public void VerifyReadOnlyPropertyInitializedByConstructor() { var fixture = new Fixture(); var assertion = new ConstructorInitializedMemberAssertion(fixture); var members = typeof (UnguardedConstructorHost<Version>).GetProperties(); assertion.Verify(members); }
public void CtorParametersAreInitialized(IFixture fixture) { var assertion = new ConstructorInitializedMemberAssertion(fixture); assertion.Verify(typeof(CmdApplicationConfigurationService)); }
public void PropertiesAreCorrectlyInitialized(ConstructorInitializedMemberAssertion assertion) { // Exercise system and verify outcome assertion.Verify(typeof (ResponseReceivedContext).GetProperties()); }
public void CtorParametersAreInitialized(IFixture fixture) { var assertion = new ConstructorInitializedMemberAssertion(fixture); assertion.Verify(typeof(NameValueParameter)); }
public void CtorParametersAreInitialized(IFixture fixture, Name name) { var assertion = new ConstructorInitializedMemberAssertion(fixture); assertion.Verify(typeof(CmdApplicationConfigurationViewModel).GetConstructors()); }
public void CtorParametersAreInitialized(IFixture fixture) { var assertion = new ConstructorInitializedMemberAssertion(fixture); assertion.Verify(typeof(NameOnlyParameterViewModel).GetConstructors()); }
public void VerifyConstructorInitializedProperties( ConstructorInitializedMemberAssertion assertion) { assertion.Verify(typeof(TypeResolutionEntry).GetProperties()); }