示例#1
0
        public When_OpportunityService_Is_Called_To_Save_EmployerDetail()
        {
            var config = new MapperConfiguration(c => c.AddMaps(typeof(OpportunityMapper).Assembly));
            var mapper = new Mapper(config);

            _opportunityRepository = Substitute.For <IOpportunityRepository>();
            var opportunityItemRepository       = Substitute.For <IRepository <OpportunityItem> >();
            var provisionGapRepository          = Substitute.For <IRepository <ProvisionGap> >();
            var referralRepository              = Substitute.For <IRepository <Domain.Models.Referral> >();
            var googleMapApiClient              = Substitute.For <IGoogleMapApiClient>();
            var opportunityPipelineReportWriter = Substitute.For <IFileWriter <OpportunityReportDto> >();
            var dateTimeProvider = Substitute.For <IDateTimeProvider>();

            _opportunityRepository.GetSingleOrDefaultAsync(Arg.Any <Expression <Func <Domain.Models.Opportunity, bool> > >()).Returns(new Domain.Models.Opportunity {
                Id = OpportunityId
            });

            var opportunityService = new OpportunityService(mapper, _opportunityRepository, opportunityItemRepository,
                                                            provisionGapRepository, referralRepository, googleMapApiClient,
                                                            opportunityPipelineReportWriter, dateTimeProvider);

            var dto = new EmployerDetailDto
            {
                OpportunityId  = OpportunityId,
                PrimaryContact = Contact,
                Email          = ContactEmail,
                Phone          = ContactPhone,
                ModifiedBy     = ModifiedBy
            };

            opportunityService.UpdateOpportunityAsync(dto).GetAwaiter().GetResult();
        }