Beispiel #1
0
        public void can_return_default_entity_if_not_found()
        {
            var repo = new XpoRepository(Xpo.UnitOfWork());
            var item = repo.GetAndDefaultIfNotFound <XpoTestEntity, NullXpoTestEntity>(x => x.Name == "ShouldntExist");

            Assert.That(item is NullXpoTestEntity);
        }
Beispiel #2
0
        public void can_postpone_delete_until_batch_is_complete()
        {
            // Create test record
            XpoTestEntity entity = Xpo.CreateXPObject <XpoTestEntity>();

            entity.Name = "Test";
            entity.Type = "Test";

            IUnitOfWork uow = entity.Session;

            uow.Commit();

            // Get test record
            XpoTestEntity persistedEntity = uow.FindObject <XpoTestEntity>("Name='Test'");

            // Postpone Delete
            uow.Delete(persistedEntity, false);

            // Persist
            uow.Commit();

            XpoTestEntity deletedEntity = uow.FindObject <XpoTestEntity>("Name='Test'");

            Assert.IsNull(deletedEntity);
        }
Beispiel #3
0
        public void when_initialiazing_defaults_on_a_sales_line_item_a_default_schedule_should_be_created()
        {
            var sli = Xpo.CreateXPObject <SalesLineItem>();

            sli.CreateDefaults();

            Assert.IsTrue(sli.GetDefaultSchedule() != null);
        }
Beispiel #4
0
        public void when_setting_the_qty_of_a_line_item_the_default_schedule_should_get_set_to_the_new_qty()
        {
            var sli = Xpo.CreateXPObject <SalesLineItem>();

            sli.CreateDefaults();

            sli.Quantity = 22;

            Assert.IsTrue(sli.GetDefaultSchedule().Qty == 22);
        }
Beispiel #5
0
        public void can_create_entity_if_not_found()
        {
            var repo = new XpoRepository(Xpo.UnitOfWork());
            var item = repo.GetAndCreateIfNotFound <XpoTestEntity>
                           (i => i.Name == "ShouldntExist", d =>
            {
                d.Name = "New";
                d.Type = "XpoTestEntity";
            });

            Assert.That(item != null && item.Name == "New");
        }
Beispiel #6
0
        public void can_save_to_repository()
        {
            var repo   = new XpoRepository(Xpo.UnitOfWork());
            var entity = repo.Create <XpoTestEntity>();

            entity.Name = "Test";
            entity.Type = "test";

            repo.Save();

            var repoItem = repo.Get <XpoTestEntity>(i => i.Name == "Test");

            Assert.IsNotNull(repoItem);
        }
Beispiel #7
0
        public void can_get_the_value_of_a_property_by_name()
        {
            PartAttributesHeader header =
                Xpo.CreateXPObject <PartAttributesHeader>();

            header.Attr1 = "Firmware";
            header.Attr2 = "MSR";

            Assert.AreEqual(Reflection.GetPropertyValue(header, "Attr1"),
                            "Firmware");

            Assert.AreEqual(Reflection.GetPropertyValue(header, "Attr2"),
                            "MSR");
        }
Beispiel #8
0
        public void can_save_to_repository()
        {
            XpoTestEntity entity = Xpo.CreateXPObject <XpoTestEntity>();

            entity.Name = "Test";
            entity.Type = "Test";

            IUnitOfWork uow = entity.Session;

            uow.Commit();

            XpoTestEntity persistedEntity =
                uow.FindObject <XpoTestEntity>("Name='Test'");

            Assert.IsNotNull(persistedEntity);
        }
Beispiel #9
0
        //[Test]
        public void test()
        {
            var part           = Xpo.CreateXPObject <Fakes.FakePart>();
            var consumableItem = Xpo.CreateXPObject <MaterialConsumableItem>();
            var sfl            = Xpo.CreateXPObject <Shopfloorline>();

            consumableItem.Part          = part;
            consumableItem.Qty           = 10;
            consumableItem.Shopfloorline = sfl;

            m_unitOfWork = Xpo.UnitOfWork();
            m_repository = new XpoRepository(m_unitOfWork);
            m_repository.Create <MaterialConsumableItem>();

            m_repository.Save();

            var inventory = new ServiceMaterialsInventoryController(m_unitOfWork, m_repository);
            var transId   = inventory.Consume("FAKE", 1, 1, "Repair", "");

            var item = m_repository.Find <MaterialConsumableItem>().FirstOrDefault(mci => mci.Part == part);

            Assert.That(item.Qty == 9);
        }
Beispiel #10
0
        public void can_delete_from_repository()
        {
            XpoTestEntity entity = Xpo.CreateXPObject <XpoTestEntity>();

            entity.Name = "Test";
            entity.Type = "Test";

            IUnitOfWork uow = entity.Session;

            uow.Commit();

            XpoTestEntity persistedEntity = uow.FindObject <XpoTestEntity>("Name='Test'");

            if (persistedEntity == null)
            {
                throw new NullReferenceException("XpoTestEntity has not been persisted to the in memory database.");
            }

            uow.Delete(persistedEntity, true);

            XpoTestEntity deletedEntity = uow.FindObject <XpoTestEntity>("Name='Test'");

            Assert.IsNull(deletedEntity);
        }
 public void teardown()
 {
     Xpo.Destroy();
 }
 public void setup()
 {
     m_unitOfWork = Xpo.UnitOfWork();
 }
Beispiel #13
0
 public void TearDown()
 {
     Xpo.Destroy();
 }
Beispiel #14
0
 public T CreateEntity <T>(IUnitOfWork uow)
 {
     return(Reflection.CreateInstanceOfType <T>(Xpo.UnitOfWork()));
 }
Beispiel #15
0
 public XpoUnitOfWork GetUnitOfWork()
 {
     return(Xpo.UnitOfWork());
 }
Beispiel #16
0
 public void SetUp()
 {
     m_uow = Xpo.UnitOfWork();
 }