public void ShouldLoadLazyObjects3() { var content = @"Discriminator,Engine NonVirtualCar,{new Gears.Interpreter.Tests.Pages.Iteration5Tests.Engine(){Power=5}} NonVirtualApple,ApplesDontHaveEngines "; var path = _inputFolder + "\\Scenario4.csv"; File.WriteAllText(path, content); Bootstrapper.Register(); ServiceLocator.Instance.Resolve <ITypeRegistry>().Register(typeof(NonVirtualCar)); ServiceLocator.Instance.Resolve <ITypeRegistry>().Register(typeof(NonVirtualApple)); var apple = new FileObjectAccess(path, ServiceLocator.Instance.Resolve <ITypeRegistry>()).GetAll().Last(); Assert.IsInstanceOf <NonVirtualApple>(apple, apple.ToString()); Assert.IsFalse(apple.GetType().Name.ToLower().Contains("proxy")); Assert.AreEqual("ApplesDontHaveEngines", (apple as NonVirtualApple).Engine); var obj = new FileObjectAccess(path, ServiceLocator.Instance.Resolve <ITypeRegistry>()).GetAll().First(); Assert.IsInstanceOf <CorruptObject>(obj, obj.ToString()); var car = obj as CorruptObject; Assert.IsTrue(car.Exception.Message.Contains("virtual")); }
public void ShouldLoadLazyObjects() { var codeStub = "{Generate.Word()}"; var content = $"Discriminator,FruitName\nTree,{codeStub}\n"; var path = _inputFolder + "\\Scenario3.csv"; File.WriteAllText(path, content); Bootstrapper.Register(); ServiceLocator.Instance.Resolve <ITypeRegistry>().Register(typeof(Tree)); var tree = new FileObjectAccess(path, ServiceLocator.Instance.Resolve <ITypeRegistry>()).Get <Tree>(); Assert.IsNotNull(tree); Assert.IsTrue(tree.GetType().Name.ToLower().Contains("proxy")); Assert.IsNotNull(codeStub, tree.FruitName); Assert.AreNotEqual(codeStub, tree.FruitName); }