public void View() { var restClient = MockRestClient .ThatReturns(filename: "WebhooksView.json") .FromEndpoint("GET", "webhooks/dff95aec-c11f-423c-82f3-1f391d78d716", baseUrl) .Get(); var client = Client.Create(restClient.Object); var webhookResponse = client.ViewWebhook("dff95aec-c11f-423c-82f3-1f391d78d716"); restClient.Verify(); Assert.IsNotNull(webhookResponse.Data); Assert.IsNotNull(webhookResponse.Links); var selfLink = webhookResponse.Links["self"]; Assert.AreEqual("/webhooks/dff95aec-c11f-423c-82f3-1f391d78d716", selfLink); var webhook = webhookResponse.Data.FirstOrDefault(); Assert.AreEqual("dff95aec-c11f-423c-82f3-1f391d78d716", webhook.Id); Assert.AreEqual("https://testing.com", webhook.url); Assert.AreEqual("example token", webhook.token); Assert.IsNotNull(webhook.createdAt); Assert.IsNotNull(webhook.updatedAt); }
public void View() { var restClient = MockRestClient .ThatReturns(filename: "RecordingView.json") .FromEndpoint("GET", "calls/bb3f0391-4fdc-4e38-9551-e8a01602984f/legs/cc3bd14d-3eee-4380-b01f-fe7723c69a31/recordings/3b4ac358-9467-4f7a-a6c8-6157ad181123", baseUrl) .Get(); var client = Client.Create(restClient.Object); var recordingResponse = client.ViewRecording("bb3f0391-4fdc-4e38-9551-e8a01602984f", "cc3bd14d-3eee-4380-b01f-fe7723c69a31", "3b4ac358-9467-4f7a-a6c8-6157ad181123"); restClient.Verify(); Assert.IsNotNull(recordingResponse.Data); Assert.IsNotNull(recordingResponse.Links); var selfLink = recordingResponse.Links["self"]; Assert.AreEqual("/calls/bb3f0391-4fdc-4e38-9551-e8a01602984f/legs/cc3bd14d-3eee-4380-b01f-fe7723c69a31/recordings/3b4ac358-9467-4f7a-a6c8-6157ad181123", selfLink); var fileLink = recordingResponse.Links["file"]; Assert.AreEqual("/calls/bb3f0391-4fdc-4e38-9551-e8a01602984f/legs/cc3bd14d-3eee-4380-b01f-fe7723c69a31/recordings/3b4ac358-9467-4f7a-a6c8-6157ad181123.wav", fileLink); var recording = recordingResponse.Data.FirstOrDefault(); Assert.AreEqual("3b4ac358-9467-4f7a-a6c8-6157ad181123", recording.Id); Assert.AreEqual("cc3bd14d-3eee-4380-b01f-fe7723c69a31", recording.LegId); Assert.AreEqual("wav", recording.Format); Assert.AreEqual("done", recording.Status); Assert.AreEqual(7, recording.Duration); Assert.IsNotNull(recording.CreatedAt); Assert.IsNotNull(recording.UpdatedAt); Assert.IsNull(recording.Links); }
public void List() { var restClient = MockRestClient .ThatReturns(filename: "WebhooksList.json") .FromEndpoint("GET", "webhooks?limit=20&page=0", baseUrl) .Get(); var client = Client.Create(restClient.Object); var webhookList = client.ListWebhooks(); restClient.Verify(); Assert.IsNotNull(webhookList.Data); Assert.IsNotNull(webhookList.Links); Assert.IsNotNull(webhookList.Pagination); var selfLink = webhookList.Links["self"]; Assert.AreEqual("/webhooks?page=1", selfLink); var webhook = webhookList.Data.FirstOrDefault(); Assert.AreEqual("25fde85f-5e8f-42ef-9709-92241ae3789d", webhook.Id); Assert.AreEqual("https://newurl.com", webhook.url); Assert.AreEqual("test title", webhook.token); Assert.IsNotNull(webhook.createdAt); Assert.IsNotNull(webhook.updatedAt); var pagination = webhookList.Pagination; Assert.AreEqual(2, pagination.TotalCount); Assert.AreEqual(1, pagination.PageCount); Assert.AreEqual(1, pagination.CurrentPage); Assert.AreEqual(10, pagination.PerPage); }
public void Start() { var restClient = MockRestClient .ThatExpects( @"{""to"":""+31612345678"",""type"":""text"",""content"":{""text"":""Hello!""},""channelId"":""619747f69cf940a98fb443140ce9aed2""}") .AndReturns(filename: "ConversationView.json") .FromEndpoint("POST", "conversations/start", Resource.ConverstationsBaseUrl) .Get(); var client = Client.Create(restClient.Object); var req = new ConversationStartRequest { ChannelId = "619747f69cf940a98fb443140ce9aed2", Content = new Content { Text = "Hello!" }, Type = ContentType.Text, To = "+31612345678" }; var conversation = client.StartConversation(req); restClient.Verify(); Assert.AreEqual(req.ChannelId, conversation.LastUsedChannelId); Assert.AreEqual("31612345678", conversation.Contact.Msisdn); Assert.AreEqual(2, conversation.Channels.Count); }
public void View() { var restClient = MockRestClient .ThatReturns(filename: "TranscriptionView.json") .FromEndpoint("GET", "calls/373395cc-382b-4a33-b372-cc31f0fdf242/legs/8dd347a4-11ee-44f2-bee3-7fbda300b2cd/recordings/cfa9ae96-e034-4db7-91cb-e58a8392c7bd/transcriptions/2ce04c83-ca4f-4d94-8310-02968da41318", baseUrl) .Get(); var client = Client.Create(restClient.Object); var transcriptionResponse = client.ViewTranscription("373395cc-382b-4a33-b372-cc31f0fdf242", "8dd347a4-11ee-44f2-bee3-7fbda300b2cd", "cfa9ae96-e034-4db7-91cb-e58a8392c7bd", "2ce04c83-ca4f-4d94-8310-02968da41318"); restClient.Verify(); Assert.IsNotNull(transcriptionResponse.Data); Assert.IsNotNull(transcriptionResponse.Links); var selfLink = transcriptionResponse.Links["self"]; Assert.AreEqual("/calls/373395cc-382b-4a33-b372-cc31f0fdf242/legs/8dd347a4-11ee-44f2-bee3-7fbda300b2cd/recordings/cfa9ae96-e034-4db7-91cb-e58a8392c7bd/transcriptions/2ce04c83-ca4f-4d94-8310-02968da41318", selfLink); var fileLink = transcriptionResponse.Links["file"]; Assert.AreEqual("/calls/373395cc-382b-4a33-b372-cc31f0fdf242/legs/8dd347a4-11ee-44f2-bee3-7fbda300b2cd/recordings/cfa9ae96-e034-4db7-91cb-e58a8392c7bd/transcriptions/2ce04c83-ca4f-4d94-8310-02968da41318.txt", fileLink); var transcription = transcriptionResponse.Data.FirstOrDefault(); Assert.AreEqual("2ce04c83-ca4f-4d94-8310-02968da41318", transcription.Id); Assert.AreEqual("cfa9ae96-e034-4db7-91cb-e58a8392c7bd", transcription.RecordingId); Assert.AreEqual("done", transcription.Status); Assert.IsNotNull(transcription.CreatedAt); Assert.IsNotNull(transcription.UpdatedAt); Assert.IsNotNull(transcription.Links); }
public void PostWebhook() { var restClient = MockRestClient .ThatExpects( @"{""events"":[""message.created"", ""message.updated""],""channelId"": ""853eeb5348e541a595da93b48c61a1ae"",""url"":""https://example.com/webhook""}") .AndReturns(filename: "WebhookView.json") .FromEndpoint("POST", "webhooks", Resource.ConverstationsBaseUrl) .Get(); var client = Client.Create(restClient.Object); var req = new ConversationWebhook { ChannelId = "853eeb5348e541a595da93b48c61a1ae", Url = "https://example.com/webhook", Events = new List <ConversationWebhookEvent> { ConversationWebhookEvent.MessageCreated, ConversationWebhookEvent.MessageUpdated } }; var webhook = client.CreateConversationWebhook(req); restClient.Verify(); Assert.AreEqual(req.ChannelId, webhook.ChannelId); Assert.AreEqual(req.Url, webhook.Url); Assert.AreEqual(req.Events.Count, webhook.Events.Count); Assert.IsTrue(webhook.Events.Contains(ConversationWebhookEvent.MessageCreated)); Assert.IsTrue(webhook.Events.Contains(ConversationWebhookEvent.MessageUpdated)); }
public void PostMessage() { var restClient = MockRestClient .ThatExpects(@"{""type"": ""text"",""content"":{""text"": ""Hello!""}}") .AndReturns(filename: "ConversationMessage.json") .FromEndpoint("POST", $"conversations/{ConvId}/messages", Resource.ConverstationsBaseUrl) .Get(); var client = Client.Create(restClient.Object); var req = new ConversationMessageSendRequest { Type = ContentType.Text, Content = new Content { Text = "Hello!" } }; var message = client.SendConversationMessage(ConvId, req); restClient.Verify(); Assert.AreEqual(ConvId, message.ConversationId); Assert.AreEqual(ConversationMessageStatus.Pending, message.Status); Assert.AreEqual(ConversationMessageDirection.Sent, message.Direction); }
public void Create() { var restClient = MockRestClient .ThatExpects("{\"url\":\"https://testing.com\",\"token\":\"example token\"}") .AndReturns(filename: "WebhooksCreate.json") .FromEndpoint("POST", "webhooks", baseUrl) .Get(); var client = Client.Create(restClient.Object); var newWebhook = new Webhook { url = "https://testing.com", token = "example token" }; var webhookResponse = client.CreateWebhook(newWebhook); restClient.Verify(); Assert.IsNotNull(webhookResponse.Data); Assert.IsNotNull(webhookResponse.Links); var selfLink = webhookResponse.Links["self"]; Assert.AreEqual("/webhooks/dff95aec-c11f-423c-82f3-1f391d78d716", selfLink); var webhook = webhookResponse.Data.FirstOrDefault(); Assert.AreEqual("dff95aec-c11f-423c-82f3-1f391d78d716", webhook.Id); Assert.AreEqual("https://testing.com", webhook.url); Assert.AreEqual("example token", webhook.token); Assert.IsNotNull(webhook.createdAt); Assert.IsNotNull(webhook.updatedAt); }
public async Task Should_Retrieve_User() { const string userId = "*****@*****.**"; string path = $"/api/users/byUserId/{userId}"; MockRestClient.Setup(m => m.GetAsync <RetrieveUserResponse>(It.Is <string>(a => a == path))).ReturnsAsync(new ApiResponse <RetrieveUserResponse> { UrlPath = path, HttpStatusCode = HttpStatusCode.OK, Model = new RetrieveUserResponse { User = new UserModel { Email = userId, UserId = userId } } }); ApiResponse <RetrieveUserResponse> response = await _userClient.GetByUserIdAsync(userId).ConfigureAwait(false); Assert.NotNull(response); Assert.NotNull(response.Model); Assert.NotNull(response.Model.User); Assert.Equal(userId, response.Model.User.Email); Assert.Equal(userId, response.Model.User.UserId); Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode); Assert.Equal(path, response.UrlPath); MockRestClient.Verify(m => m.GetAsync <RetrieveUserResponse>(It.Is <string>(a => a == path)), Times.Once); }
public void View() { var restClient = MockRestClient .ThatReturns(filename: "CallView.json") .FromEndpoint("GET", "calls/f1aa71c0-8f2a-4fe8-b5ef-9a330454ef58", baseUrl) .Get(); var client = Client.Create(restClient.Object); var callResponse = client.ViewCall("f1aa71c0-8f2a-4fe8-b5ef-9a330454ef58"); restClient.Verify(); Assert.IsNotNull(callResponse.Data); Assert.IsNotNull(callResponse.Links); var selfLink = callResponse.Links["self"]; Assert.AreEqual("/calls/f1aa71c0-8f2a-4fe8-b5ef-9a330454ef58", selfLink); var call = callResponse.Data.FirstOrDefault(); Assert.AreEqual("f1aa71c0-8f2a-4fe8-b5ef-9a330454ef58", call.Id); Assert.AreEqual(CallStatus.Ended, call.Status); Assert.AreEqual("31644556677", call.Source); Assert.AreEqual("31612345678", call.Destination); Assert.IsNotNull(call.CreatedAt); Assert.IsNotNull(call.UpdatedAt); Assert.IsNotNull(call.EndedAt); Assert.IsNull(call.Links); }
public async Task Should_Delete_User() { const string email = "*****@*****.**"; string path = $"/api/users/{email}"; MockRestClient.Setup(m => m.DeleteAsync <DeleteUserResponse>(It.Is <string>(a => a == path))).ReturnsAsync(new ApiResponse <DeleteUserResponse> { UrlPath = path, HttpStatusCode = HttpStatusCode.OK, Model = new DeleteUserResponse { Code = "Success" } }); ApiResponse <DeleteUserResponse> response = await _userClient.DeleteByEmailAsync(email).ConfigureAwait(false); Assert.NotNull(response); Assert.NotNull(response.Model); Assert.Equal("Success", response.Model.Code); Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode); Assert.Equal(path, response.UrlPath); MockRestClient.Verify(m => m.DeleteAsync <DeleteUserResponse>(It.Is <string>(a => a == path)), Times.Once); }
public void View() { var restClient = MockRestClient .ThatReturns(filename: "CallFlowView.json") .FromEndpoint("GET", "call-flows/de3ed163-d5fc-45f4-b8c4-7eea7458c635", baseUrl) .Get(); var client = Client.Create(restClient.Object); var callFlowResponse = client.ViewCallFlow("de3ed163-d5fc-45f4-b8c4-7eea7458c635"); restClient.Verify(); Assert.IsNotNull(callFlowResponse.Data); Assert.IsNotNull(callFlowResponse.Links); var links = callFlowResponse.Links; Assert.AreEqual("/call-flows/de3ed163-d5fc-45f4-b8c4-7eea7458c635", links.GetValueOrDefault("self")); var callFlow = callFlowResponse.Data.FirstOrDefault(); Assert.AreEqual("de3ed163-d5fc-45f4-b8c4-7eea7458c635", callFlow.Id); Assert.AreEqual("Forward call to 31611223344", callFlow.Title); Assert.AreEqual(false, callFlow.Record); Assert.IsNotNull(callFlow.CreatedAt); Assert.IsNotNull(callFlow.UpdatedAt); Assert.IsNotNull(callFlow.Steps); var step = callFlow.Steps.FirstOrDefault(); Assert.AreEqual("3538a6b8-5a2e-4537-8745-f72def6bd393", step.Id); Assert.AreEqual("transfer", step.Action); Assert.AreEqual("31611223344", step.Options.Destination); }
public async Task Should_Delete() { const int listId = 14; string path = $"/api/lists/{listId}"; MockRestClient.Setup(m => m.DeleteAsync <DeleteListResponse>(It.Is <string>(a => a == path))).ReturnsAsync(new ApiResponse <DeleteListResponse> { UrlPath = path, HttpStatusCode = HttpStatusCode.OK, Model = new DeleteListResponse { Code = "Success" } }); ApiResponse <DeleteListResponse> response = await _listClient.DeleteAsync(listId).ConfigureAwait(false); Assert.NotNull(response); Assert.NotNull(response.Model); Assert.Equal("Success", response.Model.Code); Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode); Assert.Equal(path, response.UrlPath); MockRestClient.Verify(m => m.DeleteAsync <DeleteListResponse>(It.Is <string>(a => a == path)), Times.Once); }
public async Task Should_Retrieve_Users() { const int listId = 14; const string users = "[email protected]\[email protected]"; string path = $"/api/lists/getUsers?listId={listId}"; MockRestClient.Setup(m => m.GetContentAsync(It.Is <string>(a => a == path))).ReturnsAsync(new ApiResponse { UrlPath = path, HttpStatusCode = HttpStatusCode.OK, Content = users }); ApiResponse <GetUsersResponse> response = await _listClient.GetUsersAsync(listId).ConfigureAwait(false); Assert.NotNull(response); Assert.NotNull(response.Model); Assert.NotNull(response.Model.UserIds); Assert.True(response.Model.UserIds.Any()); Assert.Equal(2, response.Model.UserIds.Count()); Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode); Assert.Equal(path, response.UrlPath); MockRestClient.Verify(m => m.GetContentAsync(It.Is <string>(a => a == path)), Times.Once); }
public void ShouldReturnHealthStatus() { var expected = new HealthStatus() { IsElasticsearchServerAvailable = true, IsMailServerAvailable = true, IsMessageQueueServerAvailable = true, }; var content = JsonConvert.SerializeObject(expected); var restResponse = new RestResponse() { Content = content }; MockRestClient.Setup(x => x.Execute(It.Is <RestRequest>(y => y.Resource == HealthStatusName))) .Returns(restResponse); MockJsonConvert.Setup(x => x.DeserializeObject <HealthStatus>(content)) .Returns(expected); var actual = Subject.GetHealthStatus(); Assert.That(actual, Is.EqualTo(expected)); MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource == HealthStatusName)), Times.Once); MockJsonConvert.Verify(x => x.DeserializeObject <HealthStatus>(content), Times.Once); }
public async Task Should_Update_User() { string path = "/api/users/update"; var request = new UpdateUserRequest { Email = "*****@*****.**", UserId = "*****@*****.**" }; MockRestClient.Setup(m => m.PostAsync <UpdateUserResponse>(It.Is <string>(a => a == path), It.IsAny <UpdateUserRequest>())).ReturnsAsync(new ApiResponse <UpdateUserResponse> { UrlPath = path, HttpStatusCode = HttpStatusCode.OK, Model = new UpdateUserResponse { Code = "Success" } }); ApiResponse <UpdateUserResponse> response = await _userClient.UpdateAsync(request).ConfigureAwait(false); Assert.NotNull(response); Assert.NotNull(response.Model); Assert.Equal("Success", response.Model.Code); Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode); Assert.Equal(path, response.UrlPath); MockRestClient.Verify(m => m.PostAsync <UpdateUserResponse>(It.Is <string>(a => a == path), It.IsAny <UpdateUserRequest>()), Times.Once); }
public void It_should_call_leankit_to_create_card_if_card_with_externalid_exists_but_different_externalsystemname() { _mapping.Identity.LeanKit = 5; _mapping.Identity.Target = "5"; ((TestGitHubIssues)TestItem).Syncronize(_mapping); MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("/5/issues") && y.Method == Method.GET)), Times.Exactly(_mapping.QueryStates.Count)); MockLeanKitApi.Verify(x => x.AddCard(5, It.IsAny <Card>(), It.IsAny <string>()), Times.Exactly(1)); }
public void It_should_call_leankit_to_create_card_if_existing_card_has_externalid_but_externalsystemname_does_not_match() { _mapping.Identity.LeanKit = 5; _mapping.Identity.Target = "5"; ((TestGitHubPulls)TestItem).Syncronize(_mapping); MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("/5/pulls") && y.Method == Method.GET)), Times.Exactly(1)); MockLeanKitApi.Verify(x => x.AddCard(5, It.IsAny <Card>(), It.IsAny <string>()), Times.Exactly(1)); }
public void It_should_call_github_to_get_list_of_issues() { _mapping.Identity.LeanKit = 1; _mapping.Identity.Target = "1"; ((TestGitHubIssues)TestItem).Syncronize(_mapping); MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("/1/issues") && y.Method == Method.GET)), Times.Exactly(_mapping.QueryStates.Count)); MockLeanKitApi.Verify(x => x.AddCard(1, It.IsAny <Card>(), It.IsAny <string>()), Times.Exactly(1)); }
public void It_should_call_leankit_multiple_times_to_create_card_if_there_are_multiple_issues() { _mapping.Identity.LeanKit = 3; _mapping.Identity.Target = "3"; ((TestGitHubIssues)TestItem).Syncronize(_mapping); MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("/3/issues") && y.Method == Method.GET)), Times.Exactly(_mapping.QueryStates.Count)); MockLeanKitApi.Verify(x => x.AddCard(3, It.IsAny <Card>(), It.IsAny <string>()), Times.Exactly(3)); }
public void It_should_call_leankit_once_to_create_card_if_there_is_one_pullrequest() { _mapping.Identity.LeanKit = 2; _mapping.Identity.Target = "2"; ((TestGitHubPulls)TestItem).Syncronize(_mapping); MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("/2/pulls") && y.Method == Method.GET)), Times.Exactly(1)); MockLeanKitApi.Verify(x => x.AddCard(2, It.IsAny <Card>(), It.IsAny <string>()), Times.Exactly(1)); }
public void It_should_not_call_leankit_to_create_card_if_card_with_externalid_already_exists() { _mapping.Identity.LeanKit = 4; _mapping.Identity.Target = "4"; ((TestUnfuddle)TestItem).Syncronize(_mapping); MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("projects/4/ticket_reports") && y.Method == Method.GET)), Times.Exactly(1)); MockLeanKitApi.Verify(x => x.AddCard(4, It.IsAny <Card>(), It.IsAny <string>()), Times.Never()); }
public void It_should_call_leankit_create_card_if_card_with_externalid_exists_but_has_different_externalsystemname() { _mapping.Identity.LeanKit = 5; _mapping.Identity.Target = "5"; ((TestUnfuddle)TestItem).Syncronize(_mapping); MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("projects/5/ticket_reports") && y.Method == Method.GET)), Times.Exactly(1)); MockLeanKitApi.Verify(x => x.AddCard(5, It.IsAny <Card>(), It.IsAny <string>()), Times.Exactly(1)); }
public void It_should_call_leankit_multiple_times_to_create_card_if_there_are_multiple_tickets() { _mapping.Identity.LeanKit = 3; _mapping.Identity.Target = "3"; ((TestUnfuddle)TestItem).Syncronize(_mapping); MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("projects/3/ticket_reports") && y.Method == Method.GET)), Times.Exactly(1)); MockLeanKitApi.Verify(x => x.AddCard(3, It.IsAny <Card>(), It.IsAny <string>()), Times.Exactly(3)); }
public void It_should_call_unfuddle_to_get_list_of_tickets() { _mapping.Identity.LeanKit = 1; _mapping.Identity.Target = "1"; ((TestUnfuddle)TestItem).Syncronize(_mapping); MockRestClient.Verify(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("projects/1/ticket_reports") && y.Method == Method.GET)), Times.Exactly(1)); MockLeanKitApi.Verify(x => x.AddCard(1, It.IsAny <Card>(), It.IsAny <string>()), Times.Exactly(1)); }
public void Setup() { _restClient = new MockRestClient(); _authentication = new MobileConnect.Authentication.AuthenticationService(this._restClient); _config = new MobileConnectConfig() { ClientId = "1234567890", ClientSecret = "1234567890", DiscoveryUrl = "http://localhost:8080/v2/discovery/" }; }
private void Setup(IDiscoveryCache cache) { _restClient = new MockRestClient(); _cache = cache; _discovery = new MobileConnect.Discovery.Discovery(cache, this._restClient); _config = new MobileConnectConfig() { ClientId = "1234567890", ClientSecret = "1234567890", DiscoveryUrl = "http://localhost:8080/v2/discovery/" }; }
internal static GfycatClient MakeClient() { MockRestClient restClient = new MockRestClient(new Uri(GfycatClientConfig.BaseUrl)); GfycatClientConfig config = new GfycatClientConfig(clientId, clientSecret) { RestClient = restClient }; return(new GfycatClient(config)); }
protected override void OnArrange() { base.OnArrange(); MockLeanKitApi.Setup(x => x.GetBoard(It.IsAny <long>())).Returns(_testBoard); var serializer = new JsonSerializer <Unfuddle.Person>(); var user1 = new Unfuddle.Person() { Email = "*****@*****.**", First_Name = "Johnny", Id = 1, Last_Name = "Cash", Username = "******" }; var user2 = new Unfuddle.Person() { Email = "*****@*****.**", First_Name = "Willy", Id = 2, Last_Name = "Cash", Username = "******" }; var user3 = new Unfuddle.Person() { Email = "", First_Name = "", Id = 3, Last_Name = "", Username = "" }; var restResponse1 = new RestResponse() { Content = serializer.SerializeToString(user1), StatusCode = HttpStatusCode.OK }; var restResponse2 = new RestResponse() { Content = serializer.SerializeToString(user2), StatusCode = HttpStatusCode.OK }; var restResponse3 = new RestResponse() { Content = serializer.SerializeToString(user3), StatusCode = HttpStatusCode.OK }; MockRestClient.Setup(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("people/1")))).Returns(restResponse1); MockRestClient.Setup(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("people/2")))).Returns(restResponse2); MockRestClient.Setup(x => x.Execute(It.Is <RestRequest>(y => y.Resource.Contains("people/3")))).Returns(restResponse3); }
public void ListScheduledMessages() { var restClient = MockRestClient .ThatReturns(filename: "ListMessages.json") .FromEndpoint("GET", "messages?limit=20&offset=0&status=scheduled") .Get(); var client = Client.Create(restClient.Object); client.ListMessages("scheduled"); restClient.Verify(); }
public BuildTablePopulatorTests() { var account = Util.GetStorageAccount(); var tableClient = account.CreateCloudTableClient(); _restClient = new MockRestClient(); var client = new JenkinsClient(new Uri("http://test.com"), _restClient.Client); _buildFailureExactTable = tableClient.GetTableReference(AzureConstants.TableNames.BuildFailureExact); _buildResultExactTable = tableClient.GetTableReference(AzureConstants.TableNames.BuildResultExact); _populator = new BuildTablePopulator( tableClient, client: client, factory: new CounterUtilFactory(), textWriter: new StringWriter()); }