Ejemplo n.º 1
0
            public void Init()
            {
                _settings = Options.Create(new LmiSettings()
                {
                    ApiUrl = "http://thisisarealuri.com"
                });
                var cachedLmiDataModel = new CachedLmiData
                {
                    SocCode     = 2815.ToString(),
                    JobGrowth   = JobGrowth.Increasing,
                    DateWritten = DateTimeOffset.Now
                };
                var cachedLmiData = new StringContent(JsonConvert.SerializeObject(cachedLmiDataModel));
                var mockHandler   = LmiHelpers.GetMockMessageHandler(LmiHelpers.SuccessfulLmiCall());

                _restClient    = new RestClient(mockHandler.Object);
                _cosmosService = Substitute.For <ICosmosService>();
                _cosmosService.ReadItemAsync(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <CosmosCollection>())
                .Returns(new HttpResponseMessage
                {
                    StatusCode = HttpStatusCode.OK,
                    Content    = cachedLmiData
                });
                _cosmosService.CreateItemAsync(Arg.Any <object>(), Arg.Any <CosmosCollection>())
                .Returns(new HttpResponseMessage(HttpStatusCode.OK));
                _cosmosService.UpsertItemAsync(Arg.Any <object>(), Arg.Any <CosmosCollection>())
                .Returns(new HttpResponseMessage(HttpStatusCode.OK));
            }
Ejemplo n.º 2
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);
            }
Ejemplo n.º 3
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);
            }