Esempio n. 1
0
        public void Response200Address()
        {
            var user    = DefaultConfig.FirstUser;
            var address = new AddressMessage
            {
                Uuid         = DefaultConfig.AddressUuid,
                AddressAlias = "updated_address",
            };
            var response = api.UpdateAddress(user.UserHandle, user.PrivateKey, address);

            Assert.AreEqual(200, response.StatusCode);
            var parsedResponse = (AddressResponse)response.Data;

            Assert.IsTrue(parsedResponse.Success);
            Assert.AreEqual("SUCCESS", parsedResponse.Status);
            Assert.IsNotNull(parsedResponse.Address);
            Assert.IsNotNull(parsedResponse.Address.AddedEpoch);
            Assert.IsNotNull(parsedResponse.Address.ModifiedEpoch);
            Assert.AreEqual(address.Uuid, parsedResponse.Address.Uuid);
            Assert.AreEqual(address.AddressAlias, parsedResponse.Address.Nickname);
            Assert.IsNotNull(parsedResponse.Address.StreetAddress1);
            Assert.IsNotNull(parsedResponse.Address.StreetAddress2);
            Assert.IsNotNull(parsedResponse.Address.City);
            Assert.IsNotNull(parsedResponse.Address.State);
            Assert.IsNotNull(parsedResponse.Address.Country);
            Assert.IsNotNull(parsedResponse.Address.PostalCode);
        }
Esempio n. 2
0
        public void Response200Address()
        {
            var user    = DefaultConfig.FirstUser;
            var address = new AddressMessage
            {
                AddressAlias   = "new_address",
                StreetAddress1 = "324 songbird avenue",
                StreetAddress2 = "apt. 132",
                City           = "portland",
                State          = "va",
                PostalCode     = "12345",
                Country        = "US"
            };
            var response = api.AddAddress(user.UserHandle, user.PrivateKey, address);

            Assert.AreEqual(200, response.StatusCode);
            var parsedResponse = (AddressResponse)response.Data;

            Assert.IsTrue(parsedResponse.Success);
            Assert.AreEqual("SUCCESS", parsedResponse.Status);
            Assert.IsNotNull(parsedResponse.Address);
            Assert.IsNotNull(parsedResponse.Address.AddedEpoch);
            Assert.IsNotNull(parsedResponse.Address.ModifiedEpoch);
            Assert.IsNotNull(parsedResponse.Address.Uuid);
            Assert.AreEqual(address.AddressAlias, parsedResponse.Address.Nickname);
            Assert.AreEqual(address.StreetAddress1, parsedResponse.Address.StreetAddress1);
            Assert.AreEqual(address.StreetAddress2, parsedResponse.Address.StreetAddress2);
            Assert.AreEqual(address.City, parsedResponse.Address.City);
            Assert.AreEqual(address.State, parsedResponse.Address.State);
            Assert.AreEqual(address.Country, parsedResponse.Address.Country);
            Assert.AreEqual(address.PostalCode, parsedResponse.Address.PostalCode);

            DefaultConfig.AddressUuid = parsedResponse.Address.Uuid;
        }
Esempio n. 3
0
        public void ShouldQueryForRecord()
        {
            AddressMessage message = new AddressMessage(
                "street-address-1",
                "street-address-2",
                "street-address-3",
                "suburb", "1234",
                "state",
                "country");

            propertyCreatorService.FindExactByAddress(message);
            repo.Verify(m => m.Query <PropertySale>(It.IsAny <string>(), It.IsAny <object>()));
        }
Esempio n. 4
0
        // ERM выдаёт несколько ошибок по адресам фирм, мы их схлапываем в одну (самую важную)
        // Согласовано с Антоном
        private static IEnumerable <ErmOrderValidationMessage> FormatLinkingObjectsOrderValidationRule(IReadOnlyCollection <ErmOrderValidationMessage> messages)
        {
            const int LinkingObjectsOrderValidationRule = 12;
            var       parser = new AddressMessage();

            var competitors = messages.Where(x => x.RuleCode == LinkingObjectsOrderValidationRule && parser.IsSupported(x.MessageText)).ToList();
            var winners     = competitors
                              .GroupBy(x => new { x.TargetEntityTypeCode, x.TargetEntityId, Address = parser.GetParams(x.MessageText) }, x => x)
                              .Select(x => x.OrderBy(y => parser.GetPriority(y.MessageText)).First());

            return(messages
                   .Except(competitors)
                   .Concat(winners));
        }
Esempio n. 5
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            var message = new AddressMessage {
                                             Address1 = "121 Somewhere St",
                                             Address2 = "Suite 500",
                                             City = "Cicero",
                                             State = "NY",
                                             Zip = "13090-4005"
                                          };
             _addressBindingSource.SuspendBinding();
             _addressBindingSource.DataSource = message;
             _addressBindingSource.ResumeBinding();

             _addressControl.LoadAddressFromMessage(message);
        }
