Beispiel #1
0
        public void Test_InjectionTarget_Serialization()
        {
            using (var app = new AzosApplication(null, BASE_CONF))
            {
                const string DATA = "lalala!";

                var target = new InjectionTarget_Root();
                target.Data = DATA;

                app.DependencyInjector.InjectInto(target);
                target.AssertInjectionCorrectness(app);

                using (var ms = new MemoryStream())
                {
                    var ser = new SlimSerializer();
                    ser.Serialize(ms, target);
                    ms.Position = 0;

                    var target2 = ser.Deserialize(ms) as InjectionTarget_Root;
                    Aver.IsNotNull(target2);           //we deserialized the instance

                    Aver.AreEqual(DATA, target2.Data); //the Data member got deserialized ok
                    Aver.AreNotSameRef(target.Data, target2.Data);
                    Aver.AreNotSameRef(DATA, target2.Data);

                    target2.AssertAllInjectionsNull();       //but all injections are transitive, hence are null
                    app.DependencyInjector.InjectInto(target2);
                    target2.AssertInjectionCorrectness(app); //and are re-hydrated again after InjectInto() call
                }
            }
        }
Beispiel #2
0
 public void Test_InjectionTarget_Root()
 {
     using (var app = new AzosApplication(null, BASE_CONF))
     {
         var target = new InjectionTarget_Root();
         app.DependencyInjector.InjectInto(target);
         target.AssertInjectionCorrectness(app);
     }
 }