示例#1
0
        public async Task Then_Do_Not_Delete_Opportunity(
            [Frozen] IOpportunityRepository opportunityRepo,
            [Frozen] IRepository <OpportunityItem> opportunityItemRepo,
            [Frozen] IRepository <Domain.Models.Referral> referralRepo,
            [Frozen] IRepository <ProvisionGap> provisionGapRepo,
            OpportunityItem opportunityItem,
            OpportunityService sut)
        {
            //Arrange
            opportunityItem.IsSaved = true;

            opportunityItemRepo.GetManyAsync(Arg.Any <Expression <Func <OpportunityItem, bool> > >()).Returns(new List <OpportunityItem>
            {
                opportunityItem
            }.AsQueryable());

            referralRepo.GetManyAsync(Arg.Any <Expression <Func <Domain.Models.Referral, bool> > >()).Returns(opportunityItem.Referral.AsQueryable());
            provisionGapRepo.GetManyAsync(Arg.Any <Expression <Func <ProvisionGap, bool> > >()).Returns(opportunityItem.ProvisionGap.AsQueryable());

            //Act
            await sut.DeleteOpportunityItemAsync(opportunityItem.OpportunityId, opportunityItem.OpportunityId);

            //Assert
            await opportunityRepo.DidNotReceive().DeleteAsync(Arg.Any <int>());
        }
示例#2
0
        public When_OpportunityService_Is_Called_To_Delete_UnSaved_Opportunity()
        {
            var mapper = new Mapper(Substitute.For <IConfigurationProvider>());

            _opportunityRepository     = Substitute.For <IOpportunityRepository>();
            _opportunityItemRepository = Substitute.For <IRepository <OpportunityItem> >();
            _provisionGapRepository    = Substitute.For <IRepository <ProvisionGap> >();
            _referralRepository        = Substitute.For <IRepository <Domain.Models.Referral> >();

            _opportunityItemRepository
            .GetManyAsync(Arg.Any <Expression <Func <OpportunityItem, bool> > >())
            .Returns(SetOpportunityItem().AsQueryable());

            _referralRepository
            .GetManyAsync(Arg.Any <Expression <Func <Domain.Models.Referral, bool> > >())
            .Returns(SetReferrals().AsQueryable());

            _provisionGapRepository
            .GetManyAsync(Arg.Any <Expression <Func <ProvisionGap, bool> > >())
            .Returns(SetProvisionGaps().AsQueryable());

            var googleMapApiClient = Substitute.For <IGoogleMapApiClient>();
            var opportunityPipelineReportWriter = Substitute.For <IFileWriter <OpportunityReportDto> >();
            var dateTimeProvider = Substitute.For <IDateTimeProvider>();

            var opportunityService = new OpportunityService(mapper, _opportunityRepository, _opportunityItemRepository,
                                                            _provisionGapRepository, _referralRepository, googleMapApiClient,
                                                            opportunityPipelineReportWriter, dateTimeProvider);

            opportunityService.DeleteOpportunityItemAsync(OpportunityId, OpportunityItemId).GetAwaiter().GetResult();
        }