Exemplo n.º 1
0
        public void UnknownPassedCountryThrowsArgumentOutOfRangeException()
        {
            async Task Act()
            {
                await IsDayOffApiClient.GetDataAsync(
                    04.08.Of(2020),
                    04.08.Of(2020),
                    (Country)int.MaxValue,
                    false,
                    false,
                    false,
                    CancellationToken.None);
            }

            Assert.ThrowsAsync <ArgumentOutOfRangeException>(Act);
        }
Exemplo n.º 2
0
        public async Task RequestHasCorrectUserAgentHeader()
        {
            HttpMessageHandlerMock.ResponseMessage = new HttpResponseMessage {
                Content = new StringContent("0")
            };

            await IsDayOffApiClient.GetDataAsync(
                04.08.Of(2020),
                04.08.Of(2020),
                Country.Russia,
                false,
                false,
                false,
                CancellationToken.None);

            Assert.That(HttpMessageHandlerMock.LastRequest.Headers.UserAgent.ToString(), Is.EqualTo(UserAgentStub));
        }
Exemplo n.º 3
0
        public async Task ResponsePassesUnchanged(string response)
        {
            HttpMessageHandlerMock.ResponseMessage = new HttpResponseMessage {
                Content = new StringContent(response)
            };

            var result = await IsDayOffApiClient.GetDataAsync(
                04.08.Of(2020),
                04.08.Of(2020),
                Country.Russia,
                false,
                false,
                false,
                CancellationToken.None);

            Assert.That(result.Result, Is.EqualTo(response));
        }
Exemplo n.º 4
0
        public async Task <string> UrlConstructsCorrectly(
            DateTime from,
            DateTime to,
            Country country,
            bool useShortDays,
            bool treatNonWorkingDaysByCovidAsWorkingDayAdvanced,
            bool useSixDaysWorkWeek,
            string fakeResponse)
        {
            HttpMessageHandlerMock.ResponseMessage = new HttpResponseMessage {
                Content = new StringContent(fakeResponse)
            };

            await IsDayOffApiClient.GetDataAsync(
                from,
                to,
                country,
                useShortDays,
                treatNonWorkingDaysByCovidAsWorkingDayAdvanced,
                useSixDaysWorkWeek,
                CancellationToken.None);

            return(HttpMessageHandlerMock.LastRequest.RequestUri.ToString());
        }
Exemplo n.º 5
0
        public Type ValidationWorksCorrectly(string responseStringContent,
                                             HttpStatusCode responseStatusCode)
        {
            HttpMessageHandlerMock.ResponseMessage = new HttpResponseMessage(responseStatusCode)
            {
                Content = new StringContent(responseStringContent)
            };

            async Task Act()
            {
                await IsDayOffApiClient.GetDataAsync(
                    04.08.Of(2020),
                    06.08.Of(2020),
                    Country.Russia,
                    false,
                    false,
                    false,
                    CancellationToken.None);
            }

            var outerException = Assert.ThrowsAsync <IsDayOffExternalServiceException>(Act);

            return(outerException.InnerException !.GetType());
        }
Exemplo n.º 6
0
        public override void Setup()
        {
            base.Setup();

            IsDayOffApiClient = new IsDayOffApiClient(ApiBaseUrlStub, UserAgentStub, new HttpClientFactory(HttpMessageHandlerMock));
        }