public void SetUpOrganisationTests() { var databaseConnection = new SqlConnection(_databaseService.WebConfiguration.SqlConnectionString); var unitOfWork = new UnitOfWork(databaseConnection); _repository = new RegisterRepository(unitOfWork, new Mock <ILogger <RegisterRepository> >().Object); _validationRepository = new RegisterValidationRepository(unitOfWork); _organisationIdCreated = "EPA0987"; _ukprnCreated = 123321; _org2IdCreated = "EPA0001"; _organisationTypeId = 5; OrganisationTypeHandler.InsertRecord(new OrganisationTypeModel { Id = _organisationTypeId, Status = "new", Type = "organisation type 1" }); _id = Guid.NewGuid(); _organisation = new OrganisationModel { Id = _id, CreatedAt = DateTime.Now, EndPointAssessorName = "name 2", EndPointAssessorOrganisationId = _organisationIdCreated, EndPointAssessorUkprn = _ukprnCreated, PrimaryContact = null, OrganisationTypeId = _organisationTypeId, OrganisationData = null, Status = OrganisationStatus.New }; _organisation2 = new OrganisationModel { Id = Guid.NewGuid(), CreatedAt = DateTime.Now, EndPointAssessorName = "name 1", EndPointAssessorOrganisationId = _org2IdCreated, OrganisationTypeId = null, Status = OrganisationStatus.New }; _username = "******"; OrganisationHandler.InsertRecord(_organisation); OrganisationHandler.InsertRecord(_organisation2); _contactId = Guid.NewGuid(); _contact = new EpaContact { Id = _contactId, EndPointAssessorOrganisationId = _organisationIdCreated, Username = _username, DisplayName = "Joe Cool", Email = "*****@*****.**", PhoneNumber = "555 55555", Status = OrganisationStatus.New, SigninType = "", FirstName = "zzz", LastName = "Ftagn" }; }
public void setup_organisation_is_added() { _organisationStatusId1 = 1; _providerTypeId1 = 10; _organisationTypeId1 = 100; _organisationUkprn = 11114433; _legalName = "Legal name 1"; _organisationId = Guid.NewGuid(); _repository = new OrganisationRepository(_databaseService.WebConfiguration); _status1 = new OrganisationStatusModel { Id = _organisationStatusId1, Status = "Live", CreatedAt = DateTime.Now, CreatedBy = "TestSystem" }; OrganisationStatusHandler.InsertRecord(_status1); _providerType1 = new ProviderTypeModel { Id = _providerTypeId1, ProviderType = "provider type 10", Description = "provider type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live" }; ProviderTypeHandler.InsertRecord(_providerType1); _organisationTypeModel1 = new OrganisationTypeModel { Id = _organisationTypeId1, Type = "organisation type 10", Description = "organisation type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live" }; OrganisationTypeHandler.InsertRecord(_organisationTypeModel1); _organisation = new OrganisationModel { UKPRN = _organisationUkprn, OrganisationTypeId = _organisationTypeId1, ProviderTypeId = _providerTypeId1, StatusId = _organisationStatusId1, StatusDate = DateTime.Today.AddDays(5), LegalName = _legalName, Id = _organisationId, CreatedAt = DateTime.Now, CreatedBy = "Test" }; OrganisationHandler.InsertRecord(_organisation); }
public void Set_up_and_run_update() { _organisationStatusId1 = 1; _organisationStatusId0 = 0; _providerTypeId1 = 10; _organisationTypeId1 = 100; _organisationUkprn = 11114433; _legalName = "Legal name 1"; _organisationId = Guid.NewGuid(); _updateOrganisationRepository = new UpdateOrganisationRepository(_databaseService.DbConnectionHelper); _repository = new OrganisationRepository(_databaseService.DbConnectionHelper); _status1 = new OrganisationStatusModel { Id = _organisationStatusId1, Status = "Live", CreatedAt = DateTime.Now, CreatedBy = "TestSystem" }; OrganisationStatusHandler.InsertRecord(_status1); _status2 = new OrganisationStatusModel { Id = _organisationStatusId0, Status = "Live", CreatedAt = DateTime.Now, CreatedBy = "TestSystem" }; OrganisationStatusHandler.InsertRecord(_status2); _reason1 = new RemovedReasonModel { Id = 1, CreatedBy = "System", Reason = "Test reason", Status = "Live" }; RemovedReasonHandler.InsertRecord(_reason1); _reason2 = new RemovedReasonModel { Id = 2, CreatedBy = "System", Reason = "Test reason 2", Status = "Live" }; RemovedReasonHandler.InsertRecord(_reason2); _providerType1 = new ProviderTypeModel { Id = _providerTypeId1, ProviderType = "provider type 10", Description = "provider type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live" }; ProviderTypeHandler.InsertRecord(_providerType1); _organisationTypeModel1 = new OrganisationTypeModel { Id = _organisationTypeId1, Type = "organisation type 10", Description = "organisation type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live" }; OrganisationTypeHandler.InsertRecord(_organisationTypeModel1); var json = "{ \"CompanyNumber\":\"12345678\",\"CharityNumber\":\"1234567\",\"ParentCompanyGuarantee\":false,\"FinancialTrackRecord\":true,\"NonLevyContract\":false,\"StartDate\":\"2019-03-27 00:00:00\",\"RemovedReason\":{\"Id\":1,\"Reason\":\"Test reason\",\"Description\":null,\"CreatedBy\":\"System\",\"CreatedAt\":\"2019-02-11 15:47:23\",\"UpdatedBy\":null,\"UpdatedAt\":null,\"Status\":\"Live\"}}"; _organisation = new OrganisationModel { UKPRN = _organisationUkprn, OrganisationTypeId = _organisationTypeId1, ProviderTypeId = _providerTypeId1, StatusId = _organisationStatusId1, StatusDate = DateTime.Today.AddDays(5), LegalName = _legalName, Id = _organisationId, CreatedAt = DateTime.Now, CreatedBy = "Test", OrganisationData = json }; OrganisationHandler.InsertRecord(_organisation); _changedBy = "SystemChange"; var _updatedReason = _updateOrganisationRepository.UpdateStatusWithRemovedReason(_organisationId, _organisationStatusId0, _reason2.Id, _changedBy).Result; _successfulUpdate = (_updatedReason != null); _newOrganisationStatusId = _repository.GetOrganisationStatus(_organisationId).Result; }
public void Set_up_and_run_update() { _organisationStatusId1 = 1; _providerTypeId1 = 10; _providerTypeId2 = 20; _organisationTypeId1 = 100; _organisationTypeId2 = 111; _organisationUkprn = 11114433; _legalName = "Legal name 1"; _organisationId = Guid.NewGuid(); _updateOrganisationRepository = new UpdateOrganisationRepository(_databaseService.DbConnectionHelper); _repository = new OrganisationRepository(_databaseService.DbConnectionHelper); _status1 = new OrganisationStatusModel { Id = _organisationStatusId1, Status = "Live", CreatedAt = DateTime.Now, CreatedBy = "TestSystem" }; OrganisationStatusHandler.InsertRecord(_status1); _providerType1 = new ProviderTypeModel { Id = _providerTypeId1, ProviderType = "provider type 10", Description = "provider type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live" }; ProviderTypeHandler.InsertRecord(_providerType1); _providerType2 = new ProviderTypeModel { Id = _providerTypeId2, ProviderType = "provider type 12", Description = "provider type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live" }; ProviderTypeHandler.InsertRecord(_providerType2); _organisationTypeModel1 = new OrganisationTypeModel { Id = _organisationTypeId1, Type = "organisation type 10", Description = "organisation type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live" }; OrganisationTypeHandler.InsertRecord(_organisationTypeModel1); _organisationTypeModel2 = new OrganisationTypeModel { Id = _organisationTypeId2, Type = "organisation type 22", Description = "organisation type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live" }; OrganisationTypeHandler.InsertRecord(_organisationTypeModel2); _organisation = new OrganisationModel { UKPRN = _organisationUkprn, OrganisationTypeId = _organisationTypeId1, ProviderTypeId = _providerTypeId1, StatusId = _organisationStatusId1, StatusDate = DateTime.Today.AddDays(5), LegalName = _legalName, Id = _organisationId, CreatedAt = DateTime.Now, CreatedBy = "Test" }; OrganisationHandler.InsertRecord(_organisation); _changedBy = "SystemChange"; _successfulUpdate = _updateOrganisationRepository.UpdateProviderTypeAndOrganisationType(_organisationId, _providerTypeId2, _organisationTypeId2, _changedBy).Result; _newProviderType = _repository.GetProviderType(_organisationId).Result; _newOrganisationType = _repository.GetOrganisationType(_organisationId).Result; }
public void Set_up_and_run_update() { _organisationStatusId = 1; _providerTypeId = 10; _organisationTypeId = 100; _applicationDeterminedate = DateTime.Today; _newApplicationDeterminedDate = DateTime.Today.AddDays(-1); _organisationUkprn = 11114433; _organisationId = Guid.NewGuid(); _updateOrganisationRepository = new UpdateOrganisationRepository(_databaseService.DbConnectionHelper); _repository = new OrganisationRepository(_databaseService.DbConnectionHelper); _status = new OrganisationStatusModel { Id = _organisationStatusId, Status = "Live", CreatedAt = DateTime.Now, CreatedBy = "TestSystem" }; OrganisationStatusHandler.InsertRecord(_status); _providerType = new ProviderTypeModel { Id = _providerTypeId, ProviderType = "provider type 10", Description = "provider type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live" }; ProviderTypeHandler.InsertRecord(_providerType); _organisationTypeModel = new OrganisationTypeModel { Id = _organisationTypeId, Type = "organisation type 10", Description = "organisation type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live" }; OrganisationTypeHandler.InsertRecord(_organisationTypeModel); var organisationData = new OrganisationData { ApplicationDeterminedDate = _applicationDeterminedate }; _organisation = new OrganisationModel { UKPRN = _organisationUkprn, OrganisationTypeId = _organisationTypeId, ProviderTypeId = _providerTypeId, StatusId = _organisationStatusId, StatusDate = DateTime.Today.AddDays(5), LegalName = "legal name", Id = _organisationId, CreatedAt = DateTime.Now, CreatedBy = "Test", OrganisationData = JsonConvert.SerializeObject(organisationData) }; OrganisationHandler.InsertRecord(_organisation); _originalDeterminedDate = _repository.GetApplicationDeterminedDate(_organisationId).Result; _changedBy = "SystemChange"; _successfulUpdate = _updateOrganisationRepository.UpdateApplicationDeterminedDate(_organisationId, _newApplicationDeterminedDate.Value, _changedBy).Result; _newApplicationDeterminedDate = _repository.GetApplicationDeterminedDate(_organisationId).Result; }
public void ExpectedLatestDateIsReturnedWithUpdatedTakingPrecedence(DateTime createdDate, DateTime?updatedDate, DateTime previousCreatedDate, DateTime?previousUpdatedDate, DateTime expectedLatestDate, int organisationStatusId) { var expectedLatest = updatedDate ?? createdDate; if (organisationStatusId == 3) { expectedLatest = previousUpdatedDate ?? previousCreatedDate; } _organisation = new OrganisationModel { UKPRN = _organisationUkprn, OrganisationTypeId = _organisationTypeId1, ProviderTypeId = _providerTypeId1, StatusId = organisationStatusId, StatusDate = DateTime.Today.AddDays(5), LegalName = _legalName, Id = _organisationId, CreatedAt = createdDate, UpdatedAt = updatedDate, CreatedBy = "Test" }; var _organisationOld = new OrganisationModel { UKPRN = _organisationUkprn2, OrganisationTypeId = _organisationTypeId1, ProviderTypeId = _providerTypeId1, StatusId = OrganisationStatusHandler.Active, StatusDate = DateTime.Today.AddDays(5), LegalName = _legalName, Id = _organisationId2, CreatedAt = previousCreatedDate, UpdatedAt = previousUpdatedDate, CreatedBy = "Test" }; OrganisationHandler.InsertRecord(_organisation); OrganisationHandler.InsertRecord(_organisationOld); var latestDate = _repository.GetLatestNonOnboardingOrganisationChangeDate().Result; Assert.AreEqual(expectedLatest.ToString("F"), latestDate.Value.ToString("F")); OrganisationHandler.DeleteAllRecords(); }
public void Set_up_and_run_update() { _organisationStatusId1 = 1; _providerTypeId1 = 10; _organisationTypeId1 = 100; _organisationUkprn = 11114433; _organisationId = Guid.NewGuid(); _parentCompanyGuarantee = true; _parentCompanyGuaranteeAfterChange = false; _updateOrganisationRepository = new UpdateOrganisationRepository(_databaseService.WebConfiguration); _repository = new OrganisationRepository(_databaseService.WebConfiguration); _status1 = new OrganisationStatusModel { Id = _organisationStatusId1, Status = "Live", CreatedAt = DateTime.Now, CreatedBy = "TestSystem" }; OrganisationStatusHandler.InsertRecord(_status1); _providerType1 = new ProviderTypeModel { Id = _providerTypeId1, ProviderType = "provider type 10", Description = "provider type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live" }; ProviderTypeHandler.InsertRecord(_providerType1); _organisationTypeModel1 = new OrganisationTypeModel { Id = _organisationTypeId1, Type = "organisation type 10", Description = "organisation type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live" }; OrganisationTypeHandler.InsertRecord(_organisationTypeModel1); var organisationData = new OrganisationData { ParentCompanyGuarantee = _parentCompanyGuarantee }; _organisation = new OrganisationModel { UKPRN = _organisationUkprn, OrganisationTypeId = _organisationTypeId1, ProviderTypeId = _providerTypeId1, StatusId = _organisationStatusId1, StatusDate = DateTime.Today.AddDays(5), LegalName = "legal name", Id = _organisationId, CreatedAt = DateTime.Now, CreatedBy = "Test", OrganisationData = JsonConvert.SerializeObject(organisationData) }; OrganisationHandler.InsertRecord(_organisation); _originalParentCompanyGuarantee = _repository.GetParentCompanyGuarantee(_organisationId).Result; _changedBy = "SystemChange"; _successfulUpdate = _updateOrganisationRepository.UpdateParentCompanyGuarantee(_organisationId, _parentCompanyGuaranteeAfterChange, _changedBy).Result; _newParentCompanyGuarantee = _repository.GetParentCompanyGuarantee(_organisationId).Result; }
public void Set_up_and_run_update() { _organisationStatusId1 = 1; _providerTypeId1 = 10; _organisationTypeId1 = 100; _organisationUkprn = 11114433; _tradingName = "Trading name 1"; _tradingNameAfterChange = "Trading Name Version 2"; _organisationId = Guid.NewGuid(); _updateRepository = new UpdateOrganisationRepository(_databaseService.WebConfiguration); _repository = new OrganisationRepository(_databaseService.WebConfiguration); _status1 = new OrganisationStatusModel { Id = _organisationStatusId1, Status = "Live", CreatedAt = DateTime.Now, CreatedBy = "TestSystem" }; OrganisationStatusHandler.InsertRecord(_status1); _providerType1 = new ProviderTypeModel { Id = _providerTypeId1, ProviderType = "provider type 10", Description = "provider type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live" }; ProviderTypeHandler.InsertRecord(_providerType1); _organisationTypeModel1 = new OrganisationTypeModel { Id = _organisationTypeId1, Type = "organisation type 10", Description = "organisation type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live" }; OrganisationTypeHandler.InsertRecord(_organisationTypeModel1); _organisation = new OrganisationModel { UKPRN = _organisationUkprn, OrganisationTypeId = _organisationTypeId1, ProviderTypeId = _providerTypeId1, StatusId = _organisationStatusId1, StatusDate = DateTime.Today.AddDays(5), TradingName = _tradingName, LegalName = "Legal Name 1", Id = _organisationId, CreatedAt = DateTime.Now, CreatedBy = "Test" }; OrganisationHandler.InsertRecord(_organisation); _originalTradingName = _repository.GetTradingName(_organisationId).Result; _changedBy = "SystemChange"; _successfulUpdate = _updateRepository.UpdateTradingName(_organisationId, _tradingNameAfterChange, _changedBy).Result; _newTradingName = _repository.GetTradingName(_organisationId).Result; }
public void setup_organisation_is_added() { _organisationStatusId1 = 1; _providerTypeId1 = 10; _organisationTypeId1 = 100; _organisationUkprn = 11114433; _organisationId = Guid.NewGuid(); _parentCompanyGuarantee = true; _repository = new OrganisationRepository(_databaseService.DbConnectionHelper); _status1 = new OrganisationStatusModel { Id = _organisationStatusId1, Status = "Live", CreatedAt = DateTime.Now, CreatedBy = "TestSystem" }; OrganisationStatusHandler.InsertRecord(_status1); _providerType1 = new ProviderTypeModel { Id = _providerTypeId1, ProviderType = "provider type 10", Description = "provider type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live" }; ProviderTypeHandler.InsertRecord(_providerType1); _organisationTypeModel1 = new OrganisationTypeModel { Id = _organisationTypeId1, Type = "organisation type 10", Description = "organisation type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live" }; OrganisationTypeHandler.InsertRecord(_organisationTypeModel1); var organisationData = new OrganisationData { ParentCompanyGuarantee = _parentCompanyGuarantee }; _organisation = new OrganisationModel { UKPRN = _organisationUkprn, OrganisationTypeId = _organisationTypeId1, ProviderTypeId = _providerTypeId1, StatusId = _organisationStatusId1, StatusDate = DateTime.Today.AddDays(5), LegalName = "legal name 1", Id = _organisationId, CreatedAt = DateTime.Now, CreatedBy = "Test", OrganisationData = JsonConvert.SerializeObject(organisationData) }; OrganisationHandler.InsertRecord(_organisation); }
public void ExpectedLatestDateIsReturnedWithUpdatedTakingPrecedence(int secondOrganisationStatusId, int recordsExpected, string testDescription) { _organisation = new OrganisationModel { UKPRN = _organisationUkprn, OrganisationTypeId = _organisationTypeId1, ProviderTypeId = _providerTypeId1, StatusId = secondOrganisationStatusId, StatusDate = DateTime.Today.AddDays(5), LegalName = _legalName, Id = _organisationId, CreatedAt = DateTime.Now, UpdatedAt = null, CreatedBy = "Test" }; var organisation2 = new OrganisationModel { UKPRN = _organisationUkprn2, OrganisationTypeId = _organisationTypeId1, ProviderTypeId = _providerTypeId1, StatusId = OrganisationStatusHandler.Active, StatusDate = DateTime.Today.AddDays(5), LegalName = _legalName, Id = _organisationId2, CreatedAt = DateTime.Now.AddDays(-1), UpdatedAt = DateTime.Now, CreatedBy = "Test" }; OrganisationHandler.InsertRecord(_organisation); OrganisationHandler.InsertRecord(organisation2); var registerDetails = _repository.GetRoatpSummary().Result; Assert.AreEqual(recordsExpected, registerDetails.Count()); OrganisationHandler.DeleteAllRecords(); }
public void SetUpOrganisationTests() { _repository = new RegisterRepository(_databaseService.WebConfiguration, new Mock <ILogger <RegisterRepository> >().Object); _validationRepository = new RegisterValidationRepository(_databaseService.WebConfiguration); _organisationIdCreated = "EPA0987"; _organisationTypeId = 5; OrganisationTypeHandler.InsertRecord(new OrganisationTypeModel { Id = _organisationTypeId, Status = "new", Type = "organisation type 1" }); _id = Guid.NewGuid(); _organisation = new OrganisationModel { Id = _id, CreatedAt = DateTime.Now, EndPointAssessorName = "name 2", EndPointAssessorOrganisationId = _organisationIdCreated, PrimaryContact = null, OrganisationTypeId = _organisationTypeId, OrganisationData = null, Status = OrganisationStatus.New }; _username = "******"; OrganisationHandler.InsertRecord(_organisation); _contactId = Guid.NewGuid(); _contactModel = new OrganisationContactModel { Id = _contactId, EndPointAssessorOrganisationId = _organisationIdCreated, OrganisationId = _id, Username = _username, DisplayName = "Joe Cool", Email = "*****@*****.**", PhoneNumber = "555 55555", Status = OrganisationStatus.Live }; _contactBeforeChange = new EpaContact { Id = _contactId, EndPointAssessorOrganisationId = _organisationIdCreated, Username = _username, DisplayName = "Joe Cool", Email = "*****@*****.**", PhoneNumber = "555 55555", Status = OrganisationStatus.Live }; _contactUpdated = new EpaContact { Id = _contactId, EndPointAssessorOrganisationId = _organisationIdCreated, Username = _username, DisplayName = "Joe Cool changes", Email = "*****@*****.**", PhoneNumber = "555 44444", Status = OrganisationStatus.Live }; OrganisationContactHandler.InsertRecord(_contactModel); }