Esempio n. 1
0
        public async Task CallDataStorePostAsync()
        {
            var mockDataStore = Substitute.For <IDataStore>();
            var client        = new TestableOktaClient(mockDataStore);
            var testRequest   = new HttpRequest();
            await client.PostAsync(testRequest, CancellationToken.None);

            await mockDataStore
            .Received(1)
            .PostAsync <Resource>(Arg.Is(testRequest), Arg.Any <RequestContext>(), Arg.Any <CancellationToken>());
        }
        public async Task SetContentTransferEncodingFromRequestForPost()
        {
            var executor = Substitute.For <IRequestExecutor>();

            executor
            .PostAsync(Arg.Any <HttpRequest>(), Arg.Any <CancellationToken>())
            .Returns(Task.FromResult(new HttpResponse <string>()
            {
                StatusCode = 200
            }));

            var client = new TestableOktaClient(executor);
            await client.PostAsync(new HttpRequest { ContentTransferEncoding = "bar" });

            await executor.Received()
            .PostAsync(Arg.Is <HttpRequest>(request => request.Headers.ContainsKey("Content-Transfer-Encoding") && request.Headers["Content-Transfer-Encoding"].Equals("bar")), Arg.Any <CancellationToken>());
        }