Exemplo n.º 1
0
        public async Task GetAllDomainsAsync_exclude_subusers()
        {
            // Arrange
            var mockHttp = new MockHttpMessageHandler();

            mockHttp.Expect(HttpMethod.Get, Utils.GetSendGridApiUri(ENDPOINT, "domains?exclude_subusers=true&limit=50&offset=0&username=&domain=")).Respond("application/json", MULTIPLE_DOMAINS_JSON);

            var client     = Utils.GetFluentClient(mockHttp);
            var whitelabel = new Whitelabel(client);

            // Act
            var result = await whitelabel.GetAllDomainsAsync(excludeSubusers : true).ConfigureAwait(false);

            // Assert
            mockHttp.VerifyNoOutstandingExpectation();
            mockHttp.VerifyNoOutstandingRequest();
            result.ShouldNotBeNull();
            result.Length.ShouldBe(2);
        }
Exemplo n.º 2
0
        public void GetAllDomains_exclude_subusers()
        {
            // Arrange
            var mockRepository = new MockRepository(MockBehavior.Strict);
            var mockClient     = mockRepository.Create <IClient>();

            mockClient
            .Setup(c => c.GetAsync($"{ENDPOINT}/domains?exclude_subusers=true&limit=50&offset=0&username=&domain=", It.IsAny <CancellationToken>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MULTIPLE_DOMAINS_JSON)
            })
            .Verifiable();

            var whitelabel = new Whitelabel(mockClient.Object, ENDPOINT);

            // Act
            var result = whitelabel.GetAllDomainsAsync(excludeSubusers: true).Result;

            // Assert
            result.ShouldNotBeNull();
            result.Length.ShouldBe(2);
        }