public void TestGetChannelByUserName_ShouldReturnCorrectChannel() { var options = new DbContextOptionsBuilder <TubeDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; var context = new TubeDbContext(options); SeedData(context); var mockMapper = new MapperConfiguration(cfg => { cfg.AddProfile(new TubeProfile()); }); var mapper = mockMapper.CreateMapper(); var userService = new UserService(context, mapper); var channelService = new ChannelService(context, userService, mapper); var channelName = "MyChannel"; var channelDescription = "TestChannel"; var tubeUsername = "******"; channelService.Create(channelName, channelDescription, string.Empty, tubeUsername); var expectedData = channelService.GetChannelByTubeUserName(tubeUsername); Assert.False(expectedData == null); }
public void TestIsYours_ShouldReturnFalse() { var options = new DbContextOptionsBuilder <TubeDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; var context = new TubeDbContext(options); SeedData(context); var mockMapper = new MapperConfiguration(cfg => { cfg.AddProfile(new TubeProfile()); }); var mapper = mockMapper.CreateMapper(); var userService = new UserService(context, mapper); var channelService = new ChannelService(context, userService, mapper); var channelName = "MyChannel"; var channelDescription = "TestChannel"; var tubeUsername = "******"; var channel = channelService.Create(channelName, channelDescription, string.Empty, tubeUsername); var id = channel.Id; var username = Users[1].UserName; var isYours = channelService.IsYours(id, username); Assert.False(isYours); }
public void Create_New_Channel_Ordering_When_No_Siblings() { CreateChannels(); ChannelService service = CreateChannelService(); var newchannel = MockRepository.GenerateStub <Channel>(); newchannel.Name = "new"; newchannel.Parent = channel2; newchannel.TextId = "whatever"; service.Create(newchannel); // assertions newchannel.AssertWasCalled(c => c.Create()); Assert.AreEqual(1, newchannel.Ordering); }
public async void Create() { var mock = new ServiceMockFacade <IChannelRepository>(); var model = new ApiChannelRequestModel(); mock.RepositoryMock.Setup(x => x.Create(It.IsAny <Channel>())).Returns(Task.FromResult(new Channel())); var service = new ChannelService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ChannelModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLChannelMapperMock, mock.DALMapperMockFactory.DALChannelMapperMock); CreateResponse <ApiChannelResponseModel> response = await service.Create(model); response.Should().NotBeNull(); mock.ModelValidatorMockFactory.ChannelModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiChannelRequestModel>())); mock.RepositoryMock.Verify(x => x.Create(It.IsAny <Channel>())); }
private Channel CreateChannel(StructureInfo structureInfo, Guid websiteId, string urlPrefix, string channelName) { var channel = structureInfo.Website.Channel; var newChannel = new Channel(structureInfo.Id(channel.FieldTemplateSystemId)) { GoogleTagManagerContainerId = channel.GoogleTagManagerContainerId, SystemId = structureInfo.Id(channel.SystemId), DomainNameLinks = new List <ChannelToDomainNameLink> { new ChannelToDomainNameLink(structureInfo.Id(structureInfo.Website.DomainName.SystemId)) { UrlPrefix = urlPrefix } }, GoogleAnalyticsAccountId = channel.GoogleAnalyticsAccountId }; foreach (var language in _languageService.GetAll()) { newChannel.Localizations[language.CultureInfo].Name = channelName; } if (channel.MarketSystemId != null) { newChannel.MarketSystemId = structureInfo.Id(structureInfo.Website.Market.SystemId); } if (channel.ProductLanguageSystemId.HasValue) { newChannel.ProductLanguageSystemId = structureInfo.Id(channel.ProductLanguageSystemId.Value); } if (channel.WebsiteLanguageSystemId.HasValue) { newChannel.WebsiteLanguageSystemId = structureInfo.Id(channel.WebsiteLanguageSystemId.Value); } newChannel.CountryLinks.Clear(); newChannel.WebsiteSystemId = structureInfo.Id(websiteId); newChannel.Id = _slugifyService.Slugify(CultureInfo.CurrentCulture, channelName); _channelService.Create(newChannel); return(newChannel); }
public async Task <ActionResult> EnsureAndJoin(ChannelViewModel channelViewModel) { Channel channel = null; if (!channelViewModel.EnsureUnique) { channel = await _channelService.FindChannel(User, channelViewModel.Name); } if (channel == null) { channel = await _channelService.Create(User, channelViewModel.Name, channelViewModel.IsPublic, channelViewModel.AllowedUsers); } if (channel != null) { await _channelService.Join(User, channel.Id); } return(Ok(channel)); }
public void TestCreate() { Channel channel = new Channel(); channel.ID = _channelID; channel.Name = "MyChannel"; channel.AppID = _confAppID; channel.AddressMap = "myMapfile"; channel.AddressPath = "//*some/xpath/to/find/msisdnorso"; channel.AddressPermission = EnumAddressPermission.BACKEND; channel.AddressType = EnumAddressType.XPATH; channel.CallBackPwd = "secret"; channel.CallBackURL = "http://mybackendserver.com/callback.svc"; channel.CallBackUser = "******"; channel.MapIn = "MyXSLTTransformRequest.xslt"; channel.MapInType = EnumMapType.XSLT; channel.MapOut = "MyXSLTTransformResponse.xslt"; channel.MapOutType = EnumMapType.XSLT; channel.Priority = EnumPriority.NORMAL; channel.Retries = 3; channel.TTL = 50000; _service.Create(channel); }
public Task <int> Create(ChannelData channel) => Service.Create(channel);