Exemplo n.º 1
0
        public void ChannelsAttached()
        {
            // Arrange
            var serviceChannel         = EntityGenerator.CreateEntity <ServiceChannelVersioned, ServiceChannel, ServiceChannelLanguageAvailability>(PublishedId);
            var channelId              = serviceChannel.Id;
            var serviceChannelRepoMock = new Mock <IServiceChannelVersionedRepository>();

            serviceChannelRepoMock.Setup(s => s.All()).Returns(new List <ServiceChannelVersioned>
            {
                new ServiceChannelVersioned {
                    Id = channelId
                }
            }.AsQueryable());
            unitOfWorkMockSetup.Setup(uw => uw.CreateRepository <IServiceChannelVersionedRepository>()).Returns(serviceChannelRepoMock.Object);

            _publishedGd.UnificRoot.StatutoryServiceGeneralDescriptionServiceChannels = new List <GeneralDescriptionServiceChannel>
            {
                new GeneralDescriptionServiceChannel
                {
                    ServiceChannel = new ServiceChannel {
                        Versions = new List <ServiceChannelVersioned> {
                            serviceChannel
                        }
                    },
                    ServiceChannelId = channelId,
                    StatutoryServiceGeneralDescriptionId = _publishedGdId
                }
            };
            GdRepoMock.Setup(g => g.All()).Returns(_gdList.AsQueryable());
            var service = Arrange();

            // Act
            var result = service.GetGeneralDescriptionVersionBase(_publishedGdId, DefaultVersion);

            // Assert
            result.Should().NotBeNull();
            result.Should().BeOfType <V7VmOpenApiGeneralDescription>();
            unitOfWorkMockSetup.Verify(x => x.CreateRepository <IGeneralDescriptionServiceChannelRepository>(), Times.Once());
        }
Exemplo n.º 2
0
        private GeneralDescriptionService Arrange()
        {
            var gdList      = _gdList;
            var publishedGd = gdList.Where(o => o.PublishingStatusId == PublishedId).FirstOrDefault();
            var id          = publishedGd.Id;

            unitOfWorkMockSetup.Setup(uw => uw.ApplyIncludes(
                                          It.IsAny <IQueryable <StatutoryServiceGeneralDescriptionVersioned> >(),
                                          It.IsAny <Func <IQueryable <StatutoryServiceGeneralDescriptionVersioned>, IQueryable <StatutoryServiceGeneralDescriptionVersioned> > >(),
                                          It.IsAny <bool>()
                                          )).Returns(new List <StatutoryServiceGeneralDescriptionVersioned> {
                publishedGd
            }.AsQueryable());
            var unitOfWork     = unitOfWorkMockSetup.Object;
            var contextManager = new TestContextManager(unitOfWork, unitOfWork);

            var serviceUtilities = new ServiceUtilities(UserIdentification, LockingManager, contextManager, UserOrganizationService,
                                                        VersioningManager, UserInfoService, UserOrganizationChecker);

            translationManagerMockSetup.Setup(t => t.Translate <StatutoryServiceGeneralDescriptionVersioned, VmOpenApiGeneralDescriptionVersionBase>(_publishedGd))
            .Returns(new VmOpenApiGeneralDescriptionVersionBase());

            var translationManagerMock = translationManagerMockSetup.Object;

            VersioningManagerMock.Setup(s => s.GetVersionId <StatutoryServiceGeneralDescriptionVersioned>(unitOfWork, id, PublishingStatus.Published, true)).Returns(Guid.NewGuid());

            // repositories
            GdRepoMock.Setup(g => g.All()).Returns(gdList.AsQueryable());
            var serviceChannelNameRepoMock = new Mock <IServiceChannelNameRepository>();

            unitOfWorkMockSetup.Setup(uw => uw.CreateRepository <IServiceChannelNameRepository>()).Returns(serviceChannelNameRepoMock.Object);

            return(new GeneralDescriptionService(contextManager, UserIdentification, translationManagerMockSetup.Object, TranslationManagerVModel,
                                                 Logger, serviceUtilities, CommonService, PublishingStatusCache, UserOrganizationChecker, LanguageCache, TypeCache,
                                                 VersioningManager, DataUtils, ValidationManagerMock));
        }