Exemplo n.º 1
0
        public void Can_execute_command_methods()
        {
            var test = new TestHelper();

            var related = new xts_relatedentity {
                Id = Guid.NewGuid()
            };

            related.Set(e => e.xts_name, "RELATED");

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

            reference.Set(e => e.xts_optionsetvalue, 12);
            reference.Set(e => e.xts_int, 345);
            reference.Set(e => e.xts_string, "PARENT");
            reference.Set(e => e.xts_referenceid, related.ToEntityReference());
            reference.Set(e => e.xts_money, new Money(1234m));

            reference.SetFormattedValue(e => e.xts_attribute, "Hello Formatted Value");
            reference.SetFormattedValue("xts_anotherattribute", "1234-another-fv");

            var child = new xts_relatedentity {
                Id = Guid.NewGuid()
            };

            child.Set(e => e.xts_name, "CHILD");
            child.Set(e => e.xts_relatedid, reference.ToEntityReference());

            test.Service.Retrieve(Arg.Any <string>(), Arg.Is <Guid>(id => id == related.Id), Arg.Any <ColumnSet>())
            .Returns(related);
            test.Service.Retrieve(Arg.Any <string>(), Arg.Is <Guid>(id => id == child.Id), Arg.Any <ColumnSet>())
            .Returns(child);
            test.Service.RetrieveMultiple(Arg.Any <QueryBase>()).Returns(new EntityCollection(new List <Entity> {
                child
            }));

            var context = Substitute.For <ITransactionContext <xts_entity> >();

            context.Service.Returns(test.Service);
            var txReference = new TransactionContextEntity <xts_entity>(reference);

            context.Current.Returns(txReference);

            var commandTest = new CommandTest(context);

            commandTest.ExecuteTest();

            IEntityWrapperRelation <xts_entity> wrapper = commandTest;

            var relatedColumnSet = new ColumnSet <xts_relatedentity>(
                e => e.Id,
                e => e.xts_name
                );

            var relatedGeneric = wrapper.GetRelated(e => e.xts_referenceid, relatedColumnSet);

            Assert.Equal("RELATED", relatedGeneric.Get(e => e.xts_name));
        }
Exemplo n.º 2
0
 public static IEntityWrapper <xts_derivedentity> GetProduct(
     this IEntityWrapperRelation <xts_relatedentity> relation, IColumnSet <xts_derivedentity> columnSet)
 {
     return(relation.GetRelated(e => e.xts_relatedid, columnSet));
 }
Exemplo n.º 3
0
 public static IEntityWrapper <xts_relatedentity> GetReference(
     this IEntityWrapperRelation <xts_entity> relation, IColumnSet <xts_relatedentity> columnSet)
 {
     return(relation.GetRelated(e => e.xts_referenceid, columnSet));
 }