public void ConstructObject_GivenNonZeroParameter_ShouldConstructCorrectly() { //---------------Set up test pack------------------- //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- Assert.DoesNotThrow(() => ConstructorTestHelper.ConstructObject <FakeTestClass4>()); //---------------Test Result ----------------------- }
public void ConstructObject_GivenArray_ShouldNotThrowException() { //---------------Set up test pack------------------- //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- Assert.DoesNotThrow(() => ConstructorTestHelper.ConstructObject <FakeTestClass2>()); //---------------Test Result ----------------------- }
public void ConstructObject_GivenAllParametersMustMatch_ShouldConstructCorrectly() { //---------------Set up test pack------------------- //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- Assert.DoesNotThrow(() => ConstructorTestHelper.ConstructObject <FakeTestClass4>(null, null, true, ("someTestValue", 200))); //---------------Test Result ----------------------- }
public void ConstructObject_GivenTypeAndParameterAndNoValue_ShouldConstructObjectWithNullValue() { //---------------Set up test pack------------------- //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var testClass = (FakeTestClass)ConstructorTestHelper.ConstructObject(typeof(FakeTestClass), "allFakes"); //---------------Test Result ----------------------- testClass.Should().NotBeNull(); testClass.FakeList.Should().BeNullOrEmpty(); }
public void ConstructObject_GivenType_ShouldNotThrowExceptionAndConstructObject() { //---------------Set up test pack------------------- FakeTestClass testClass = null; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- Assert.DoesNotThrow(() => testClass = (FakeTestClass)ConstructorTestHelper.ConstructObject(typeof(FakeTestClass))); //---------------Test Result ----------------------- testClass.Should().NotBeNull(); }
public void ConstructObject_GivenTypeAndParameterAndValue_ShouldConstructObjectWithExpectedValue() { //---------------Set up test pack------------------- var parameterValue = "FakeTestName"; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var testClass = (FakeTestClass)ConstructorTestHelper.ConstructObject(typeof(FakeTestClass), "testName", parameterValue); //---------------Test Result ----------------------- testClass.Should().NotBeNull(); testClass.Name.Should().Be(parameterValue); }
public void ConstructObject_GivenObjectWithMultipleConstructors_ShouldConstructUsingMatchingConstructor(string parameterName) { //---------------Set up test pack------------------- //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var exception = Assert.Throws <TargetInvocationException>(() => ConstructorTestHelper.ConstructObject <FakeTestClass3>(parameterName)); //---------------Test Result ----------------------- exception.Should().NotBeNull(); exception.InnerException.Should().BeOfType <ArgumentNullException>(); ((ArgumentNullException)exception.InnerException)?.ParamName.Should().Be(parameterName); }
public void ConstructObject_GivenException_ShouldConstructObjectAndNotThrowException() { //---------------Set up test pack------------------- //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- Assert.DoesNotThrow(() => { var fakeException = ConstructorTestHelper.ConstructObject <FakeException>(); //---------------Test Result ----------------------- fakeException.Should().NotBeNull(); }); }
public void ConstructObject_GivenGenericType_ShouldNotThrowExceptionAndConstructObjectWithValuesAsExpected(string propertyName, Type expectedType) { //---------------Set up test pack------------------- FakeTestClass testClass = null; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- Assert.DoesNotThrow(() => testClass = ConstructorTestHelper.ConstructObject <FakeTestClass>()); //---------------Test Result ----------------------- testClass.Should().NotBeNull(); var propertyValue = testClass.GetPropertyValue(propertyName); propertyValue.Should().NotBeNull(); propertyValue.Should().BeOfType(expectedType); }
public void ConstructObject_GivenParameterValues_ShouldConstructObjectWithParameterValues() { //---------------Set up test pack------------------- var testDateTime = DateTime.Now; var fakeComplex = new FakeComplex(); var parameterValues = new List <(string paramName, object paramValue)> { ("testDateTime", testDateTime), ("complexObject", fakeComplex) }; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var testClass = ConstructorTestHelper.ConstructObject <FakeTestClass>(constructorParams: parameterValues.ToArray()); //---------------Test Result ----------------------- testClass.TestDateTime.Should().BeSameDateAs(testDateTime); testClass.ComplexObject2.Should().Be(fakeComplex); }