public void GetAsync_WhenIdAndCancellationTokenIsPassedIn_ReturnsEntity()
        {
            // Arrange
            DateTime?startDate = new DateTime(2014, 10, 22);
            DateTime?endDate   = new DateTime(2014, 10, 29);

            _webFactory.RegisterResultForUri(
                string.Format("{0}/{1}/{2}?StartDate={3}&EndDate={4}", _cf.Uri.AbsoluteUri, _service.Route, _newGuid,
                              startDate.Value.Date.ToString("s"), endDate.Value.Date.ToString("s")),
                new Timesheet().ToJson());

            // Act, Assert
            Timesheet result =
                _service.GetAsync(_cf, _newGuid, startDate.Value, endDate.Value, null, new CancellationToken()).Result;

            Assert.IsNotNull(result);
        }
        public void GetAsync_WhenIdAndCancellationTokenIsPassedIn_ReturnsEntity()
        {
            // arrange
            DateTime?startDate = new DateTime(2014, 10, 22);
            DateTime?endDate   = new DateTime(2014, 10, 29);

            _mockProviderService
            .Given(string.Format("Given I have Timesheet data for the date range {0} to {1}", startDate, endDate))
            .UponReceiving(string.Format("A GET request for Timesheet data for the daternage {0} to {1}", startDate, endDate))
            .With(new ProviderServiceRequest
            {
                Method = HttpVerb.Get,
                Path   = string.Format("/accountright/{0}/{1}/{2}",
                                       _cfUid,
                                       _service.Route,
                                       _uid),
                Headers = new Dictionary <string, string>
                {
                    { "Authorization", "Bearer" },
                    { "Accept-Encoding", "gzip" },
                    { "User-Agent", ApiRequestHelper.UserAgent },
                    { "x-myobapi-key", "" },
                    { "x-myobapi-version", "v2" },
                    { "x-myobapi-cftoken", Convert.ToBase64String(Encoding.UTF8.GetBytes("Administrator:")) },
                },
                Query = string.Format("StartDate={0}&EndDate={1}",
                                      startDate.Value.Date.ToString("s"),
                                      endDate.Value.Date.ToString("s"))
            })
            .WillRespondWith(new ProviderServiceResponse
            {
                Status  = 200,
                Headers = new Dictionary <string, string>
                {
                    { "Content-Type", "application/json; charset=utf-8" }
                },
                Body =
                    new         //NOTE: Note the case sensitivity here, the body will be serialised as per the casing defined
                {
                    StartDate = startDate.Value.Date.ToString("s"),
                    EndDate   = endDate.Value.Date.ToString("s")
                }
            });


            // act
            var result = _service.GetAsync(_cf, _uid, startDate.Value, endDate.Value, new CompanyFileCredentials("Administrator", ""), new CancellationToken()).Result;

            // assert
            Assert.NotNull(result);

            _mockProviderService.VerifyInteractions();
        }