示例#1
0
        public void Update()
        {
            // Arrange
            var groupId     = 103;
            var name        = "Item Suggestions";
            var description = "Suggestions for items our users might like.";

            var mockRepository = new MockRepository(MockBehavior.Strict);
            var mockClient     = mockRepository.Create <IClient>();

            mockClient
            .Setup(c => c.PatchAsync($"{ENDPOINT}/{groupId}", It.IsAny <JObject>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(SINGLE_SUPPRESSION_GROUP_JSON)
            })
            .Verifiable();

            var groups = new UnsubscribeGroups(mockClient.Object, ENDPOINT);

            // Act
            var result = groups.UpdateAsync(groupId, name, description, CancellationToken.None).Result;

            // Assert
            result.ShouldNotBeNull();
        }
示例#2
0
        public void Update()
        {
            // Arrange
            var groupId     = 103;
            var name        = "Item Suggestions";
            var description = "Suggestions for items our users might like.";

            var apiResponse = @"{
				'id':103,
				'name': 'Item Suggestions',
				'description': 'Suggestions for items our users might like.'
			}"            ;
            var mockClient  = new Mock <IClient>(MockBehavior.Strict);

            mockClient.Setup(c => c.PatchAsync($"{ENDPOINT}/{groupId}", It.IsAny <JObject>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(apiResponse)
            });

            var groups = new UnsubscribeGroups(mockClient.Object);

            // Act
            var result = groups.UpdateAsync(groupId, name, description, CancellationToken.None).Result;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(groupId, result.Id);
            Assert.AreEqual(name, result.Name);
            Assert.AreEqual(description, result.Description);
        }
        public async Task UpdateAsync()
        {
            // Arrange
            var groupId     = 103;
            var name        = "Item Suggestions";
            var description = "Suggestions for items our users might like.";

            var mockHttp = new MockHttpMessageHandler();

            mockHttp.Expect(new HttpMethod("PATCH"), Utils.GetSendGridApiUri(ENDPOINT, groupId)).Respond("application/json", SINGLE_SUPPRESSION_GROUP_JSON);

            var client = Utils.GetFluentClient(mockHttp);
            var groups = new UnsubscribeGroups(client);

            // Act
            var result = await groups.UpdateAsync(groupId, name, description, null, CancellationToken.None).ConfigureAwait(false);

            // Assert
            mockHttp.VerifyNoOutstandingExpectation();
            mockHttp.VerifyNoOutstandingRequest();
            result.ShouldNotBeNull();
        }