public void Can_get_name()
        {
            var keyEntity = new xts_keytest {
                Id = Guid.NewGuid()
            };

            keyEntity.Set(e => e.xts_key, "Hello world");

            var service = Substitute.For <IOrganizationService>();

            service.Retrieve(Arg.Is <string>(name => name == "xts_keytest"), Arg.Any <Guid>(), Arg.Any <ColumnSet>())
            .Returns(keyEntity);

            var context = Substitute.For <ITransactionContextBase>();

            context.Service.Returns(service);

            var entity = new xts_entity {
                Id = Guid.NewGuid()
            };

            entity.Set(e => e.xts_referenceid, keyEntity.ToEntityReference());
            var wrapper = new EntityWrapper <xts_entity>(entity, context);

            Assert.Equal("Hello world", wrapper.GetReferenceName <xts_keytest>(e => e.xts_referenceid));
        }
示例#2
0
        public void Can_get_name()
        {
            var test      = new TestHelper();
            var keyEntity = new xts_keytest {
                Id = Guid.NewGuid()
            };

            keyEntity.Set(e => e.xts_key, "Hello world");
            test.Service.Retrieve(Arg.Is <string>(name => name == "xts_keytest"), Arg.Any <Guid>(), Arg.Any <ColumnSet>())
            .Returns(keyEntity);

            var entity = new xts_entity {
                Id = Guid.NewGuid()
            };

            entity.Set(e => e.xts_referenceid, keyEntity.ToEntityReference());
            var context = Substitute.For <ITransactionContext <xts_entity> >();

            context.Service.Returns(test.Service);
            context.Current.Returns(new TransactionContextEntity <xts_entity>(entity));

            var command = new CommandTest(context);

            Assert.Equal("Hello world", command.GetNameTest <xts_keytest>(e => e.xts_referenceid));
        }