Esempio n. 6
0
        public void ShouldBuildQueryForNullDetails()
        {
            AddressMessage message = new AddressMessage(
                "street-address-1",
                null,
                null,
                "suburb", "1234",
                "state",
                "country");

            propertyCreatorService.FindExactByAddress(message);

            sqlBuilder.Verify(s => s.AddClause("StreetAddress1", "eq", message.StreetAddress1));
            sqlBuilder.Verify(s => s.AddClause("StreetAddress2", It.IsAny <string>(), It.IsAny <object>()), Times.Never);
            sqlBuilder.Verify(s => s.AddClause("StreetAddress3", It.IsAny <string>(), It.IsAny <object>()), Times.Never);
            sqlBuilder.Verify(s => s.AddClause("Suburb", "eq", message.Suburb));
            sqlBuilder.Verify(s => s.AddClause("PostCode", "eq", message.PostCode));
            sqlBuilder.Verify(s => s.AddClause("State", "eq", message.State));
            sqlBuilder.Verify(s => s.AddClause("Country", "eq", message.Country));
        }
Esempio n. 7
0
        public void ShouldBuildQueryForAllDetails()
        {
            AddressMessage message = new AddressMessage(
                "street-address-1",
                "street-address-2",
                "street-address-3",
                "suburb", "1234",
                "state",
                "country");

            propertyCreatorService.FindExactByAddress(message);

            sqlBuilder.Verify(s => s.AddClause("StreetAddress1", "eq", message.StreetAddress1));
            sqlBuilder.Verify(s => s.AddClause("StreetAddress2", "eq", message.StreetAddress2));
            sqlBuilder.Verify(s => s.AddClause("StreetAddress3", "eq", message.StreetAddress3));
            sqlBuilder.Verify(s => s.AddClause("Suburb", "eq", message.Suburb));
            sqlBuilder.Verify(s => s.AddClause("PostCode", "eq", message.PostCode));
            sqlBuilder.Verify(s => s.AddClause("State", "eq", message.State));
            sqlBuilder.Verify(s => s.AddClause("Country", "eq", message.Country));
        }
            public static RPCMessage Generate()
            {
                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))),
                    CallArguments       = new object[ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, 6)]
                };

                for (var i = 0; i < msg.CallArguments.Length; i++)
                {
                    var r = ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, 4);
                    switch (r)
                    {
                    case 1:
                        msg.CallArguments[i] = BankMsg.Generate();
                        break;

                    case 2:
                        msg.CallArguments[i] = NaturalTextGenerator.Generate();
                        break;

                    case 3:
                        msg.CallArguments[i] = null;     //new byte[16]; Protobuf does not support byte via object
                        break;

                    default:
                        msg.CallArguments[i] = AddressMessage.Build();
                        break;
                    }
                }

                return(msg);
            }
Esempio n. 9
0
        /// <summary>
        /// 添加联系人
        /// </summary>
        /// <param name="address">Address message.</param>
        /// <param name="callback">Callback.</param>
        public static void addContact(AddressMessage address, Action <ContactResponseModel> callback)
        {
            string     route    = "connector.connectHandler.addContact";
            JsonObject userData = new JsonObject();

            userData.Add("userId", LocalDataModel.userId);
            userData.Add("sex", address.sex);
            userData.Add("nickName", address.nickName);
            userData.Add("tel", address.tel);
            userData.Add("email", address.email);
            userData.Add("types", address.types);
            userData.Add("remarks", address.remarks);

            ServiceUser.getInstance().request(route, userData, (JsonObject obj) =>
            {
                ContactResponseModel contactModel = new ContactResponseModel(obj);
                if (callback != null)
                {
                    callback(contactModel);
                }
            });
        }
Esempio n. 10
0
        /// <summary>
        /// 修改联系人
        /// </summary>
        /// <param name="address">Address message.</param>
        /// <param name="callback">Callback.</param>
        public static void updateContact(AddressMessage address, Action <BaseResponse> callback)
        {
            string     route    = "connector.connectHandler.updateContact";
            JsonObject userData = new JsonObject();

            userData.Add("userId", LocalDataModel.userId);
            userData.Add("contactId", MainMenuController.Instance.selectId);
            userData.Add("sex", address.sex);
            userData.Add("nickName", address.nickName);
            userData.Add("tel", address.tel);
            userData.Add("email", address.email);
            userData.Add("newTypes", address.newType);
            userData.Add("deleteTypes", address.deleteType);
            userData.Add("remarks", address.remarks);

            ServiceUser.getInstance().request(route, userData, (JsonObject obj) =>
            {
                BaseResponse responseModel = new BaseResponse(obj);
                if (callback != null)
                {
                    callback(responseModel);
                }
            });
        }
            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);
            }
 public PropertySale FindExactByAddress(AddressMessage message)
 {
     return(null);
 }
