public void IntegrationTest_TrackViaClient_FindRecords_ShouldReturnListOfRecords()
        {
            TestHelper.EnsureProductionValuesBeforeRunningIntegrationTests(IntegrationTestConfig.TRACKVIA_VIEWID_DEMOSIMPLECRM_ACCOUNTSDEFAULTVIEW <= 0);

            // Assemble
            string searchCriteria = "A";
            int    startIndex     = 0;
            int    maxRecords     = 2;

            TrackViaClient client = new TrackViaClient(IntegrationTestConfig.TRACKVIA_HOSTNAME, IntegrationTestConfig.TRACKVIA_USERNAME,
                                                       IntegrationTestConfig.TRACKVIA_PASSWORD, IntegrationTestConfig.TRACKVIA_API_KEY);

            // Act
            RecordSet rsResult = client.findRecords(IntegrationTestConfig.TRACKVIA_VIEWID_DEMOSIMPLECRM_ACCOUNTSDEFAULTVIEW,
                                                    searchCriteria, startIndex, maxRecords);

            // Assert
            rsResult.ShouldNotBeNull();
            rsResult.Data.ShouldNotBeNull()
            .ShouldNotBeEmpty();
            rsResult.Count.ShouldEqual(2);
            for (int i = 0; i < rsResult.Count; i++)
            {
                var recordUnderTest = rsResult.Data[i];
                recordUnderTest.ShouldNotBeNull();
                recordUnderTest.Id.ShouldBeGreaterThan(0);
            }
        }
        public void IntegrationTest_TrackViaClient_FindDomainRecords_ShouldReturnListOfRecords()
        {
            TestHelper.EnsureProductionValuesBeforeRunningIntegrationTests(IntegrationTestConfig.TRACKVIA_VIEWID_DEMOSIMPLECRM_ACCOUNTSDEFAULTVIEW <= 0);

            // Assemble
            string searchCriteria = "A";
            int    startIndex     = 0;
            int    maxRecords     = 2;

            TrackViaClient client = new TrackViaClient(IntegrationTestConfig.TRACKVIA_HOSTNAME, IntegrationTestConfig.TRACKVIA_USERNAME,
                                                       IntegrationTestConfig.TRACKVIA_PASSWORD, IntegrationTestConfig.TRACKVIA_API_KEY);

            // Act
            DomainRecordSet <TestData.SimpleCrmContact> domainRecordSet = client.findRecords <TestData.SimpleCrmContact>(
                IntegrationTestConfig.TRACKVIA_VIEWID_DEMOSIMPLECRM_ACCOUNTSDEFAULTVIEW,
                searchCriteria, startIndex, maxRecords);

            // Assert
            domainRecordSet.ShouldNotBeNull();
            domainRecordSet.Data.ShouldNotBeNull()
            .ShouldNotBeEmpty();
            domainRecordSet.Count.ShouldEqual(2);
            // Assert

            for (int i = 0; i < domainRecordSet.Count; i++)
            {
                TestData.SimpleCrmContact Account = domainRecordSet.Data[i];
                Account.ShouldNotBeNull();
                Account.Id.ShouldBeGreaterThan(0);
                Account.AccountName.ShouldNotBeNull().ShouldNotBeEmpty();
                Account.PrimaryContact.ShouldNotBeNull().ShouldNotBeEmpty();
            }
        }
Exemple #3
0
        public void TrackViaClient_FindRecords_ShouldReturnListOfRecords()
        {
            // Assemble
            string searchCriteria = "dontcare";
            int    startIndex     = 0;
            int    maxRecords     = 25;

            RecordSet rs = TestData.getUnitTestRecordSet1();

            Mock <IAsyncHttpClientHelper>             httpClient      = new Mock <IAsyncHttpClientHelper>();
            TaskCompletionSource <HttpClientResponse> asyncTaskResult = new TaskCompletionSource <HttpClientResponse>();

            asyncTaskResult.SetResult(new HttpClientResponse()
            {
                Content     = JsonConvert.SerializeObject(rs),
                ContentType = HttpClientResponseTypes.json,
                StatusCode  = HttpStatusCode.OK
            });
            httpClient.Setup(x => x
                             .SendGetRequestAsync(It.Is <string>(s => s.Contains("q=" + searchCriteria) && s.Contains("start=" + startIndex) &&
                                                                 s.Contains("max=" + maxRecords))))
            .Returns(asyncTaskResult.Task);

            TrackViaClient client = new TrackViaClient(httpClient.Object, TestHelper.HostName_Fake, TestHelper.ApiKey_Fake);

            // Act
            RecordSet rsResponse = client.findRecords(1L, searchCriteria, startIndex, maxRecords);

            // Assert
            rsResponse
            .ShouldNotBeNull()
            .Count.ShouldEqual(rs.Count);
            rsResponse.Data
            .ShouldNotBeNull()
            .Count.ShouldEqual(rs.Count);

            for (int i = 0; i < rsResponse.Count; i++)
            {
                RecordData rd1 = rs.Data[i];
                RecordData rd2 = rsResponse.Data[i];

                rd2.ShouldNotBeNull().ShouldEqual(rd1);
            }
        }