예제 #1
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);
        }
예제 #2
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);
        }
예제 #3
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);
        }
예제 #4
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");
        }
예제 #5
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);
        }
예제 #6
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);
        }
예제 #7
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);
        }