public void EqualityOperator_AttributesCorrectness()
        {
            var number = "1234";

            var debt1 = new FindDebts()
            {
                Number = number
            };
            var debt2 = new FindDebts()
            {
                Number = number
            };

            var attributes = new Dictionary <string, string>();

            debt1.Attributes = attributes;
            debt2.Attributes = attributes;
            Assert.True(debt1 == debt2);

            attributes["a"]  = "b";
            debt1.Attributes = attributes;
            debt2.Attributes = attributes;
            Assert.True(debt1 == debt2);


            attributes["a"]  = "0";
            debt2.Attributes = attributes;
            Assert.False(debt1 == debt2);

            attributes.Clear();
            debt2.Attributes = attributes;
            Assert.False(debt1 == debt2);
        }
Beispiel #2
0
        public async Task GetFindDebts_correct()
        {
            var replyDebts = new List <Debt>
            {
                ModelBuilder.BuildReplyDebtBuilder("1", "10").BuildModel <Debt>(),
                ModelBuilder.BuildReplyDebtBuilder("2", "20").BuildModel <Debt>()
            };

            var replyJson = ModelBuilder.ToJson(replyDebts);

            var findDebts = new FindDebts
            {
                Number     = "123",
                ToDate     = new DateTime(2010, 1, 1),
                FromDate   = null,
                Attributes = new Dictionary <string, string>()
                {
                    { "a", "bxy" }
                }
            };
            var expectedQueryParams = new List <string> {
                "123", "number", "to_date", "2010-01-01", "from_date", WebUtility.UrlEncode("attributes[a]"), "bxy"
            };

            var ic = ConfigureIc("GET", "debts/find", replyJson, null, expectedQueryParams);

            var result = await ic.GetFindDebtsAsync(findDebts);

            for (var i = 0; i < replyDebts.Count; i++)
            {
                Assert.AreEqual(replyDebts[i], result[i]);
            }
        }
        public void GetSendableStringDictionary_correct()
        {
            var findDebts = new FindDebts
            {
                Number     = "123",
                ToDate     = new DateTime(2010, 1, 1),
                FromDate   = null,
                Attributes = new Dictionary <string, string>()
                {
                    { "a", "b" },
                    { "1", "2" }
                }
            };


            var dictionary = findDebts.SendableStringDictionary;

            TestingUtils.AssertDictionaryContainsItems(dictionary,
                                                       ("number", "123"),
                                                       ("to_date", "2010-01-01"),
                                                       ("from_date", ""),
                                                       ("attributes[a]", "b"),
                                                       ("attributes[1]", "2")
                                                       );
        }
        /// <summary>
        ///     Get the debts that math the search query
        /// </summary>
        /// <param name="findDebts">the search query</param>
        /// <returns>the debts list</returns>
        /// <exception cref="IcException">
        ///     On bad json (received) and when the server rejects the request (conflict, bad
        ///     request, invalid parameters, etc)
        /// </exception>
        /// <exception cref="HttpRequestException">
        ///     On connection or protocol related errors (except for the protocol errors sent by the
        ///     Invisible Collector)
        /// </exception>
        public async Task <IList <Debt> > GetFindDebtsAsync(FindDebts findDebts)
        {
            _logger.LogDebug("Making request to find debts with the following info: {Model}", findDebts);

            var ret = await MakeRequestAsync <List <Debt> >("GET", new[] { DebtsEndpoint, "find" }, findDebts.SendableStringDictionary);

            _logger.LogDebug("Received find result debts: {Models}", ret.StringifyList());
            return(ret);
        }