Exemplo n.º 1
0
        public void ASTIUpdate_RegularConnectionsNotDeleted()
        {
            // Arrange
            var serviceId = Guid.NewGuid();
            var channelId = Guid.NewGuid();
            var request   = new V7VmOpenApiServiceAndChannelRelationAstiInBase
            {
                IsASTI           = true,
                ServiceId        = serviceId,
                ChannelRelations = new List <V7VmOpenApiServiceServiceChannelAstiInBase>
                {
                    new V7VmOpenApiServiceServiceChannelAstiInBase
                    {
                        ServiceGuid = serviceId,
                        ChannelGuid = channelId,
                    }
                }
            };
            var unitOfWork = unitOfWorkMockSetup.Object;

            var contextManager = new TestContextManager(unitOfWork, unitOfWork);

            var serviceUtilities = new ServiceUtilities(UserIdentificationMock.Object, LockingManager, contextManager, UserOrganizationService,
                                                        VersioningManager, UserInfoService, UserOrganizationChecker);

            translationManagerVModelMockSetup.Setup(s => s.Translate <V7VmOpenApiServiceAndChannelRelationAstiInBase, Model.Models.Service>(request, unitOfWork))
            .Returns(new Model.Models.Service()
            {
                Id = serviceId,
                ServiceServiceChannels = new List <ServiceServiceChannel>
                {
                    new ServiceServiceChannel {
                        IsASTIConnection = true, ServiceChannelId = channelId
                    },
                    new ServiceServiceChannel {
                        IsASTIConnection = false, ServiceChannelId = Guid.NewGuid()
                    }
                }
            });

            // repositories
            ConnectionRepoMock.Setup(c => c.All()).Returns(new List <ServiceServiceChannel>().AsQueryable());
            DescriptionRepoMock.Setup(c => c.All()).Returns(new List <ServiceServiceChannelDescription>().AsQueryable());

            var service = new ServiceAndChannelService(contextManager, translationManagerMockSetup.Object, translationManagerVModelMockSetup.Object,
                                                       Logger, serviceUtilities, DataUtils, ServiceService, ChannelService, PublishingStatusCache, VersioningManager, UserOrganizationChecker,
                                                       CacheManager, UserOrganizationService);

            // Act
            var result = service.SaveServiceConnections(request, DefaultVersion);

            // Assert
            // We are not testing method GetServiceById so we expect result to be null.
            result.Should().BeNull();
            translationManagerVModelMockSetup.Verify(t => t.Translate <V7VmOpenApiServiceAndChannelRelationAstiInBase, Model.Models.Service>(It.IsAny <V7VmOpenApiServiceAndChannelRelationAstiInBase>(), unitOfWork), Times.Once());
            ConnectionRepoMock.Verify(x => x.Remove(It.IsAny <ServiceServiceChannel>()), Times.Never());
            DescriptionRepoMock.Verify(x => x.Remove(It.IsAny <ServiceServiceChannelDescription>()), Times.Never());
        }
Exemplo n.º 2
0
        public void ModelIsNull()
        {
            // Arrange
            var unitOfWork = unitOfWorkMockSetup.Object;

            var contextManager = new TestContextManager(unitOfWork, unitOfWork);

            var serviceUtilities = new ServiceUtilities(UserIdentificationMock.Object, LockingManager, contextManager, UserOrganizationService,
                                                        VersioningManager, UserInfoService, UserOrganizationChecker);
            var service = new ServiceAndChannelService(contextManager, translationManagerMockSetup.Object, translationManagerVModelMockSetup.Object,
                                                       Logger, serviceUtilities, DataUtils, ServiceService, ChannelService, PublishingStatusCache, VersioningManager, UserOrganizationChecker,
                                                       CacheManager, UserOrganizationService);

            // Act
            var result = service.SaveServiceConnections(null, DefaultVersion);

            // Assert
            result.Should().BeNull();
            translationManagerVModelMockSetup.Verify(t => t.Translate <V7VmOpenApiServiceAndChannelRelationAstiInBase, Model.Models.Service>(It.IsAny <V7VmOpenApiServiceAndChannelRelationAstiInBase>(), unitOfWork), Times.Never());
        }