public async Task Arrange() { MappingBootstrapper.Initialize(); var userNameToFind = "NotFoundUser"; var contacts = new List <Contact> { Builder <Contact> .CreateNew() .With(q => q.Username = userNameToFind) .Build() }.AsQueryable(); var mockSet = contacts.CreateMockSet(contacts); var mockDbContext = CreateMockDbContext(mockSet); var contactRepository = new ContactRepository(mockDbContext.Object, new Mock <IUnitOfWork>().Object); try { await contactRepository.Delete("testuser"); } catch (Exception exception) { _exception = exception; } }
public async Task Arrange() { MappingBootstrapper.Initialize(); var organisations = new List <Organisation> { Builder <Organisation> .CreateNew() .With(q => q.EndPointAssessorUkprn = 10000000) .Build() }.AsQueryable(); var mockSet = organisations.CreateMockSet(organisations); var mockDbContext = CreateMockDbContext(mockSet); _organisationRepository = new OrganisationRepository(mockDbContext.Object); try { await _organisationRepository.Delete("123456"); } catch (Exception exception) { _exception = exception; } }
public void Arrange() { MappingBootstrapper.Initialize(); var certificates = Builder <CertificateHistoryModel> .CreateListOfSize(10) .All() .With(x => x.CertificateLogs = Builder <CertificateLog> .CreateListOfSize(2) .TheFirst(1) .With(q => q.Status = CertificateStatus.Submitted) .With(q => q.Action = CertificateActions.Submit) .With(q => q.Username = SubmitUsername) .With(q => q.EventTime = SubmitDateTime) .TheNext(1) .With(q => q.Status = CertificateStatus.Submitted) .With(q => q.Action = CertificateActions.Status) .With(q => q.Username = SystemUsers.PrintFunction) .With(q => q.EventTime = SubmitDateTime.AddDays(1)) .Build().ToList()) .Build().ToList(); _certificateRepositoryMock = new Mock <ICertificateRepository>(); _certificateRepositoryMock .Setup(r => r.GetCertificateHistory( It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <List <string> >())) .ReturnsAsync(new PaginatedList <CertificateHistoryModel>(certificates, 40, 1, ResultPageSize)); _contactQueryRepositoryMock = new Mock <IContactQueryRepository>(); _contactQueryRepositoryMock.Setup(r => r.GetContact(SubmitUsername)).ReturnsAsync(new Contact { DisplayName = SubmitDisplayname }); _roatpApiClientMock = new Mock <IRoatpApiClient>(); _roatpApiClientMock.Setup(r => r.GetOrganisationByUkprn(It.IsAny <long>())) .ReturnsAsync(new OrganisationSearchResult { ProviderName = "TestProvider", Ukprn = 123456789 }); _loggermock = new Mock <ILogger <GetCertificatesHistoryHandler> >(); var sut = new GetCertificatesHistoryHandler(_certificateRepositoryMock.Object, _roatpApiClientMock.Object, _contactQueryRepositoryMock.Object, _loggermock.Object); _result = sut.Handle(new GetCertificateHistoryRequest { PageIndex = 1, EndPointAssessorOrganisationId = "12345677" }, new CancellationToken()) .Result; }
public void Arrange() { var mediator = new Mock <IMediator>(); MappingBootstrapper.Initialize(); var certificateHistoryResponses = Builder <CertificateSummaryResponse> .CreateListOfSize(10).Build().ToList(); var certificateHistoryPaginatedList = new PaginatedList <CertificateSummaryResponse>(certificateHistoryResponses, 40, 1, 10); mediator.Setup(q => q.Send(Moq.It.IsAny <GetCertificateHistoryRequest>(), new CancellationToken())) .Returns(Task.FromResult((certificateHistoryPaginatedList))); var certificateQueryControler = new CertificateQueryController(mediator.Object); var statuses = new List <string> { "Submitted" }; int page = 1; string userName = "******"; string searchTerm = "test"; string sortColumn = "DateRequested"; int sortDescending = 1; _result = certificateQueryControler.GetCertificatesHistory(page, userName, searchTerm, sortColumn, sortDescending).Result; }
public void Arrange() { MappingBootstrapper.Initialize(); var mockSet = CreateCertificateMockDbSet(); _mockDbContext = CreateMockDbContext(mockSet); _mockUnitOfWork = new Mock <IUnitOfWork>(); _certificateRepository = new CertificateRepository(_mockUnitOfWork.Object, _mockDbContext.Object); }
public async Task Arrange() { MappingBootstrapper.Initialize(); _batchLogQueryRepository = new Mock <IBatchLogQueryRepository>(); _batchLogQueryRepository.Setup(r => r.GetLastBatchLog()).Returns(Task.FromResult(_batchLog)); var getBatchLogHandler = new GetLastBatchLogHandler(_batchLogQueryRepository.Object); _response = await getBatchLogHandler.Handle(new GetLastBatchLogRequest(), new CancellationToken()); }
public async Task Arrange() { MappingBootstrapper.Initialize(); _batchLogQueryRepository = new Mock <IBatchLogQueryRepository>(); _batchLogQueryRepository.Setup(r => r.Get(It.IsAny <int>())).Returns(Task.FromResult(_batchLog)); var sut = new GetBatchLogHandler(_batchLogQueryRepository.Object); _response = await sut.Handle(new GetBatchLogRequest { BatchNumber = _batchNumber }, new CancellationToken()); }
public void Arrange() { MappingBootstrapper.Initialize(); var organisation = Builder <Organisation> .CreateNew().Build(); var mockSet = CreateMockDbSet(); _mockDbContext = CreateMockDbContext(mockSet); _organisationRepository = new OrganisationRepository(_mockDbContext.Object); _result = _organisationRepository.CreateNewOrganisation(organisation).Result; }
public void Arrange() { MappingBootstrapper.Initialize(); var mockSet = CreateCertificateMockDbSet(); _mockDbContext = CreateMockDbContext(mockSet); _mockUnitOfWork = new Mock <IUnitOfWork>(); _certificateRepository = new CertificateRepository(_mockUnitOfWork.Object, _mockDbContext.Object); _result = _certificateRepository.GetCertificateByOrgIdLastname(1111111111, "EPA0001", "Hawkins").Result; }
public void Arrange() { MappingBootstrapper.Initialize(); var contactCreateDomainModel = Builder <Contact> .CreateNew().Build(); var mockSet = CreateMockSet(); CreateMockDbCOntext(mockSet); _contactRepository = new ContactRepository(_assessorDbContext.Object, new Mock <IDbConnection>().Object); _result = _contactRepository.CreateNewContact(contactCreateDomainModel).Result; }
public void Arrange() { Setup(); MappingBootstrapper.Initialize(); _contactResponse = Builder <Contact> .CreateNew().Build(); ContactQueryRepositoryMock.Setup(q => q.GetContact(Moq.It.IsAny <string>())) .Returns(Task.FromResult((_contactResponse))); _result = ContactQueryController.SearchContactByUserName("TestUser").Result; }
public void Arrange() { var mediator = new Mock <IMediator>(); MappingBootstrapper.Initialize(); var certificateResponses = Builder <CertificateResponse> .CreateListOfSize(10).Build().ToList(); mediator.Setup(q => q.Send(Moq.It.IsAny <GetToBePrintedCertificatesRequest>(), new CancellationToken())) .Returns(Task.FromResult((certificateResponses))); var certificateQueryControler = new CertificateQueryController(mediator.Object); _result = certificateQueryControler.GetCertificatesToBePrinted().Result; }
public void Arrange() { MappingBootstrapper.Initialize(); var mockSet = CreateCertificateMockDbSet(); _mockDbContext = CreateMockDbContext(mockSet); _mockUnitOfWork = new Mock <IUnitOfWork>(); _certificateRepository = new CertificateRepository(_mockUnitOfWork.Object, _mockDbContext.Object); _result = _certificateRepository.GetCertificates(new List <string> { "Reprint", "Submitted" }).Result; }
public void Arrange() { MappingBootstrapper.Initialize(); _certificateId = Guid.NewGuid(); var mockSet = CreateCertificateMockDbSet(); _mockDbContext = CreateMockDbContext(mockSet); _mockUnitOfWork = new Mock <IUnitOfWork>(); _certificateRepository = new CertificateRepository(_mockUnitOfWork.Object, _mockDbContext.Object); _result = _certificateRepository.GetCertificate(_certificateId).Result; }
public void ShouldBeAbleToMapDTOToModel() { MappingBootstrapper.Initialise(); Mapper.AssertConfigurationIsValid(); var address = "XXXX"; var musicRecording = new MusicRecordingDTO(); musicRecording.Address = address; musicRecording.Name = "my great track"; var musicRecordingModel = new MusicRecording(); Mapper.Map(musicRecording, musicRecordingModel); Assert.Equal(musicRecordingModel.Address, address); }
public void Arrange() { Setup(); MappingBootstrapper.Initialize(); var contact = new ContactBoolResponse(true); Mediator.Setup(q => q.Send(Moq.It.IsAny <CreateContactRequest>(), Moq.It.IsAny <CancellationToken>())) .Returns(Task.FromResult((contact))); var contactRequest = new CreateContactRequest(Moq.It.IsAny <string>(), Moq.It.IsAny <string>(), Moq.It.IsAny <string>(), Moq.It.IsAny <string>(), Moq.It.IsAny <string>()); _result = ContactController.CreateContact(contactRequest).Result; }
public void Arrange() { Setup(); MappingBootstrapper.Initialize(); var contacts = Builder <Contact> .CreateListOfSize(10).Build().AsEnumerable(); ContactQueryRepositoryMock.Setup(q => q.GetContactsForEpao(Moq.It.IsAny <string>())) .Returns(Task.FromResult((contacts))); OrganisationQueryRepositoryMock.Setup(q => q.CheckIfAlreadyExists(Moq.It.IsAny <string>())) .Returns(Task.FromResult <bool>(true)); var endPointAssessorOrganisationId = "EPA1234"; _result = ContactQueryController.SearchContactsForAnOrganisation(endPointAssessorOrganisationId).Result; }
public void Arrange() { MappingBootstrapper.Initialize(); var mockSet = CreateCertificateMockDbSet(); _mockDbContext = CreateMockDbContext(mockSet); _mockDbConnection = new Mock <IDbConnection>(); _certificateRepository = new CertificateRepository(_mockDbContext.Object, _mockDbConnection.Object); _certificateRepository = new CertificateRepository(_mockDbContext.Object, new Mock <IDbConnection>().Object); _result = _certificateRepository.GetCertificateByUlnLastname(1111111111, "Hawkins").Result; }
public void Arrange() { MappingBootstrapper.Initialize(); var certificateData = JsonConvert.SerializeObject(Builder <CertificateData> .CreateNew().Build()); var certificates = Builder <Certificate> .CreateListOfSize(10) .All().With(q => q.CertificateData = certificateData).Build().ToList(); _certificateRepository = new Mock <ICertificateRepository>(); _certificateRepository.Setup(r => r.GetCertificates(It.IsAny <List <string> >())).Returns(Task.FromResult(certificates)); var getCertificatesHandler = new GetCertificatesHandler(_certificateRepository.Object); _result = getCertificatesHandler.Handle(new GetCertificatesRequest(), new CancellationToken()) .Result; }
public void Arrange() { MappingBootstrapper.Initialize(); CreateContractRepositoryMock(); CreateOrganisationRepositoryMock(); var createOrganisationRequest = Builder <CreateOrganisationRequest> .CreateNew().Build(); var organisationQueryRepository = CreateOrganisationQueryRepository(); var createOrganisationHandler = new CreateOrganisationHandler(_organisationRepositoryMock.Object, organisationQueryRepository.Object, _contactRepositoryMock.Object); _result = createOrganisationHandler.Handle(createOrganisationRequest, new CancellationToken()).Result; }
public void Arrange() { MappingBootstrapper.Initialize(); var certificateData = JsonConvert.SerializeObject(Builder <CertificateData> .CreateNew().Build()); var certificates = Builder <Certificate> .CreateListOfSize(10) .All() .With(q => q.CertificateData = certificateData) .With(x => x.CertificateLogs = Builder <CertificateLog> .CreateListOfSize(1).All() .With(q => q.Status = Domain.Consts.CertificateStatus.Submitted).Build().ToList()) .With(x => x.Organisation = Builder <Organisation> .CreateNew().Build() ).Build().ToList(); _certificateRepositoryMock = new Mock <ICertificateRepository>(); _certificateRepositoryMock.Setup(r => r.GetCertificateHistory(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <List <string> >())) .ReturnsAsync(new PaginatedList <Certificate>(certificates, 40, 1, 10)); _contactQueryRepositoryMock = new Mock <IContactQueryRepository>(); _contactQueryRepositoryMock.Setup(r => r.GetContact(It.IsAny <string>())).ReturnsAsync(new Contact { DisplayName = "Test Name" }); _assessmentOrgsApiClientMock = new Mock <IAssessmentOrgsApiClient>(); _assessmentOrgsApiClientMock.Setup(r => r.GetProvider(It.IsAny <long>())) .ReturnsAsync(new Provider { ProviderName = "TestProvider", Ukprn = 123456789 }); _loggermock = new Mock <ILogger <GetCertificatesHistoryHandler> >(); var getCertificatesHistoryHandler = new GetCertificatesHistoryHandler(_certificateRepositoryMock.Object, _assessmentOrgsApiClientMock.Object, _contactQueryRepositoryMock.Object, _loggermock.Object); _result = getCertificatesHistoryHandler.Handle(new GetCertificateHistoryRequest { PageIndex = 1, EndPointAssessorOrganisationId = "12345677" }, new CancellationToken()) .Result; }
protected void Application_Start() { ViewEngines.Engines.Clear(); ViewEngines.Engines.Add(new RazorViewEngine()); Database.SetInitializer(new MigrateDatabaseToLatestVersion <ApplicationDbContext, Configuration>()); AutofacConfig.RegisterAutofac(); AreaRegistration.RegisterAllAreas(); GlobalFilters.Filters.Add(new RequireHttpsAttribute()); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); var config = new HttpConfiguration(); JsonConfiguration.UseCamelCase(); WebApiConfiguration.Register(config); MappingBootstrapper.Init(); }
public void Arrange() { MappingBootstrapper.Initialize(); var organisation = Builder <Certificate> .CreateNew().Build(); var mockSet = CreateCertificateMockDbSet(); _mockDbContext = CreateMockDbContext(mockSet); _certificateRepository = new CertificateRepository(_mockDbContext.Object, new Mock <IDbConnection>().Object); _mockDbConnection = new Mock <IDbConnection>(); _certificateRepository = new CertificateRepository(_mockDbContext.Object, _mockDbConnection.Object); _result = _certificateRepository.GetCertificates(new List <string> { "Reprint", "Submitted" }).Result; }
public void Arrange() { MappingBootstrapper.Initialize(); var organisation = Builder <Certificate> .CreateNew().Build(); var mockSet = CreateCertificateMockDbSet(); _mockDbContext = CreateMockDbContext(mockSet); _mockDbConnection = new Mock <IDbConnection>(); _certificateRepository = new CertificateRepository(_mockDbContext.Object, _mockDbConnection.Object); _certificateRepository = new CertificateRepository(_mockDbContext.Object, new Mock <IDbConnection>().Object); _result = _certificateRepository.GetPrivateCertificate(1111111111, "EPA0001").Result; }
public void Arrange() { MappingBootstrapper.Initialize(); var organisationUpdateDomainModel = Builder <Organisation> .CreateNew() .With(q => q.PrimaryContact = _primaryContact) .Build(); var primaryContactId = Guid.NewGuid(); var organisationMockDbSet = CreateOrganisationMockDbSet(primaryContactId); var contactsMockDbSet = CreateContactsMockDbSet(primaryContactId); var mockDbContext = CreateMockDbContext(organisationMockDbSet, contactsMockDbSet); var organisationRepository = new OrganisationRepository(mockDbContext.Object); _result = organisationRepository.UpdateOrganisation(organisationUpdateDomainModel).Result; }
public void ShouldBeAbleToMapOtherArtitsDTOToModel() { MappingBootstrapper.Initialise(); Mapper.AssertConfigurationIsValid(); var address = "XXXX"; var otherArtitsAddress = "ArtistXXXXX"; var musicRecording = new MusicRecordingDTO(); musicRecording.Address = address; musicRecording.OtherArtists.Add(new CreativeWorkArtistDTO() { ArtistAddres = otherArtitsAddress }); var musicRecordingModel = new MusicRecording(); Mapper.Map(musicRecording, musicRecordingModel); Assert.Equal(musicRecordingModel.Address, address); Assert.Equal(musicRecordingModel.OtherArtists.First().ArtistAddres, otherArtitsAddress); }
public async Task Arrange() { MappingBootstrapper.Initialize(); var organisations = new List <Organisation> { Builder <Organisation> .CreateNew() .With(q => q.EndPointAssessorOrganisationId = "123456") .With(q => q.Status = OrganisationStatus.Live) .With(q => q.EndPointAssessorUkprn = 10000000) .Build() }.AsQueryable(); var mockSet = organisations.CreateMockSet(organisations); _mockDbContext = CreateMockDbContext(mockSet); _organisationRepository = new OrganisationRepository(_mockDbContext.Object); await _organisationRepository.Delete("123456"); }
public void Arrange() { MappingBootstrapper.Initialize(); _orgRepos = new Mock <IOrganisationRepository>(); _contactRepository = new Mock <IContactRepository>(); var orgQueryRepos = new Mock <IOrganisationQueryRepository>(); orgQueryRepos.Setup(r => r.GetByUkPrn(It.IsAny <long>())).ReturnsAsync(new Organisation() { Status = OrganisationStatus.Deleted, EndPointAssessorOrganisationId = "12345" }); _orgRepos.Setup(r => r.UpdateOrganisation(It.IsAny <Organisation>())) .ReturnsAsync(new Organisation()); _handler = new CreateOrganisationHandler(_orgRepos.Object, orgQueryRepos.Object, _contactRepository.Object); }
public void Arrange() { MappingBootstrapper.Initialize(); var certificateData = JsonConvert.SerializeObject(Builder <CertificateData> .CreateNew().With(cd => cd.OverallGrade = CertificateGrade.Pass).Build()); var failedCertData = JsonConvert.SerializeObject(Builder <CertificateData> .CreateNew().With(cd => cd.OverallGrade = CertificateGrade.Fail).Build()); var certificates = Builder <Certificate> .CreateListOfSize(10) .TheFirst(6).With(q => q.CertificateData = certificateData) .TheNext(1).With(q => q.CertificateData = failedCertData) .TheNext(3).With(q => q.CertificateData = certificateData) .Build().ToList(); _certificateRepository = new Mock <ICertificateRepository>(); _certificateRepository.Setup(r => r.GetCertificates(It.IsAny <List <string> >())).Returns(Task.FromResult(certificates)); var getCertificatesToBePrintedHandler = new GetCertificatesToBePrintedHandler(_certificateRepository.Object, Mock.Of <ILogger <GetCertificatesHistoryHandler> >()); _result = getCertificatesToBePrintedHandler.Handle(new GetToBePrintedCertificatesRequest(), new CancellationToken()) .Result; }
public async Task Arrange() { MappingBootstrapper.Initialize(); _mockDbContext = new Mock <AssessorDbContext>(); var contacts = new List <Contact> { Builder <Contact> .CreateNew() .With(q => q.Username = "******") .Build() }.AsQueryable(); var mockSet = contacts.CreateMockSet(contacts); _mockDbContext.Setup(q => q.Contacts).Returns(mockSet.Object); _mockDbContext.Setup(x => x.MarkAsModified(Moq.It.IsAny <Contact>())); _mockDbContext.Setup(q => q.SaveChangesAsync(new CancellationToken())) .Returns(Task.FromResult((Moq.It.IsAny <int>()))); var contactRepository = new ContactRepository(_mockDbContext.Object, new Mock <IUnitOfWork>().Object); await contactRepository.Delete("1234"); }