public void RegularConnectionsNotDeleted() { // Arrange var serviceId = Guid.NewGuid(); var channelId = Guid.NewGuid(); var request = new V7VmOpenApiChannelServicesIn { ChannelId = channelId, ServiceRelations = new List <V7VmOpenApiServiceChannelServiceInBase> { new V7VmOpenApiServiceChannelServiceInBase { 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 <V7VmOpenApiChannelServicesIn, ServiceChannel>(request, unitOfWork)) .Returns(new ServiceChannel() { Id = serviceId, ServiceServiceChannels = new List <ServiceServiceChannel> { new ServiceServiceChannel { IsASTIConnection = true, ServiceChannelId = channelId, ServiceId = serviceId }, new ServiceServiceChannel { IsASTIConnection = false, ServiceChannelId = channelId, ServiceId = Guid.NewGuid() } } }); var service = new ServiceAndChannelService(contextManager, translationManagerMockSetup.Object, translationManagerVModelMockSetup.Object, Logger, serviceUtilities, DataUtils, ServiceService, ChannelService, PublishingStatusCache, VersioningManager, UserOrganizationChecker, CacheManager, UserOrganizationService); // Act var result = service.SaveServiceChannelConnections(request, DefaultVersion); // Assert // We are not testing method GetServiceChannelById so we expect result to be null. result.Should().BeNull(); ConnectionRepoMock.Verify(x => x.Remove(It.IsAny <ServiceServiceChannel>()), Times.Never()); DescriptionRepoMock.Verify(x => x.Remove(It.IsAny <ServiceServiceChannelDescription>()), Times.Never()); }
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.SaveServiceChannelConnections(null, DefaultVersion); // Assert result.Should().BeNull(); }
public void DeleteAllASTIConnections() { // Arrange var channelId = Guid.NewGuid(); var serviceId = Guid.NewGuid(); var serviceId2 = Guid.NewGuid(); var request = new V7VmOpenApiChannelServicesIn { ChannelId = channelId, DeleteAllServiceRelations = true }; // repositories var connectionList = new List <ServiceServiceChannel>() { new ServiceServiceChannel { ServiceId = serviceId, ServiceChannelId = channelId }, new ServiceServiceChannel { ServiceId = serviceId2, ServiceChannelId = channelId } }; ConnectionRepoMock.Setup(c => c.All()).Returns(connectionList.AsQueryable()); DescriptionRepoMock.Setup(c => c.All()).Returns(new List <ServiceServiceChannelDescription> { new ServiceServiceChannelDescription { ServiceId = serviceId, ServiceChannelId = channelId }, new ServiceServiceChannelDescription { ServiceId = serviceId2, ServiceChannelId = channelId }, }.AsQueryable()); 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 <V7VmOpenApiChannelServicesIn, ServiceChannel>(request, unitOfWork)) .Returns(new ServiceChannel() { Id = serviceId, ServiceServiceChannels = new List <ServiceServiceChannel> { new ServiceServiceChannel { IsASTIConnection = true, ServiceChannelId = channelId, ServiceId = serviceId }, new ServiceServiceChannel { IsASTIConnection = true, ServiceChannelId = channelId, ServiceId = serviceId2 }, new ServiceServiceChannel { IsASTIConnection = false, ServiceChannelId = channelId, ServiceId = Guid.NewGuid() } // regular connection that should not be removed } }); var service = new ServiceAndChannelService(contextManager, translationManagerMockSetup.Object, translationManagerVModelMockSetup.Object, Logger, serviceUtilities, DataUtils, ServiceService, ChannelService, PublishingStatusCache, VersioningManager, UserOrganizationChecker, CacheManager, UserOrganizationService); // Act var result = service.SaveServiceChannelConnections(request, DefaultVersion); // Assert // We are not testing method GetServiceChannelById so we expect result to be null. result.Should().BeNull(); translationManagerVModelMockSetup.Verify(t => t.Translate <V7VmOpenApiChannelServicesIn, ServiceChannel>(It.IsAny <V7VmOpenApiChannelServicesIn>(), unitOfWork), Times.Once()); ConnectionRepoMock.Verify(x => x.Remove(It.IsAny <ServiceServiceChannel>()), Times.Exactly(2)); DescriptionRepoMock.Verify(x => x.Remove(It.IsAny <ServiceServiceChannelDescription>()), Times.Exactly(2)); }