Exemplo n.º 1
0
            public async Task CreatesRequestWithAppropriateHeaders()
            {
                var apiClient  = Substitute.For <IApiClient>();
                var serializer = Substitute.For <IJsonSerializer>();
                var endpoint   = Endpoint.Get(BaseUrls.ForApi(ApiEnvironment.Staging), "");

                apiClient.Send(Arg.Any <Request>()).Returns(x => new Response("It lives", true, "text/plain", new List <KeyValuePair <string, IEnumerable <string> > >(), OK));

                var credentials = Credentials.WithPassword(
                    "*****@*****.**".ToEmail(),
                    "theirobotmoviesucked123".ToPassword());
                const string expectedHeader = "c3VzYW5jYWx2aW5AcHN5Y2hvaGlzdG9yaWFuLm11c2V1bTp0aGVpcm9ib3Rtb3ZpZXN1Y2tlZDEyMw==";

                var testApi = new TestApi(endpoint, apiClient, serializer, credentials, endpoint);

                await testApi.Get();

                await apiClient.Received().Send(Arg.Is <Request>(request => verifyAuthHeader(request, expectedHeader)));
            }