public void Test_SetRelationship_WhenHasValue_AndValueRegistered_ShouldSetToRegisteredValue() { //---------------Set up test pack------------------- var bo = new BOTestFactory(typeof(FakeBO)).CreateValidBusinessObject(); var relationship = bo.Relationships["NonCompulsoryRelationship"] as ISingleRelationship; var factory = new BOTestFactory <FakeBO>(); factory.SetRelationshipToValidValue(relationship); var expectedRelationshipValue = new RelatedFakeBo(); //---------------Assert Precondition---------------- Assert.IsNotNull(relationship); var origionalBO = relationship.GetRelatedObject(); Assert.IsNotNull(relationship.GetRelatedObject()); //---------------Execute Test ---------------------- factory.SetValueFor(fakeBO => fakeBO.NonCompulsoryRelationship, expectedRelationshipValue); factory.SetRelationshipToValidValue(relationship); var actualRelatedObject = relationship.GetRelatedObject(); //---------------Test Result ----------------------- Assert.IsNotNull(actualRelatedObject); Assert.AreSame(expectedRelationshipValue, actualRelatedObject); }
public void Test_SetDefaultValue_WhenProperty_ShouldReturnSetValue() { //---------------Set up test pack------------------- const string expectedPropValue = "SomeValue"; const string propName = "SomeProp"; var boWithRelFactory = new BOTestFactory(typeof(FakeBO)); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- boWithRelFactory.SetValueFor(propName, expectedPropValue); var actualValue = boWithRelFactory.GetValidPropValue(typeof(FakeBOWithRelationship), propName); //---------------Test Result ----------------------- Assert.AreSame(expectedPropValue, actualValue); }
public void Test_SetDefaultValue_WhenRelationship_ShouldCreateWithValueSet() { //---------------Set up test pack------------------- var relatedBO = new RelatedFakeBo(); var boWithRelFactory = new BOTestFactory(typeof(FakeBOWithRelationship)); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- boWithRelFactory.SetValueFor("SingleRelationship", relatedBO); var boWithRelationship = boWithRelFactory.CreateValidBusinessObject() as FakeBOWithRelationship; //---------------Test Result ----------------------- Assert.IsNotNull(boWithRelationship); Assert.AreSame(relatedBO, boWithRelationship.SingleRelationship); }