public void AddLinks(string propertyName, BaseEntity[] linkedEntities)
        {
            var adder = new EntityLinker ();

            foreach (var linkedEntity in linkedEntities) {
                adder.AddLink (this, propertyName, linkedEntity);
            }
        }
 public DataLinker(DataManagerSettings settings, DataReader reader, DataSaver saver, DataUpdater updater, DataChecker checker, EntityLinker linker)
 {
     Settings = settings;
     Linker = linker;
     Reader = reader;
     Saver = saver;
     Updater = updater;
     Checker = checker;
 }
        public void Test_AddLink_OneWay_SingleEntity()
        {
            var source = new ExampleReferenceSource ();
            var target = new ExampleReferenceTarget ();

            var adder = new EntityLinker ();

            adder.AddLink (source, "Target", target);

            //Assert.IsNotNull (source.Target, "Link failed.");
            //Assert.IsNotNull (target.Left, "Reverse link failed.");
        }
        // TODO: Remove if not needed
        //[Test]
        public void Test_AddLink_TwoWay_SingleEntity()
        {
            var invoice = new ExampleInvoice ();
            var invoiceItem = new ExampleInvoiceItem ();

            var adder = new EntityLinker ();

            adder.AddLink (invoice, "Right", invoiceItem);

            Assert.IsNotNull (invoice.Items, "Link failed.");
            Assert.AreEqual(1, invoice.Items.Length, "Link failed.");
            Assert.IsNotNull (invoiceItem.Invoice, "Reverse link failed.");
        }
        public void Test_RemoveEntityFromObject_Array()
        {
            var linker = new EntityLinker ();

            var entity = new ExampleInvoiceItem ();

            var obj = new ExampleInvoiceItem[]{entity};

            var propertyInfo = typeof(ExampleInvoice).GetProperty ("Items");

            var newObj = linker.RemoveEntityFromObject (entity, obj, propertyInfo);

            Assert.IsNotNull (newObj);
            Assert.AreEqual (0, ((ExampleInvoiceItem[])newObj).Length);
        }
        public TestContext()
        {
            DataClient = new MockRedisClientWrapper ();

            Settings = new DataManagerSettings ();
            Settings.IsVerbose = true;

            Keys = new DataKeys (Settings);

            IdManager = new DataIdManager (Keys, DataClient);
            TypeManager = new DataTypeManager (Keys, DataClient);

            EntityLinker = new EntityLinker ();

            var preparer = new DataPreparer (DataClient);
            Preparer = preparer;

            var reader = new DataReader (TypeManager, IdManager, Keys, DataClient);
            Reader = reader;

            var checker = new DataChecker (reader, Settings);
            Checker = checker;

            var saver = new DataSaver (Settings, TypeManager, IdManager, Keys, preparer, null, checker, DataClient); // The linker argument is null because it needs to be set after it's created below
            Saver = saver;

            var updater = new DataUpdater (Settings, Keys, null, preparer, checker, DataClient); // The linker argument is null because it needs to be set after it's created below
            Updater = updater;

            var linker = new DataLinker (Settings, reader, saver, updater, checker, EntityLinker);
            Linker = linker;

            // TODO: Is there a way to avoid this messy hack?
            // Make sure the linker is set to the saver and updater
            saver.Linker = linker;
            updater.Linker = linker;
        }
 public MockDataLinker(DataManagerSettings settings, DataReader reader, DataSaver saver, DataUpdater updater, DataChecker checker, EntityLinker entityLinker)
     : base(settings, reader, saver, updater, checker, entityLinker)
 {
 }
        public void AddLink(string propertyName, BaseEntity linkedEntity)
        {
            var adder = new EntityLinker ();

            adder.AddLink (this, propertyName, linkedEntity);
        }