コード例 #1
0
            public void WhenLmiDataCached_ReturnCachedData()
            {
                _restClient = new RestClient();

                var matches = new List <OccupationMatch>
                {
                    new OccupationMatch
                    {
                        SocCode = 2815
                    }
                };
                var date = DateTimeOffset.Now.Subtract(new TimeSpan(-1, -1, -1));
                var cachedLmiDataModel = new CachedLmiData
                {
                    SocCode     = 2815.ToString(),
                    JobGrowth   = JobGrowth.Increasing,
                    DateWritten = date,
                };

                _cosmosService.ReadItemAsync(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <CosmosCollection>())
                .Returns(new HttpResponseMessage
                {
                    StatusCode = HttpStatusCode.OK,
                    Content    = new StringContent(JsonConvert.SerializeObject(cachedLmiDataModel))
                });
                var serviceUnderTest = new LmiService(_restClient, _settings, _cosmosService);
                var result           = serviceUnderTest.GetPredictionsForGetOccupationMatches(matches);

                result[0].SocCode.Should().Be(2815);
                result[0].JobGrowth.Should().Be(JobGrowth.Increasing);
            }
コード例 #2
0
            public void IfMatchesIsNull_ReturnMatches()
            {
                var serviceUnderTest = new LmiService(_settings, _cosmosService);

                var result = serviceUnderTest.GetPredictionsForGetOccupationMatches(null);

                result.Should().BeNull();
            }
コード例 #3
0
            public void IfMatchesIsEmpty_ReturnMatches()
            {
                var serviceUnderTest = new LmiService(_restClient, _settings, _cosmosService);
                var matches          = new List <OccupationMatch>();

                var result = serviceUnderTest.GetPredictionsForGetOccupationMatches(matches);

                result.Should().Equal(matches);
            }
コード例 #4
0
            public void IfSocCodeIsZero_ReturnMatchesWithoutGrowth()
            {
                var serviceUnderTest = new LmiService(_restClient, _settings, _cosmosService);
                var matches          = new List <OccupationMatch>
                {
                    new OccupationMatch
                    {
                        SocCode = 0
                    }
                };

                var result = serviceUnderTest.GetPredictionsForGetOccupationMatches(matches);

                result.FirstOrDefault().JobGrowth.Should().Be(JobGrowth.Undefined);
            }
コード例 #5
0
            public void IfSuccessfulCall_ReturnMatchesWithGrowth()
            {
                var serviceUnderTest = new LmiService(_restClient, _settings, _cosmosService);
                var matches          = new List <OccupationMatch>
                {
                    new OccupationMatch
                    {
                        SocCode = 2815
                    }
                };

                var result = serviceUnderTest.GetPredictionsForGetOccupationMatches(matches);

                result.FirstOrDefault().JobGrowth.Should().Be(JobGrowth.Increasing);
            }
コード例 #6
0
            public void IfUnsuccessfulCall_ReturnMatchesWithoutGrowth()
            {
                var mockHandler = LmiHelpers.GetMockMessageHandler(string.Empty, HttpStatusCode.BadRequest);

                _restClient = new RestClient(mockHandler.Object);
                var serviceUnderTest = new LmiService(_restClient, _settings, _cosmosService);
                var matches          = new List <OccupationMatch>
                {
                    new OccupationMatch
                    {
                        SocCode = 2815
                    }
                };

                var result = serviceUnderTest.GetPredictionsForGetOccupationMatches(matches);

                result.FirstOrDefault().JobGrowth.Should().Be(JobGrowth.Undefined);
            }
コード例 #7
0
            public void IfSuccessfulCall_WithNullContentReturnMatchesWithoutGrowth()
            {
                var wfResult    = JsonConvert.SerializeObject(new WfPredictionResult());
                var mockHandler = LmiHelpers.GetMockMessageHandler(wfResult, HttpStatusCode.OK);

                _restClient = new RestClient(mockHandler.Object);
                var serviceUnderTest = new LmiService(_restClient, _settings, _cosmosService);
                var matches          = new List <OccupationMatch>
                {
                    new OccupationMatch
                    {
                        SocCode = 2815
                    }
                };

                var result = serviceUnderTest.GetPredictionsForGetOccupationMatches(matches);

                result.FirstOrDefault().JobGrowth.Should().Be(JobGrowth.Undefined);
            }