Esempio n. 13
0
            public async Task StartMessageListener()
            {
                try
                {
                    while (true)
                    {
                        await ReadMessage(Cancellation.Token);

                        string.Format(
                            "{0} received message {1}",
                            GetID(),
                            Command)
                        .Log(LogFile);

                        switch (Command)
                        {
                        case "ping":
                            await SendMessage(new PongMessage(
                                                  BitConverter.ToUInt64(Payload, 0)));

                            break;

                        case "addr":
                            AddressMessage addressMessage =
                                new AddressMessage(Payload);
                            break;

                        case "sendheaders":
                            await SendMessage(new SendHeadersMessage());

                            break;

                        case "feefilter":
                            FeeFilterMessage feeFilterMessage =
                                new FeeFilterMessage(Payload);
                            FeeFilterValue = feeFilterMessage.FeeFilterValue;
                            break;

                        case "block":

                            byte[] blockBytes = Payload
                                                .Take(PayloadLength)
                                                .ToArray();

                            Block block = ParserToken.ParseBlock(blockBytes);

                            if (IsStateIdle())
                            {
                                string.Format(
                                    "{0}: Receives unsolicited block {1}.",
                                    GetID(),
                                    block.Header.Hash.ToHexString())
                                .Log(LogFile);

                                Console.Beep();

                                if (!Blockchain.TryLock())
                                {
                                    break;
                                }

                                try
                                {
                                    ProcessHeaderUnsolicited(
                                        block.Header,
                                        out bool flagHeaderExtendsChain);

                                    if (flagHeaderExtendsChain)
                                    {
                                        if (!Blockchain.TryInsertBlock(
                                                block,
                                                flagValidateHeader: true))
                                        {
                                            // Blockchain insert sollte doch einfach Ex. schmeissen
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Blockchain.ReleaseLock();

                                    throw ex;
                                }

                                Blockchain.ReleaseLock();
                            }
                            else if (IsStateAwaitingBlockDownload())
                            {
                                BlockDownload.InsertBlock(block);

                                if (BlockDownload.IsDownloadCompleted)
                                {
                                    SignalProtocolTaskCompleted.Post(true);

                                    lock (LOCK_StateProtocol)
                                    {
                                        State = StateProtocol.IDLE;
                                    }

                                    break;
                                }

                                Cancellation.CancelAfter(
                                    TIMEOUT_RESPONSE_MILLISECONDS);
                            }

                            break;

                        case "headers":

                            Header header = null;
                            int    index  = 0;

                            int countHeaders = VarInt.GetInt32(
                                Payload,
                                ref index);

                            string.Format(
                                "{0}: Receiving {1} headers.",
                                GetID(),
                                countHeaders)
                            .Log(LogFile);

                            if (IsStateIdle())
                            {
                                header = Token.ParseHeader(
                                    Payload,
                                    ref index);

                                string.Format(
                                    "Received unsolicited header {0}",
                                    header.Hash.ToHexString())
                                .Log(LogFile);

                                index += 1;

                                if (!Blockchain.TryLock())
                                {
                                    break;
                                }

                                try
                                {
                                    ProcessHeaderUnsolicited(
                                        header,
                                        out bool flagHeaderExtendsChain);

                                    if (flagHeaderExtendsChain)
                                    {
                                        List <Inventory> inventories = new()
                                        {
                                            new Inventory(
                                                InventoryType.MSG_BLOCK,
                                                header.Hash)
                                        };

                                        SendMessage(new GetDataMessage(inventories));
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Blockchain.ReleaseLock();

                                    throw ex;
                                }

                                Blockchain.ReleaseLock();
                            }
                            else if (IsStateGetHeaders())
                            {
                                if (countHeaders > 0)
                                {
                                    while (index < PayloadLength)
                                    {
                                        header = Token.ParseHeader(
                                            Payload,
                                            ref index);

                                        index += 1;

                                        HeaderDownload.InsertHeader(header, Token);
                                    }
                                }

                                SignalProtocolTaskCompleted.Post(true);
                            }

                            break;

                        case "notfound":

                            Debug.WriteLine(
                                "Command notfound not implemented yet.");

                            break;

                        case "inv":

                            var invMessage = new InvMessage(Payload);

                            var getDataMessage = new GetDataMessage(
                                invMessage.Inventories);

                            break;

                        case "getdata":

                            getDataMessage = new GetDataMessage(Payload);

                            foreach (Inventory inventory in getDataMessage.Inventories)
                            {
                                if (inventory.Type == InventoryType.MSG_TX)
                                {
                                    if (Token.TryRequestTX(
                                            inventory.Hash,
                                            out byte[] tXRaw))