예제 #1
0
        public static SomePersonalDataMessage Build()
        {
            var rnd         = ExternalRandomGenerator.Instance.NextRandomInteger;
            var primaryAddr = AddressMessage.Build();
            var data        = new SomePersonalDataMessage
            {
                ID                = Guid.NewGuid(),
                LegalName         = HumanName.Build(),
                RegistrationName  = HumanName.Build(),
                RegistrationDate  = DateTime.Now.AddDays(-23),
                Residence         = primaryAddr,
                Shipping          = primaryAddr,
                Billing           = primaryAddr,
                StageAccessCode   = new byte[32],
                SpeakerAccessCode = new byte[32],

                YearsInSchool  = (0 != (rnd & (1 << 29))) ? 10 : (int?)null,
                EducationGrade = (0 != (rnd & (1 << 28))) ? 230 : (int?)null,

                AssetsAtHand = 567000m,
                TotalDebt    = 2345m,
                CreditScale  = 0.02323d
            };

            return(data);
        }
예제 #2
0
        public static RPCMessage Build()
        {
            var rnd = ExternalRandomGenerator.Instance.NextRandomInteger;
            var msg = new RPCMessage
            {
                RequestID      = Guid.NewGuid(),
                TypeName       = NaturalTextGenerator.Generate(80),
                MethodName     = NaturalTextGenerator.Generate(30),
                MethodID       = rnd % 25,
                RemoteInstance = (0 != (rnd & (1 << 32)))  ? Guid.NewGuid() : (Guid?)null,

                RequiredReliability = (0 != (rnd & (1 << 31)))  ? rnd / 100d : (double?)null,
                WrapException       = (0 != (rnd & (1 << 30))),
                ElevatePermission   = (0 != (rnd & (1 << 29)))
            };

            msg.CallArguments = new object[ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, 6)];
            for (var i = 0; i < msg.CallArguments.Length; i++)
            {
                var r = ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, 4);
                if (r == 1)
                {
                    msg.CallArguments[i] = BankMsg.Build();
                }
                else if (r == 2)
                {
                    msg.CallArguments[i] = NaturalTextGenerator.Generate();
                }
                else if (r == 3)
                {
                    msg.CallArguments[i] = null;           //new byte[16]; Protobuf does not support byte[] via object[]
                }
                else
                {
                    msg.CallArguments[i] = AddressMessage.Build();
                }
            }

            return(msg);
        }