public void GetValue_ShouldReturnValueOfProperty()
        {
            var expected = "Expected";
            var entity = new SimpleTestEntity(){ StringProperty = expected};

            var setter = new PropertyPropertySetter(StringProperty);

            Assert.Equal(expected, setter.GetValue(entity));
        }
        public void RegisterFactoryFunction_ShouldAddMethodThatTakesNoParameters()
        {
            var expected = new SimpleTestEntity();
            var col = new EntityFactoryFunctionCollection();
            col.RegisterFactoryFunction(() => expected);

            var factoryFunction = col.GetFactoryFunction<SimpleTestEntity>();

            Assert.Same(expected, factoryFunction(null));
        }
 public FactoryTests_PropertySetting_WhenCreatedWithDefaultCtor()
 {
     factory = new Factory();
     entity = factory.Create<SimpleTestEntity>();
 }
Exemplo n.º 4
0
        public void CreateNew_ShouldUseRegisteredFactoryFunction()
        {
            var expectedEntity = new SimpleTestEntity();
            var factory = new Factory();
            factory.Entities.RegisterFactoryFunction(() => expectedEntity);

            var entity = factory.Create<SimpleTestEntity>();

            Assert.Same(expectedEntity, entity);
        }
        public void SetValue_ShouldApplyValueToInstance()
        {
            var entity = new SimpleTestEntity();

            var setter = new PropertyPropertySetter(StringProperty);

            setter.SetValue(entity, "Test Value");

            Assert.Equal("Test Value", entity.StringProperty);
        }