public CourseListInput GetCourseSearchInput(CourseSearchProperties courseSearchProperties) { if (courseSearchProperties == null) { throw new ArgumentNullException(nameof(courseSearchProperties)); } var apiRequest = new CourseListInput { CourseListRequest = new CourseListRequestStructure { CourseSearchCriteria = new SearchCriteriaStructure { APIKey = configuration.GetConfig <string>(Constants.CourseSearchApiKey), SubjectKeyword = courseSearchProperties.Filters.SearchTerm, EarliestStartDate = courseBusinessRules.GetEarliestStartDate(courseSearchProperties.Filters.StartDate, courseSearchProperties.Filters.StartDateFrom), AttendanceModes = convertTribalCodes.GetTribalAttendanceModes(courseSearchProperties.Filters.CourseType), StudyModes = convertTribalCodes.GetTribalStudyModes(courseSearchProperties.Filters.CourseHours), ProviderKeyword = courseSearchProperties.Filters.Provider, Distance = courseSearchProperties.Filters.DistanceSpecified ? courseSearchProperties.Filters.Distance : default(float), DistanceSpecified = courseSearchProperties.Filters.DistanceSpecified, Location = courseSearchProperties.Filters.Location }, RecordsPerPage = courseSearchProperties.Count.ToString(), PageNo = courseSearchProperties.Page.ToString(), SortBy = GetSortType(courseSearchProperties.OrderedBy), SortBySpecified = true } }; return(apiRequest); }
public CourseListInput GetCourseSearchInput(string courseName, CourseSearchProperties courseSearchProperties) { if (courseSearchProperties == null) { throw new ArgumentNullException(nameof(courseSearchProperties)); } var apiRequest = new CourseListInput { CourseListRequest = new CourseListRequestStructure { CourseSearchCriteria = new SearchCriteriaStructure { APIKey = configuration.GetConfig <string>(Constants.CourseSearchApiKey), SubjectKeyword = courseName, EarliestStartDate = null, AttendanceModes = convertTribalCodesService.GetTribalAttendanceModes(string.Join(",", courseSearchProperties.Filters.Attendance ?? new List <string>())), StudyModes = convertTribalCodesService.GetTribalStudyModes(string.Join(",", courseSearchProperties.Filters.StudyMode ?? new List <string>())), DFE1619Funded = courseSearchProperties.Filters.Only1619Courses ? "Y" : null, AttendancePatterns = convertTribalCodesService.GetTribalAttendancePatterns(string.Join(",", courseSearchProperties.Filters.AttendancePattern ?? new List <string>())), ProviderKeyword = courseSearchProperties.Filters.Provider, Distance = courseSearchProperties.Filters.Distance, DistanceSpecified = courseSearchProperties.Filters.DistanceSpecified, Location = courseSearchProperties.Filters.Location }, RecordsPerPage = courseSearchProperties.Count.ToString(), PageNo = courseSearchProperties.Page.ToString(), SortBy = GetSortType(courseSearchProperties.OrderedBy), SortBySpecified = true } }; return(apiRequest); }
public void SimulateEmailResponseTest(string emailAddress, bool isSuccessResponse) { // Assign A.CallTo(() => fakeConfiguration.GetConfig <string>(A <string> .That.Matches(x => x.Equals(Constants.SimulationSuccessEmailAddress)))).Returns(Constants.SimulationSuccessEmailAddress); A.CallTo(() => fakeConfiguration.GetConfig <string>(A <string> .That.Matches(x => x.Equals(Constants.SimulationFailureEmailAddress)))).Returns(Constants.SimulationFailureEmailAddress); // Act var simulationServices = new EmailSimulateService(fakeConfiguration); var response = simulationServices.SimulateEmailResponse(emailAddress); // Assert response.Should().Be(isSuccessResponse); }
public void InitialiseTest() { //Arrange A.CallTo(() => fakeConfiguration.GetConfig <string>(Constants.CosmosDbName)).Returns(Constants.CosmosDbName); A.CallTo(() => fakeConfiguration.GetConfig <string>(Constants.EmailDocumentCollection)).Returns(Constants.EmailDocumentCollection); //Act var repo = GetEmailRepo(); repo.Initialise(); //Assert A.CallTo(() => fakeConfiguration.GetConfig <string>(Constants.CosmosDbName)).MustHaveHappened(); A.CallTo(() => fakeConfiguration.GetConfig <string>(Constants.EmailDocumentCollection)).MustHaveHappened(); }
public void GetCourseSearchInputTest(string courseName, CourseSearchProperties courseSearchProperties, CourseListInput expectedCourseListInput) { // Assign var buildTribalMessageService = new BuildTribalMessageService(fakeConvertTribalCodesService, fakeConfiguration); //Act var result = buildTribalMessageService.GetCourseSearchInput(courseName, courseSearchProperties); //Assert result.Should().BeEquivalentTo(expectedCourseListInput); A.CallTo(() => fakeConvertTribalCodesService.GetTribalAttendanceModes(A <string> ._)).MustHaveHappened(); A.CallTo(() => fakeConvertTribalCodesService.GetTribalAttendancePatterns(A <string> ._)).MustHaveHappened(); A.CallTo(() => fakeConvertTribalCodesService.GetTribalStudyModes(A <string> ._)).MustHaveHappened(); A.CallTo(() => fakeConfiguration.GetConfig <string>(A <string> ._)).MustHaveHappened(1, Times.Exactly); }
public void GetCourseSearchInputTest(CourseSearchProperties courseSearchProperties, CourseListInput expectedCourseListInput) { // Assign var buildTribalMessageService = new TribalMessageBuilder(fakeConvertTribalCodesService, fakeConfiguration, fakeCourseBusinessRules); //Act var result = buildTribalMessageService.GetCourseSearchInput(courseSearchProperties); //Assert result.Should().BeEquivalentTo(expectedCourseListInput); A.CallTo(() => fakeConvertTribalCodesService.GetTribalAttendanceModes(A <CourseType> ._)).MustHaveHappened(); A.CallTo(() => fakeCourseBusinessRules.GetEarliestStartDate(A <StartDate> ._, A <DateTime> ._)).MustHaveHappened(); A.CallTo(() => fakeConvertTribalCodesService.GetTribalStudyModes(A <CourseHours> ._)).MustHaveHappened(); A.CallTo(() => fakeConfiguration.GetConfig <string>(A <string> ._)).MustHaveHappened(1, Times.Exactly); }
public async Task <ServiceStatus> GetCurrentStatusAsync() { var serviceStatus = new ServiceStatus { Name = ServiceName, Status = ServiceState.Red, CheckCorrelationId = Guid.NewGuid() }; try { var response = await this.httpPublishingClient.GetAsync(configurationProvider.GetConfig <string>(Constants.CUIShellHealthEndPoint)); if (response.IsSuccessStatusCode) { // Got a response back serviceStatus.Status = ServiceState.Green; serviceStatus.CheckCorrelationId = Guid.Empty; } else { applicationLogger.Warn($"{nameof(CUIShellHealthCheck)}.{nameof(GetCurrentStatusAsync)} : {Constants.ServiceStatusWarnLogMessage} - Correlation Id [{serviceStatus.CheckCorrelationId}] - Non Success Response StatusCode [{response.StatusCode}] Reason [{response.ReasonPhrase}]"); } } catch (Exception ex) { applicationLogger.ErrorJustLogIt($"{nameof(CUIShellHealthCheck)}.{nameof(GetCurrentStatusAsync)} : {Constants.ServiceStatusFailedLogMessage} - Correlation Id [{serviceStatus.CheckCorrelationId}]", ex); } return(serviceStatus); }
public IHandler GetPipeline() { var pipeLineHandlres = new List <IHandler>(); HandlersCollection handlersCollection = _configurationProvider.GetConfig(); foreach (PipelineConfigItem handler in handlersCollection.Handlers) { pipeLineHandlres.Add(_handlerFactory.GetHandler(handler)); } if (pipeLineHandlres.Count > 0) { IHandler pipeline = null; pipeLineHandlres.ForEach(h => { if (pipeline != null) { pipeline.Next = h; } pipeline = h; }); return(pipeLineHandlres[0]); } return(null); }
public AfTestAppContext CreateContext() { var databaseFaleName = _configurationProvider.GetConfig(DatabaseFileConfigName); AfTestAppContext.CreateDatabaseFile(databaseFaleName); var connection = AfTestAppContext.CreateConnection(databaseFaleName); var context = new AfTestAppContext(connection); return(context); }
public void GetLocationAssetFileAndVersionTest() { var dummyHttpResponseMessage = new HttpResponseMessage() { Content = new StringContent("Dummy Content"), StatusCode = System.Net.HttpStatusCode.InternalServerError }; var expectedAssetFileLocation = $"{CDNLocation}/{DummyAssetFile}"; A.CallTo(() => fakeHTTPClientService.GetAsync(A <string> ._, A <FaultToleranceType> ._)).Returns(dummyHttpResponseMessage); var assetLocationAndVersion = new AssetLocationAndVersion(fakeConfigurationProvider, fakeHTTPClientService, fakeAsyncHelper, fakeWbAppContext, fakeApplicationLogger); A.CallTo(() => fakeConfigurationProvider.GetConfig <string>(A <string> ._)).Returns(CDNLocation); var result = assetLocationAndVersion.GetLocationAssetFileAndVersion(DummyAssetFile); result.Should().StartWith($"{expectedAssetFileLocation}?{DateTime.Now.ToString("yyyyMMdd")}"); }
private static void FillConfigurations() { _groupNames = _configurationProvider.GetConfig("GroupNames", _groupNames); _profilePhotosToLike = _configurationProvider.GetConfig("ProfilePhotosToLike", 2); _minAge = _configurationProvider.GetConfig("MinAge", 17); _maxAge = _configurationProvider.GetConfig("MaxAge", 29); _skipRecentlyLikedProfilesPhotosCount = _configurationProvider.GetConfig("SkipRecentlyLikedProfilesPhotosCount ", 1); _cityIds = _configurationProvider.GetConfig("CityIds", _cityIds); _strategy = _configurationProvider.GetConfig("Strategy", _strategy); var minDateConfig = _configurationProvider.GetConfig("MinDateForPosts"); if (!string.IsNullOrWhiteSpace(minDateConfig)) { MinDateForPosts = DateTime.ParseExact(minDateConfig, "d", CultureInfo.InvariantCulture); } }
public async Task GetServiceStatusAsync(HttpStatusCode returnHttpStatusCode, ServiceState expectedServiceStatus) { //Arrange var httpResponseMessage = new HttpResponseMessage { StatusCode = returnHttpStatusCode }; A.CallTo(() => fakeConfigurationProvider.GetConfig <string>(A <string> ._)).Returns(A.Dummy <string>()); A.CallTo(() => fakeHttpClientService.GetAsync(A <string> ._, A <FaultToleranceType> ._)).Returns(httpResponseMessage); //Act var shellHealthCheck = new CUIShellHealthCheck(fakeApplicationLogger, fakeConfigurationProvider, fakeHttpClientService); var serviceStatus = await shellHealthCheck.GetCurrentStatusAsync(); //Assert serviceStatus.Status.Should().Be(expectedServiceStatus); }
public async Task SendContentPageMessage(MicroServicesPublishingPageData contentPageData, string contentType, string actionType) { applicationLogger.Info($" CREATED service bus message for sitefinity event {actionType.ToUpper()} on ContentPage with Title -- {contentPageData.CanonicalName} and Id -- {contentPageData.ContentPageId.ToString()}"); var connectionStringServiceBus = configurationProvider.GetConfig <string>("DFC.Digital.ServiceBus.ConnectionString"); var topicName = configurationProvider.GetConfig <string>("DFC.Digital.ServiceBus.TopicName"); var topicClient = new TopicClient(connectionStringServiceBus, topicName); // Send Messages var jsonData = JsonConvert.SerializeObject(contentPageData); try { applicationLogger.Info($" SENDING service bus message for sitefinity event {actionType.ToUpper()} on ContentPage with Title -- {contentPageData.CanonicalName} and Id -- {contentPageData.ContentPageId.ToString()} "); // Message that send to the queue var message = new Message(Encoding.UTF8.GetBytes(jsonData)); message.ContentType = "application/json"; message.Label = contentPageData.CanonicalName; message.UserProperties.Add("Id", contentPageData.ContentPageId); message.UserProperties.Add("ActionType", actionType); message.UserProperties.Add("CType", contentType); message.CorrelationId = Guid.NewGuid().ToString(); await topicClient.SendAsync(message); applicationLogger.Info($" SENT SUCCESSFULLY service bus message for sitefinity event {actionType.ToUpper()} on ContentPage with Title -- {contentPageData.CanonicalName} with Id -- {contentPageData.ContentPageId.ToString()} and with Correlation Id -- {message.CorrelationId.ToString()}"); } catch (Exception ex) { applicationLogger.Info($" FAILED service bus message for sitefinity event {actionType.ToUpper()} on ContentPage with Title -- {contentPageData.CanonicalName} with Id -- {contentPageData.ContentPageId.ToString()} has an exception \n {ex.Message} "); } finally { await topicClient.CloseAsync(); } }
private static void FillConfigurations() { _excludeDeletedUsers = true; _reverseTotalList = _configurationProvider.GetConfig("reverseTotalList", false); _wait = _configurationProvider.GetConfig("Wait", 23); _cityIds = _configurationProvider.GetConfig("CityIds", _cityIds); _idsToExclude = _configurationProvider.GetConfig("idsToExclude", _idsToExclude); _deletedUserText = "DELETED"; _secondsToSleepAfterOwnerIdIsIncorrect = 1; _secondsToSleepAfterOtherExceptions = 1; _hoursToSleepAfterFloodControl = 4; _blacklistMembersOfChatId = _configurationProvider.GetConfig("BlacklistMembersOfChatId", _blacklistMembersOfChatId); _blacklistFriendsOfUserId = _configurationProvider.GetConfig("BlacklistFriendsOfUserId", _blacklistFriendsOfUserId); _blackListGroupIds = _configurationProvider.GetConfig("BlackListGroupIds", _blackListGroupIds); _strategy = _configurationProvider.GetConfig("Strategy", _strategy); _groupNames = _configurationProvider.GetConfig("GroupNames", _groupNames) ?? new List <string>(); var minDateConfig = _configurationProvider.GetConfig("MinDateForPostsInBackgroundWork"); if (!string.IsNullOrWhiteSpace(minDateConfig)) { MinDateForPostsBackGroundWork = DateTime.ParseExact(minDateConfig, "d", CultureInfo.InvariantCulture); } }
public async Task <ServiceStatus> GetCurrentStatusAsync() { return(await serviceStatusCUIApp.GetCurrentCUIAppStatusAsync(ServiceName, configurationProvider.GetConfig <string>(Constants.CUIAppJobProfilesHealthEndPoint))); }
private Dictionary <string, string> GetCredentials(string name) { return(_configurationProvider.GetConfig(name).Split(',').ToDictionary(k => k.Split(':').First(), v => v.Split(':').Last())); }
internal override void Initialise() { Database = configuration.GetConfig <string>(Constants.CosmosDbName); DocumentCollection = configuration.GetConfig <string>(Constants.CourseSearchDocumentCollection); }
public CUIContentPagesStatusCheckTests() { fakeServiceStatusCUIApp = A.Fake <IServiceStatusCUIApp>(ops => ops.Strict()); fakeConfigurationProvider = A.Fake <IConfigurationProvider>(ops => ops.Strict()); A.CallTo(() => fakeConfigurationProvider.GetConfig <string>(A <string> ._)).Returns(A.Dummy <string>()); }