コード例 #1
0
        public void Execute_ConfigurationNotSet_ThrowsException()
        {
            //Assign
            var target = new object();
            var savingContext = Substitute.For<AbstractTypeSavingContext>();
            var service = Substitute.For<IAbstractService>();
            var args = new ObjectSavingArgs(null, target, savingContext, service);
            var task = new StandardSavingTask();


            //Act
            task.Execute(args);

            //Assert

        }
コード例 #2
0
        public void Execute_RunnerCorrectlyConfigured_CallsEachDataMapper()
        {
            //Assign
            var target = new Stub();
            var savingContext = Substitute.For<AbstractTypeSavingContext>();
            var service = Substitute.For<IAbstractService>();
            var args = new ObjectSavingArgs(null, target, savingContext, service);
            var task = new StandardSavingTask();

            var dataContext = Substitute.For<AbstractDataMappingContext>(target);
            service.CreateDataMappingContext(savingContext).Returns(dataContext);

            var property1 = Substitute.For<AbstractPropertyConfiguration>();
            var config1 = Substitute.For<AbstractPropertyConfiguration>();
            var mapper1 = new StubMapper();

            property1.Mapper = mapper1;
            config1.PropertyInfo = typeof (Stub).GetProperty("Property");
            property1.PropertyInfo = config1.PropertyInfo;
            mapper1.Setup(new DataMapperResolverArgs(null, config1));

            var property2 = Substitute.For<AbstractPropertyConfiguration>();
            var config2 = Substitute.For<AbstractPropertyConfiguration>();
            var mapper2 = new StubMapper();

            property2.Mapper = mapper2;
            config2.PropertyInfo = typeof (Stub).GetProperty("Property2");
            property2.PropertyInfo = config2.PropertyInfo;
            mapper2.Setup(new DataMapperResolverArgs(null, config2));

            savingContext.Config = new AttributeConfigurationLoaderFixture.StubTypeConfiguration();
            savingContext.Config.AddProperty(property1);
            savingContext.Config.AddProperty(property2);

            //Act
            task.Execute(args);

            //Assert
            Assert.IsTrue(mapper1.MapCalled);
            Assert.IsTrue(mapper2.MapCalled);
        }
コード例 #3
0
 /// <summary>
 /// Saves the object.
 /// </summary>
 /// <param name="abstractTypeSavingContext">The abstract type saving context.</param>
 public virtual void SaveObject(AbstractTypeSavingContext abstractTypeSavingContext)
 {
     //Run the object construction
     var savingArgs = new ObjectSavingArgs(GlassContext, abstractTypeSavingContext.Object, abstractTypeSavingContext, this);
     _objectSaving.Run(savingArgs);
 }