public void CreatedDateTimeTest() { var now = new DateTime(2016, 3, 16); _dateTimeService.Setup(ds => ds.UtcNow).Returns(now); IVacancyReadRepository readRepository = new VacancyRepository(_connection, _mapper, _dateTimeService.Object, _logger.Object, _currentUserService.Object, _configurationService.Object); IVacancyWriteRepository writeRepository = new VacancyRepository(_connection, _mapper, _dateTimeService.Object, _logger.Object, _currentUserService.Object, _configurationService.Object); const string title = "Vacancy title"; var vacancyGuid = Guid.NewGuid(); var fixture = new Fixture(); fixture.Customizations.Add( new StringGenerator(() => Guid.NewGuid().ToString().Substring(0, 10))); var vacancy = CreateValidDomainVacancy(); vacancy.VacancyGuid = vacancyGuid; vacancy.Title = title; vacancy.Status = VacancyStatus.Draft; // Changed from PendingQA to Draft because PendingQA is not still in the db vacancy.VacancyManagerId = SeedData.ProviderSites.HopwoodCampus.ProviderSiteId; vacancy.Address.Postcode = "CV1 2WT"; vacancy.Address.County = "West Midlands"; vacancy.VacancyOwnerRelationshipId = SeedData.VacancyOwnerRelationships.TestOne.VacancyOwnerRelationshipId; vacancy.FrameworkCodeName = null; vacancy.SectorCodeName = "ALB"; vacancy.ContractOwnerId = SeedData.Providers.HopwoodHallCollege.ProviderId; vacancy = writeRepository.Create(vacancy); vacancy.Status = VacancyStatus.Submitted; vacancy = writeRepository.Update(vacancy); vacancy.Status = VacancyStatus.Referred; vacancy = writeRepository.Update(vacancy); vacancy.Status = VacancyStatus.Submitted; vacancy = writeRepository.Update(vacancy); vacancy.Status = VacancyStatus.Live; vacancy = writeRepository.Update(vacancy); var entity = readRepository.GetByReferenceNumber(vacancy.VacancyReferenceNumber); entity.CreatedDateTime.Should().Be(now); }
public void SimpleGetTest() { IVacancyReadRepository readRepository = new VacancyRepository(_connection, _mapper, _dateTimeService.Object, _logger.Object, _currentUserService.Object, _configurationService.Object); IVacancyWriteRepository writeRepository = new VacancyRepository(_connection, _mapper, _dateTimeService.Object, _logger.Object, _currentUserService.Object, _configurationService.Object); const string title = "Vacancy title"; var vacancyGuid = Guid.NewGuid(); var fixture = new Fixture(); fixture.Customizations.Add( new StringGenerator(() => Guid.NewGuid().ToString().Substring(0, 10))); var vacancy = CreateValidDomainVacancy(); vacancy.VacancyGuid = vacancyGuid; vacancy.Title = title; vacancy.Status = VacancyStatus.Draft; // Changed from PendingQA to Draft because PendingQA is not still in the db vacancy.VacancyManagerId = SeedData.ProviderSites.HopwoodCampus.ProviderSiteId; vacancy.Address.Postcode = "CV1 2WT"; vacancy.Address.County = "West Midlands"; vacancy.VacancyOwnerRelationshipId = SeedData.VacancyOwnerRelationships.TestOne.VacancyOwnerRelationshipId; vacancy.FrameworkCodeName = null; vacancy.SectorCodeName = "ALB"; vacancy.ContractOwnerId = SeedData.Providers.HopwoodHallCollege.ProviderId; vacancy.Duration = 2; vacancy.DurationType = DurationType.Years; vacancy.ExpectedDuration = "2 years"; writeRepository.Create(vacancy); var entity = readRepository.GetByReferenceNumber(vacancy.VacancyReferenceNumber); entity.AdditionalLocationInformationComment = "AdditionalLocationInformationComment"; writeRepository.Update(entity); entity = readRepository.GetByReferenceNumber(vacancy.VacancyReferenceNumber); entity.ShouldBeEquivalentTo(vacancy, options => ForShallowSave(options) .Excluding(x => x.SelectedMemberPath.EndsWith("Comment")) .Excluding(x => x.VacancyId) .Excluding(x => x.SectorCodeName) // what is this? .Excluding(x => x.Address.PostalAddressId) .Excluding(x => x.Address.ValidationSourceCode) .Excluding(x => x.Address.ValidationSourceKeyValue) .Excluding(x => x.Address.DateValidated) .Excluding(x => x.Address.County) // do a DB lookup .Excluding(x => x.LastEditedById) // Get from VacancyHistory table (not yet implemented) .Excluding(x => x.ClosingDate) .Excluding(x => x.PossibleStartDate) .Excluding(x => x.DateFirstSubmitted) .Excluding(x => x.UpdatedDateTime) .Excluding(x => x.CreatedDateTime) .Excluding(x => x.CreatedByProviderUsername) .Excluding(x => x.VacancyLocationType) .Excluding(x => x.OtherInformation) .Excluding(x => x.LiveClosingDate) .Excluding(x => x.SyntheticUpdatedDateTime) .Excluding(x => x.EmployerName)); entity.AdditionalLocationInformationComment.Should().Be("AdditionalLocationInformationComment"); }