public void NonTypedWithSpecificationReturnsNullSpecimenTypeIfNotProvided()
        {
            // Arrange
            // Act
            var sut = new AutoPropertiesCommand();

            // Assert
            Assert.Null(sut.ExplicitSpecimenType);
        }
        public void SutIsSpecifiedSpecimenCommand()
        {
            // Arrange
            // Act
            var sut = new AutoPropertiesCommand <string>();

            // Assert
            Assert.IsAssignableFrom <ISpecifiedSpecimenCommand <string> >(sut);
        }
 public void ExecuteWithNullContainerThrows()
 {
     // Fixture setup
     var sut = new AutoPropertiesCommand<object>();
     var dummySpecimen = new object();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() => sut.Execute(dummySpecimen, null));
     // Teardown
 }
        public void ExecuteWithNullSpecimenThrows()
        {
            // Arrange
            var sut            = new AutoPropertiesCommand <object>();
            var dummyContainer = new DelegatingSpecimenContext();

            // Act & assert
            Assert.Throws <ArgumentNullException>(() => sut.Execute(null, dummyContainer));
        }
 public void SutIsSpecifiedSpecimenCommand()
 {
     // Fixture setup
     // Exercise system
     var sut = new AutoPropertiesCommand<string>();
     // Verify outcome
     Assert.IsAssignableFrom<ISpecifiedSpecimenCommand<string>>(sut);
     // Teardown
 }
        public void IsSatisfiedByNullThrows()
        {
            // Fixture setup
            var sut = new AutoPropertiesCommand <object>();

            // Exercise system and verify outcome
            Assert.Throws <ArgumentNullException>(() => sut.IsSatisfiedBy(null));
            // Teardown
        }
        public void ExecuteWithNullContainerThrows()
        {
            // Arrange
            var sut           = new AutoPropertiesCommand <object>();
            var dummySpecimen = new object();

            // Act & assert
            Assert.Throws <ArgumentNullException>(() => sut.Execute(dummySpecimen, null));
        }
 public void ExecuteWithNullSpecimenThrows()
 {
     // Fixture setup
     var sut = new AutoPropertiesCommand<object>();
     var dummyContainer = new DelegatingSpecimenContext();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() => sut.Execute(null, dummyContainer));
     // Teardown
 }
        public void NonTypedWithSpecificationReturnsNullSpecimenTypeIfNotProvided()
        {
            // Fixture setup
            // Exercise system
            var sut = new AutoPropertiesCommand();

            // Verify outcome
            Assert.Null(sut.ExplicitSpecimenType);
            // Teardown
        }
        public void NonGenericSutIsCorrectGenericSut()
        {
            // Arrange
            var dummyType = typeof(string);
            // Act
            var sut = new AutoPropertiesCommand(dummyType);

            // Assert
            Assert.IsAssignableFrom <AutoPropertiesCommand <object> >(sut);
        }
        public void ExecuteWithNullSpecimenThrows()
        {
            // Fixture setup
            var sut            = new AutoPropertiesCommand <object>();
            var dummyContainer = new DelegatingSpecimenContext();

            // Exercise system and verify outcome
            Assert.Throws <ArgumentNullException>(() => sut.Execute(null, dummyContainer));
            // Teardown
        }
        public void SutIsSpecifiedSpecimenCommand()
        {
            // Fixture setup
            // Exercise system
            var sut = new AutoPropertiesCommand <string>();

            // Verify outcome
            Assert.IsAssignableFrom <ISpecifiedSpecimenCommand <string> >(sut);
            // Teardown
        }
        public void IsSatisfiedByNullThrows()
        {
            // Arrange
            var sut = new AutoPropertiesCommand <object>();

            // Act & assert
#pragma warning disable 618
            Assert.Throws <ArgumentNullException>(() => sut.IsSatisfiedBy(null));
#pragma warning restore 618
        }
        public void ExecuteWithNullContainerThrows()
        {
            // Fixture setup
            var sut           = new AutoPropertiesCommand <object>();
            var dummySpecimen = new object();

            // Exercise system and verify outcome
            Assert.Throws <ArgumentNullException>(() => sut.Execute(dummySpecimen, null));
            // Teardown
        }
        public void NonTypedReturnsSpecimenTypeIfProvidedInCtor()
        {
            // Arrange
            var type = typeof(string);

            // Act
            var sut = new AutoPropertiesCommand(type);

            // Assert
            Assert.Equal(type, sut.ExplicitSpecimenType);
        }
        public void NonGenericSutIsCorrectGenericSut()
        {
            // Fixture setup
            var dummyType = typeof(string);
            // Exercise system
            var sut = new AutoPropertiesCommand(dummyType);

            // Verify outcome
            Assert.IsAssignableFrom <AutoPropertiesCommand <object> >(sut);
            // Teardown
        }
        public void IsSatisfiedByReadOnlyPropertyReturnsCorrectResult()
        {
            // Fixture setup
            var request = typeof(SingleParameterType <object>).GetProperty("Parameter");
            var sut     = new AutoPropertiesCommand <SingleParameterType <object> >();
            // Exercise system
            var result = sut.IsSatisfiedBy(request);

            // Verify outcome
            Assert.False(result);
            // Teardown
        }
        public void NonTypedWithSpecificationReturnsSpecimenTypeIfProvidedInCtor()
        {
            // Arrange
            var type = typeof(string);
            var spec = new TrueRequestSpecification();

            // Act
            var sut = new AutoPropertiesCommand(type, spec);

            // Assert
            Assert.Equal(type, sut.ExplicitSpecimenType);
        }
        public void IsSatisfiedByAnonymousRequestReturnsCorrectResult()
        {
            // Fixture setup
            var sut = new AutoPropertiesCommand <PropertyHolder <object> >();
            var anonymousRequest = new object();
            // Exercise system
            var result = sut.IsSatisfiedBy(anonymousRequest);

            // Verify outcome
            Assert.False(result);
            // Teardown
        }
        public void NonTypedReturnsSpecimenTypeIfProvidedInCtor()
        {
            // Fixture setup
            var type = typeof(string);

            // Exercise system
            var sut = new AutoPropertiesCommand(type);

            // Verify outcome
            Assert.Equal(type, sut.ExplicitSpecimenType);
            // Teardown
        }
        public void IsSatisfiedByIndexedPropertyReturnsCorrectResult()
        {
            // Fixture setup
            var request = typeof(IndexedPropertyHolder <string>).GetProperty("Item");
            var sut     = new AutoPropertiesCommand <IndexedPropertyHolder <string> >();
            // Exercise system
            var result = sut.IsSatisfiedBy(request);

            // Verify outcome
            Assert.False(result);
            // Teardown
        }
        public void IsSatisfiedByUnfilteredFieldInfoReturnsCorrectResult()
        {
            // Fixture setup
            var request = typeof(FieldHolder <object>).GetField("Field");
            var sut     = new AutoPropertiesCommand <FieldHolder <object> >();
            // Exercise system
            var result = sut.IsSatisfiedBy(request);

            // Verify outcome
            Assert.True(result);
            // Teardown
        }
        public void IsSatisfiedByAnonymousRequestReturnsCorrectResult()
        {
            // Arrange
            var sut = new AutoPropertiesCommand <PropertyHolder <object> >();
            var anonymousRequest = new object();

            // Act
#pragma warning disable 618
            var result = sut.IsSatisfiedBy(anonymousRequest);
#pragma warning restore 618
            // Assert
            Assert.False(result);
        }
        public void IsSatisfiedByIndexedPropertyReturnsCorrectResult()
        {
            // Arrange
            var request = typeof(IndexedPropertyHolder <string>).GetProperty("Item");
            var sut     = new AutoPropertiesCommand <IndexedPropertyHolder <string> >();

            // Act
#pragma warning disable 618
            var result = sut.IsSatisfiedBy(request);
#pragma warning restore 618
            // Assert
            Assert.False(result);
        }
        public void IsSatisfiedByReadOnlyPropertyReturnsCorrectResult()
        {
            // Arrange
            var request = typeof(SingleParameterType <object>).GetProperty("Parameter");
            var sut     = new AutoPropertiesCommand <SingleParameterType <object> >();

            // Act
#pragma warning disable 618
            var result = sut.IsSatisfiedBy(request);
#pragma warning restore 618
            // Assert
            Assert.False(result);
        }
        public void IsSatisfiedByUnfilteredFieldInfoReturnsCorrectResult()
        {
            // Arrange
            var request = typeof(FieldHolder <object>).GetField("Field");
            var sut     = new AutoPropertiesCommand <FieldHolder <object> >();

            // Act
#pragma warning disable 618
            var result = sut.IsSatisfiedBy(request);
#pragma warning restore 618
            // Assert
            Assert.True(result);
        }
        public void ExecuteDoesNotThrowOnIndexedProperty()
        {
            // Arrange
            var sut       = new AutoPropertiesCommand <IndexedPropertyHolder <object> >();
            var specimen  = new IndexedPropertyHolder <object>();
            var container = new DelegatingSpecimenContext {
                OnResolve = r => new object()
            };

            // Act & assert
            Assert.Null(Record.Exception(() =>
                                         sut.Execute((object)specimen, container)));
        }
 public void ExecuteDoesNotSetReadOnlyProperty()
 {
     // Fixture setup
     var sut = new AutoPropertiesCommand<SingleParameterType<object>>();
     var specimen = new SingleParameterType<object>(new object());
     var unexpectedValue = new object();
     var container = new DelegatingSpecimenContext { OnResolve = r => unexpectedValue };
     // Exercise system
     sut.Execute(specimen, container);
     // Verify outcome
     Assert.NotEqual(unexpectedValue, specimen.Parameter);
     // Teardown
 }
        public void IsSatisfiedByUnfilteredPropertyInfoReturnsCorrectResult()
        {
            // Fixture setup
            var request = typeof(PropertyHolder <object>).GetProperty("Property");
            var sut     = new AutoPropertiesCommand <PropertyHolder <object> >();

            // Exercise system
#pragma warning disable 618
            var result = sut.IsSatisfiedBy(request);
#pragma warning restore 618
            // Verify outcome
            Assert.True(result);
            // Teardown
        }
        public void ExecuteDoesNotThrowOnIndexedProperty()
        {
            // Fixture setup
            var sut       = new AutoPropertiesCommand <IndexedPropertyHolder <object> >();
            var specimen  = new IndexedPropertyHolder <object>();
            var container = new DelegatingSpecimenContext {
                OnResolve = r => new object()
            };

            // Exercise system and verify outcome
            Assert.DoesNotThrow(() =>
                                sut.Execute(specimen, container));
            // Teardown
        }
        void ExecuteDoesNotSetStaticField()
        {
            // Arrange
            var sut       = new AutoPropertiesCommand <StaticFieldHolder <object> >();
            var specimen  = new StaticFieldHolder <object>();
            var container = new DelegatingSpecimenContext {
                OnResolve = r => new object()
            };

            // Act
            sut.Execute((object)specimen, container);
            // Assert
            Assert.Null(StaticFieldHolder <object> .Field);
        }
        public void IsSatisfiedByFilteredFieldInfoReturnsCorrectResult()
        {
            // Fixture setup
            var spec = new DelegatingRequestSpecification {
                OnIsSatisfiedBy = r => false
            };
            var sut     = new AutoPropertiesCommand <FieldHolder <object> >(spec);
            var request = typeof(FieldHolder <object>).GetField("Field");
            // Exercise system
            var result = sut.IsSatisfiedBy(request);

            // Verify outcome
            Assert.False(result);
            // Teardown
        }
        public void ExecuteDoesNotSetStaticField()
        {
            // Fixture setup
            var sut       = new AutoPropertiesCommand <StaticFieldHolder <object> >();
            var specimen  = new StaticFieldHolder <object>();
            var container = new DelegatingSpecimenContext {
                OnResolve = r => new object()
            };

            // Exercise system
            sut.Execute(specimen, container);
            // Verify outcome
            Assert.Null(StaticFieldHolder <object> .Field);
            // Teardown
        }
        public void ExecuteDoesNotSetReadOnlyProperty()
        {
            // Arrange
            var sut             = new AutoPropertiesCommand <SingleParameterType <object> >();
            var specimen        = new SingleParameterType <object>(new object());
            var unexpectedValue = new object();
            var container       = new DelegatingSpecimenContext {
                OnResolve = r => unexpectedValue
            };

            // Act
            sut.Execute((object)specimen, container);
            // Assert
            Assert.NotEqual(unexpectedValue, specimen.Parameter);
        }
        public void ExecuteWillAssignCorrectPropertyValue()
        {
            // Fixture setup
            var expectedPropertyValue = new object();
            var container = new DelegatingSpecimenContext { OnResolve = r => expectedPropertyValue };

            var sut = new AutoPropertiesCommand<PropertyHolder<object>>();

            var specimen = new PropertyHolder<object>();
            // Exercise system
            sut.Execute(specimen, container);
            // Verify outcome
            Assert.Equal(expectedPropertyValue, specimen.Property);
            // Teardown
        }
 public void IsSatisfiedByUnfilteredFieldInfoReturnsCorrectResult()
 {
     // Fixture setup
     var request = typeof(FieldHolder<object>).GetField("Field");
     var sut = new AutoPropertiesCommand<FieldHolder<object>>();
     // Exercise system
     var result = sut.IsSatisfiedBy(request);
     // Verify outcome
     Assert.True(result);
     // Teardown
 }
 public void ExecuteDoesNotSetStaticField()
 {
     // Fixture setup
     var sut = new AutoPropertiesCommand<StaticFieldHolder<object>>();
     var specimen = new StaticFieldHolder<object>();
     var container = new DelegatingSpecimenContext { OnResolve = r => new object() };
     // Exercise system
     sut.Execute(specimen, container);
     // Verify outcome
     Assert.Null(StaticFieldHolder<object>.Field);
     // Teardown
 }
 public void ExecuteDoesNotAssignFieldWhenSpecificationIsNotSatisfied()
 {
     // Fixture setup
     var spec = new DelegatingRequestSpecification { OnIsSatisfiedBy = r => false };
     var sut = new AutoPropertiesCommand<FieldHolder<object>>(spec);
     var specimen = new FieldHolder<object>();
     var container = new DelegatingSpecimenContext { OnResolve = r => new object() };
     // Exercise system
     sut.Execute(specimen, container);
     // Verify outcome
     Assert.Null(specimen.Field);
     // Teardown
 }
 public void ExecuteWillQuerySpecificationWithCorrectFieldInfo()
 {
     // Fixture setup
     var expectedFieldInfo = typeof(FieldHolder<string>).GetField("Field");
     var verified = false;
     var specMock = new DelegatingRequestSpecification { OnIsSatisfiedBy = r => verified = expectedFieldInfo.Equals(r) };
     var sut = new AutoPropertiesCommand<FieldHolder<string>>(specMock);
     // Exercise system
     var specimen = new FieldHolder<string>();
     var dummyContainer = new DelegatingSpecimenContext();
     sut.Execute(specimen, dummyContainer);
     // Verify outcome
     Assert.True(verified, "Mock verified");
     // Teardown
 }
 public void ExecuteWillNotAssignFieldWhenContextReturnsOmitSpecimen()
 {
     // Fixture setup
     var sut = new AutoPropertiesCommand<FieldHolder<object>>();
     var specimen = new FieldHolder<object>();
     var context = new DelegatingSpecimenContext
     {
         OnResolve = r => new OmitSpecimen()
     };
     // Exercise system
     sut.Execute(specimen, context);
     // Verify outcome
     Assert.Null(specimen.Field);
     // Teardown
 }
 public void IsSatisfiedByWillInvokeSpecificationWithCorrectFieldInfo()
 {
     // Fixture setup
     var expectedRequest = typeof(FieldHolder<object>).GetField("Field");
     var verified = false;
     var specMock = new DelegatingRequestSpecification { OnIsSatisfiedBy = r => verified = expectedRequest.Equals(r) };
     var sut = new AutoPropertiesCommand<FieldHolder<object>>(specMock);
     // Exercise system
     sut.IsSatisfiedBy(expectedRequest);
     // Verify outcome
     Assert.True(verified, "Mock verified");
     // Teardown
 }
 public void IsSatisfiedByReadOnlyPropertyReturnsCorrectResult()
 {
     // Fixture setup
     var request = typeof(SingleParameterType<object>).GetProperty("Parameter");
     var sut = new AutoPropertiesCommand<SingleParameterType<object>>();
     // Exercise system
     var result = sut.IsSatisfiedBy(request);
     // Verify outcome
     Assert.False(result);
     // Teardown
 }
 public void IsSatisfiedByFilteredFieldInfoReturnsCorrectResult()
 {
     // Fixture setup
     var spec = new DelegatingRequestSpecification { OnIsSatisfiedBy = r => false };
     var sut = new AutoPropertiesCommand<FieldHolder<object>>(spec);
     var request = typeof(FieldHolder<object>).GetField("Field");
     // Exercise system
     var result = sut.IsSatisfiedBy(request);
     // Verify outcome
     Assert.False(result);
     // Teardown
 }
 public void SutIsSpecimenCommand()
 {
     var sut = new AutoPropertiesCommand<object>();
     Assert.IsAssignableFrom<ISpecimenCommand>(sut);
 }
        public void ExecuteOnNonGenericFalseSpecifiedDoesNotAssignProperty()
        {
            // Fixture setup
            var falseSpecification = new DelegatingRequestSpecification
            {
                OnIsSatisfiedBy = x => false
            };
            var sut = new AutoPropertiesCommand(falseSpecification);

            var dummyPropertyValue = new object();
            var context = new DelegatingSpecimenContext { OnResolve = r => dummyPropertyValue };

            var specimen = new PropertyHolder<object>();
            // Exercise system
            sut.Execute(specimen, context);
            // Verify outcome
            Assert.NotEqual(dummyPropertyValue, specimen.Property);
            // Teardown
        }
        public void ExecuteOnNonGenericTrueSpecifiedAssignsProperty()
        {
            // Fixture setup
            var trueSpecification = new DelegatingRequestSpecification
            {
                OnIsSatisfiedBy = x => true 
            };
            var sut = new AutoPropertiesCommand(trueSpecification);

            var expectedPropertyValue = new object();
            var context = new DelegatingSpecimenContext { OnResolve = r => expectedPropertyValue };

            var specimen = new PropertyHolder<object>();
            // Exercise system
            sut.Execute(specimen, context);
            // Verify outcome
            Assert.Equal(expectedPropertyValue, specimen.Property);
            // Teardown
        }
 public void NonGenericSutIsCorrectGenericSut()
 {
     // Fixture setup
     var dummyType = typeof(string);
     // Exercise system
     var sut = new AutoPropertiesCommand(dummyType);
     // Verify outcome
     Assert.IsAssignableFrom<AutoPropertiesCommand<object>>(sut);
     // Teardown
 }
 public void ExecuteDoesNotThrowOnIndexedProperty()
 {
     // Fixture setup
     var sut = new AutoPropertiesCommand<IndexedPropertyHolder<object>>();
     var specimen = new IndexedPropertyHolder<object>();
     var container = new DelegatingSpecimenContext { OnResolve = r => new object() };
     // Exercise system and verify outcome
     Assert.DoesNotThrow(() =>
         sut.Execute(specimen, container));
     // Teardown
 }
 public void IsSatisfiedByNullThrows()
 {
     // Fixture setup
     var sut = new AutoPropertiesCommand<object>();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() => sut.IsSatisfiedBy(null));
     // Teardown
 }
 public void IsSatisfiedByAnonymousRequestReturnsCorrectResult()
 {
     // Fixture setup
     var sut = new AutoPropertiesCommand<PropertyHolder<object>>();
     var anonymousRequest = new object();
     // Exercise system
     var result = sut.IsSatisfiedBy(anonymousRequest);
     // Verify outcome
     Assert.False(result);
     // Teardown
 }
 public void IsSatisfiedByIndexedPropertyReturnsCorrectResult()
 {
     // Fixture setup
     var request = typeof(IndexedPropertyHolder<string>).GetProperty("Item");
     var sut = new AutoPropertiesCommand<IndexedPropertyHolder<string>>();
     // Exercise system
     var result = sut.IsSatisfiedBy(request);
     // Verify outcome
     Assert.False(result);
     // Teardown
 }