Example #1
0
        public void VerifyGetBillsByDay()
        {
            string expectedResult = "91";

            repositoryMock.Setup(repository =>
                                 repository.GetBillsByDate(It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <DateTime>())).Returns(expectedResult);

            Assert.AreEqual(91, service.GetBillsByDay("", 2017, 1, 1));

            //Verify method call
            repositoryMock.Verify(x => x.GetBillsByDate(It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <DateTime>()), Times.Once);
        }
Example #2
0
        /// <summary>
        /// Get the total bill of a provided month
        /// </summary>
        /// <param name="id">The id </param>
        /// <param name="year">The year</param>
        /// <param name="month">The mont</param>
        /// <returns>Count of bills in the month</returns>
        public int GetBillsByMonth(string id, int year, int month)
        {
            //Generate datetimes with the range according to the month
            DateTime start = new DateTime(year, month, 1);
            DateTime end   = start.AddMonths(1).AddDays(-1);

            //make a first try sending the whole month
            string serviceResponse = billyRepository.GetBillsByDate(id, start, end);

            RequestCount++;
            int bills = 0;

            //Check if is a number what we fetched
            if (!int.TryParse(serviceResponse, out bills))
            {
                //If it is not a number we now try fetching the data by fortnights
                bills = GetMonthlyBillsByFortnights(id, year, month);
            }

            return(bills);
        }