Summary description for TagController
Inheritance: Controller
Exemplo n.º 1
0
        public void TagController_Has_Authorize_And_Area_Attributes()
        {
            // arrange
            var tagServiceMock         = new Mock <ITagService>();
            var destinationServiceMock = new Mock <IDestinationService>();
            var controller             = new TagController(tagServiceMock.Object, destinationServiceMock.Object);

            // act
            var authorizeAttributes = controller
                                      .GetType()
                                      .GetCustomAttributes(typeof(AuthorizeAttribute), true)
                                      .Cast <AuthorizeAttribute>()
                                      .ToList();

            var areaAttributes = controller
                                 .GetType()
                                 .GetCustomAttributes(typeof(AreaAttribute), true)
                                 .Cast <AreaAttribute>()
                                 .ToList();

            // assert
            Assert.True(authorizeAttributes.Count == 1);
            Assert.True(areaAttributes.Count == 1);
            Assert.True(authorizeAttributes[0].Roles == WriterRole);
            Assert.True(areaAttributes[0].RouteKey == "area");
            Assert.True(areaAttributes[0].RouteValue == WriterArea);
        }
Exemplo n.º 2
0
        public async void BulkInsert_No_Errors()
        {
            TagControllerMockFacade mock = new TagControllerMockFacade();

            var mockResponse = ValidationResponseFactory <ApiTagServerResponseModel> .CreateResponse(null as ApiTagServerResponseModel);

            mockResponse.SetRecord(new ApiTagServerResponseModel());
            mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiTagServerRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiTagServerResponseModel> >(mockResponse));
            TagController controller = new TagController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            var records = new List <ApiTagServerRequestModel>();

            records.Add(new ApiTagServerRequestModel());
            IActionResult response = await controller.BulkInsert(records);

            response.Should().BeOfType <OkObjectResult>();
            (response as OkObjectResult).StatusCode.Should().Be((int)HttpStatusCode.OK);
            var result = (response as OkObjectResult).Value as CreateResponse <List <ApiTagServerResponseModel> >;

            result.Success.Should().BeTrue();
            result.Record.Should().NotBeEmpty();
            mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiTagServerRequestModel>()));
        }
Exemplo n.º 3
0
        public MainWindow()
        {
            InitializeComponent();

            try
            {
                this.logger = Gnosis.Utilities.Log4NetLogger.GetDefaultLogger(typeof(MainWindow));
            }
            catch (Exception loggerEx)
            {
                throw new ApplicationException("Could not initialize logger", loggerEx);
            }

            try
            {
                logger.Info("Initializing Alexandria");

                mediaFactory    = new MediaFactory(logger);
                securityContext = new SecurityContext(mediaFactory);
                tagTypeFactory  = new TagTypeFactory();

                mediaRepository = new SQLiteMediaRepository(logger, mediaFactory);
                mediaRepository.Initialize();

                linkRepository = new SQLiteLinkRepository(logger);
                linkRepository.Initialize();

                tagRepository = new SQLiteTagRepository(logger, tagTypeFactory);
                tagRepository.Initialize();

                metadataRepository = new SQLiteMetadataRepository(logger, securityContext, mediaFactory);
                metadataRepository.Initialize();

                marqueeRepository = new SQLiteMarqueeRepository(logger);

                audioStreamFactory = new AudioStreamFactory();

                videoPlayer = new Gnosis.Video.Vlc.VideoPlayerControl();
                videoPlayer.Initialize(logger, () => GetVideoHost());

                catalogController = new CatalogController(logger, securityContext, mediaFactory, mediaRepository, linkRepository, tagRepository, metadataRepository, audioStreamFactory);
                spiderFactory     = new SpiderFactory(logger, securityContext, mediaFactory, linkRepository, tagRepository, mediaRepository, metadataRepository, audioStreamFactory);

                metadataController = new MediaItemController(logger, securityContext, mediaFactory, linkRepository, tagRepository, metadataRepository);
                taskController     = new TaskController(logger, mediaFactory, videoPlayer, spiderFactory, metadataController, marqueeRepository, metadataRepository);
                tagController      = new TagController(logger, tagRepository);
                commandController  = new CommandController(logger);

                taskResultView.Initialize(logger, securityContext, mediaFactory, metadataController, taskController, tagController, videoPlayer);
                //taskManagerView.Initialize(logger, taskController, taskResultView);
                searchView.Initialize(logger, taskController, taskResultView);
                commandView.Initialize(logger, commandController, taskController, taskResultView);

                ScreenSaver.Disable();
            }
            catch (Exception ex)
            {
                logger.Error("MainWindow.ctor", ex);
            }
        }
Exemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                bool isvalidated = validatefields();
                if (isvalidated)
                {
                    int tagId = Convert.ToInt32(dataGridView1.Text);
                    Tag tag   = new Tag();
                    tag.tagId      = tagId;
                    tag.tagName    = txttagName.Text;
                    tag.tagCode    = txttagCode.Text;
                    tag.relatedTag = comborelatedTag.SelectedItem.ToString();

                    string message = TagController.UpdateTag(tag);
                    MessageBox.Show(message);
                    loadgrid();
                    clear();
                }
                else
                {
                    MessageBox.Show("please fill in all fields!");
                }
            }
            catch (FormatException fe)
            {
                MessageBox.Show("Updated successfully");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 5
0
 private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     try
     {
         if (e.RowIndex >= 0)
         {
             DataGridViewRow row   = dataGridView1.Rows[e.RowIndex];
             int             tagId = Convert.ToInt32(row.Cells[0].Value.ToString());
             Tag             tag   = TagController.SelectedTag(tagId);
             if (tag != null)
             {
                 label5.Text     = tagId.ToString();
                 txttagName.Text = tag.tagName;
                 txttagCode.Text = tag.tagCode;
                 comborelatedTag.SelectedItem = tag.relatedTag;
             }
             else
             {
                 label5.Text     = string.Empty;
                 txttagName.Text = string.Empty;
                 txttagCode.Text = string.Empty;
                 comborelatedTag.SelectedIndex = -1;
             }
         }
     }
     catch (FormatException fe)
     {
         MessageBox.Show("no data selected");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 6
0
        public async void Patch_No_Errors()
        {
            TagControllerMockFacade mock = new TagControllerMockFacade();
            var mockResult = new Mock <UpdateResponse <ApiTagServerResponseModel> >();

            mockResult.SetupGet(x => x.Success).Returns(true);
            mock.ServiceMock.Setup(x => x.Update(It.IsAny <int>(), It.IsAny <ApiTagServerRequestModel>()))
            .Callback <int, ApiTagServerRequestModel>(
                (id, model) => model.Count.Should().Be(1)
                )
            .Returns(Task.FromResult <UpdateResponse <ApiTagServerResponseModel> >(mockResult.Object));
            mock.ServiceMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <ApiTagServerResponseModel>(new ApiTagServerResponseModel()));
            TagController controller = new TagController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, new ApiTagServerModelMapper());

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            var patch = new JsonPatchDocument <ApiTagServerRequestModel>();

            patch.Replace(x => x.Count, 1);

            IActionResult response = await controller.Patch(default(int), patch);

            response.Should().BeOfType <OkObjectResult>();
            (response as OkObjectResult).StatusCode.Should().Be((int)HttpStatusCode.OK);
            mock.ServiceMock.Verify(x => x.Update(It.IsAny <int>(), It.IsAny <ApiTagServerRequestModel>()));
        }
Exemplo n.º 7
0
        public async Task Delete_DefaultWorkflow()
        {
            // arrange
            var idToDelete             = 13;
            var tagServiceMock         = new Mock <ITagService>(MockBehavior.Strict);
            var destinationServiceMock = new Mock <IDestinationService>(MockBehavior.Strict);
            var controller             = new TagController(tagServiceMock.Object, destinationServiceMock.Object)
            {
                TempData = new Mock <ITempDataDictionary>().Object
            };

            tagServiceMock.Setup(s => s.ExistsAsync(idToDelete)).ReturnsAsync(true);
            tagServiceMock.Setup(s => s.DeleteAsync(idToDelete)).ReturnsAsync(true);

            // act
            var result = await controller.Delete(idToDelete);

            // assert
            Assert.IsAssignableFrom <RedirectToActionResult>(result);
            var actionName = (result as RedirectToActionResult)?.ActionName;

            Assert.True(string.Equals(actionName, nameof(TagController.Add), System.StringComparison.InvariantCultureIgnoreCase));
            destinationServiceMock.VerifyAll();
            tagServiceMock.VerifyAll();
        }
Exemplo n.º 8
0
        public void CanDeleteUpdateTag()
        {
            Mock <ITagRepository> mock       = new Mock <ITagRepository>();
            TagController         controller = new TagController(mock.Object);

            controller.Delete(1);
        }
Exemplo n.º 9
0
        public static List <TagModel> GetTags(string tagName)
        {
            if (!String.IsNullOrEmpty(tagName) && tagName.IndexOf(',') >= 0)
            {
                return(null);
            }

            var now      = DateTime.Now;
            var textInfo = new CultureInfo("vi-VN", false).TextInfo;
            var tags     = new List <TagModel>();
            var tagData  = TagController.get(tagName);

            if (tagData.Where(x => x.name == textInfo.ToLower(tagName)).Count() > 0)
            {
                tags.AddRange(tagData);
            }
            else
            {
                tags.Add(new TagModel()
                {
                    id   = 0,
                    name = textInfo.ToLower(tagName),
                    slug = String.Format("tag-new-{0:yyyyMMddhhmmss}", now)
                });
                tags.AddRange(tagData);
            }

            return(tags);
        }
Exemplo n.º 10
0
        public void CanDeleteUpdateTag()
        {
            Mock<ITagRepository> mock = new Mock<ITagRepository>();
            TagController controller = new TagController(mock.Object);

            controller.Delete(1);
        }
Exemplo n.º 11
0
        public void Details_When_No_Tag_Found()
        {
            // arrange
            var serviceMock = new Mock <ITagService>(MockBehavior.Strict);

            var tempDataMock = new Mock <ITempDataDictionary>();
            var controller   = new TagController(serviceMock.Object)
            {
                TempData = tempDataMock.Object
            };

            int id = 1;

            serviceMock.Setup(s => s.ExistsAsync(id)).ReturnsAsync(false);

            // act
            var result = controller.Details(id);

            // assert
            Assert.IsAssignableFrom <RedirectToActionResult>(result.Result);
            var actionName = (result.Result as RedirectToActionResult)?.ActionName;

            Assert.True(actionName != null && actionName.Equals(nameof(TagController.All), StringComparison.InvariantCultureIgnoreCase));
            serviceMock.VerifyAll();
        }
Exemplo n.º 12
0
        public void CanAddTagType()
        {
            Mock<ITagRepository> mock = new Mock<ITagRepository>();
            TagController controller = new TagController(mock.Object);

            controller.Post(new Tag { Id = 1, Description = "abc" });
        }
Exemplo n.º 13
0
        public void GetTagsReturnsOkResponse()
        {
            // Arrange
            List <string> tags = new List <string>
            {
                "iOS", "AR", "Gazzda"
            };
            var mockRepository = new Mock <ITagService>();

            mockRepository.Setup(s => s.GetTags())
            .Returns(tags);
            var controller = new TagController(mockRepository.Object);

            // Act
            IHttpActionResult actionResult = controller.GetTags();
            var createdResult = actionResult as OkNegotiatedContentResult <IEnumerable <string> >;
            var result        = createdResult.Content;

            // Assert
            Assert.IsNotNull(actionResult);
            Assert.IsNotNull(createdResult.Content);
            Assert.IsInstanceOfType(createdResult.Content, typeof(IEnumerable <string>));
            createdResult.Content.Should().NotContainNulls();
            createdResult.Content.Should().HaveCount(3);
            createdResult.Content.Should().Contain("AR");
        }
Exemplo n.º 14
0
 public void Setup()
 {
     _unitOfWorkMock = new Mock <IUnitOfWork>();
     _factoryMock    = new Mock <IFactory>();
     _factoryMock.Setup(x => x.GetUOF()).Returns(_unitOfWorkMock.Object);
     _uut = new TagController(_factoryMock.Object);
 }
Exemplo n.º 15
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                bool isvalidated = validatefields();
                if (isvalidated)
                {
                    Tag tag = new Tag();
                    tag.tagName    = txttagName.Text;
                    tag.tagCode    = txttagCode.Text;
                    tag.relatedTag = comborelatedTag.SelectedItem.ToString();



                    string message = TagController.AddTag(tag);
                    MessageBox.Show(message);
                    clear();
                }
                else
                {
                    MessageBox.Show("please fill in all fields!");
                }
            }
            catch (NullReferenceException nre)
            {
                MessageBox.Show("please fill in all fields!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Handles the main asynchronous execution and handling of command events.
        /// </summary>
        private static async Task MainAsync(string token)
        {
            // Set up client
            var discord = new DiscordClient(new DiscordConfiguration()
            {
                Token           = token,
                TokenType       = TokenType.Bot,
                MinimumLogLevel = LogLevel.Debug
            });

            // Set up command prefix
            discord.UseCommandsNext(new CommandsNextConfiguration()
            {
                StringPrefixes = new[] { "!" }
            });

            // Register module controllers
            TagController.Register(discord);
            ModerationController.Register(discord);
            MiscController.Register(discord);

            await discord.ConnectAsync();

            await Task.Delay(-1);
        }
Exemplo n.º 17
0
 public void Setup()
 {
     this.controller = new TagController(this.ArticleServiceMock.Object)
     {
         Cache = this.CacheServiceMock.Object
     };
 }
Exemplo n.º 18
0
        public void Create_Tag()
        {
            // Arrange

            var mapper = CreateMapperObject().CreateMapper();

            var mockRepo = new Mock <IAppProductRepository>();

            mockRepo.Setup(repo => repo.GetProductAsync(It.IsAny <Guid>()))
            .ReturnsAsync(GetSingleProduct());
            mockRepo.Setup(repo => repo.AddTag(It.IsAny <Tag>()));

            var controller = new TagController(mapper, mockRepo.Object);

            var inputDto = new TagCreationDto
            {
                Value = "blue"
            };

            // Act
            var result = controller.CreateTag(It.IsAny <Guid>(), inputDto);

            // Assert

            var tagOutput = Assert.IsType <OkResult>(result.Result);
            var model     = Assert.IsAssignableFrom <OkResult>(
                tagOutput);

            Assert.Equal(200, model.StatusCode);
        }
Exemplo n.º 19
0
 public void SetUp()
 {
     _loggingService  = A.Fake <ILogService>();
     _tagService      = A.Fake <ITagService>();
     _facebookService = A.Fake <IFacebookService>();
     _tagBuilder      = A.Fake <ITagBuilder>();
     _controller      = new TagController(_facebookService, _loggingService, _tagService, _tagBuilder);
 }
Exemplo n.º 20
0
 public TagControllerTest() : base()
 {
     _hostingEnv    = ServiceProvider.GetService <IWebHostEnvironment>();
     _tagController = ServiceProvider.GetService <TagController>();;
     _mapper        = ServiceProvider.GetService <IMapper>();
     _tagRepository = ServiceProvider.GetService <IAuditBaseRepository <Tag> >();
     _freeSql       = ServiceProvider.GetService <IFreeSql>();
 }
        public void CanCreate()
        {
            var tagRepository     = new Mock <IRepository <Tag> >();
            var userManager       = new Mock <IIdentityMembershipProvider>();
            var contactRepository = new Mock <IRepository <Contact> >();

            var controller = new TagController(userManager.Object, tagRepository.Object, contactRepository.Object);
        }
Exemplo n.º 22
0
        public void CanUpdateTag()
        {
            Mock <ITagRepository> mock       = new Mock <ITagRepository>();
            TagController         controller = new TagController(mock.Object);

            controller.Put(new Tag {
                Id = 1, Description = "abc"
            });
        }
Exemplo n.º 23
0
        public void CanAddTagType()
        {
            Mock <ITagRepository> mock       = new Mock <ITagRepository>();
            TagController         controller = new TagController(mock.Object);

            controller.Post(new Tag {
                Id = 1, Description = "abc"
            });
        }
Exemplo n.º 24
0
        public void TagController_Search_ShouldCallTagServiceSearch()
        {
            var tagService    = A.Fake <ITagAdminService>();
            var tagController = new TagController(tagService);

            tagController.Search("test");

            A.CallTo(() => tagService.Search("test")).MustHaveHappened();
        }
Exemplo n.º 25
0
        public static List <TagModel> GetTagListByNameList([FromUri] string[] tagNameList)
        {
            if (tagNameList == null || tagNameList.Length == 0)
            {
                return(null);
            }

            return(TagController.get(tagNameList.ToList()));
        }
Exemplo n.º 26
0
 private void loadgrid()
 {
     try
     {
         dataGridView1.DataSource = TagController.FilterTag();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 27
0
    void CreateEmoji(TagParams tParams)
    {
        GameObject nTag = Instantiate(emojiPrefabs[tParams.emojiIndex - 1]);

        TagController tg = nTag.GetComponent <TagController>();

        tg.tagParams = tParams;

        curLoc(tParams.location).PositionAtLocation(tg.transform);
        tg.SetUpTag();
    }
Exemplo n.º 28
0
 public Display(FilmCatalogContext context)
 {
     this.movieTagController = new MovieTagController(context);
     this.tagController      = new TagController(context);
     this.movieController    = new MovieController(context);
     this.genreController    = new GenreController(context);
     this.ratingController   = new RatingController(context);
     this.userController     = new UserController(context);
     this.validate           = new Validate(context);
     this.RegisterOrLogin();
     HandleInput();
 }
        public void DeleteTagWhichIsNotInRepositoryReturnsBadREquest()
        {
            var tagRepository     = new Mock <IRepository <Tag> >();
            var userManager       = new Mock <IIdentityMembershipProvider>();
            var contactRepository = new Mock <IRepository <Contact> >();

            var controller = new TagController(userManager.Object, tagRepository.Object, contactRepository.Object);

            var result = controller.Delete(1, 1);

            Assert.AreEqual(typeof(BadRequestResult), result.GetType());
        }
        public void Create_GET_ReturnsCorrectView()
        {
            //Arrange
            IRepository mockRepo = Substitute.For <IRepository>();

            //Act
            TagController target = new TagController(mockRepo);
            ActionResult  result = target.Create();

            //Assert
            Assert.IsInstanceOf <ViewResult>(result);
        }
Exemplo n.º 31
0
        public void TagController_Search_ShouldReturnTheResultOfTheServiceQuery()
        {
            var tagService    = A.Fake <ITagAdminService>();
            var tagController = new TagController(tagService);
            IEnumerable <AutoCompleteResult> results = Enumerable.Empty <AutoCompleteResult>();

            A.CallTo(() => tagService.Search("test")).Returns(results);

            JsonResult result = tagController.Search("test");

            result.Data.As <IEnumerable <AutoCompleteResult> >().Should().BeEquivalentTo(results);
        }
Exemplo n.º 32
0
        public void CanGetTagType()
        {
            Tag expected = new Tag { Id = 1, Description = "abc" };
            Mock<ITagRepository> mock = new Mock<ITagRepository>();
            mock.Setup(f => f.GetById(1))
                .Returns(expected);

            TagController controller = new TagController(mock.Object);
            Tag tag = controller.Get(1);

            Assert.AreEqual(expected, tag);
        }
Exemplo n.º 33
0
        public void Edit_GetRequestNotFoundResult()
        {
            var tag        = "my tag";
            var repo       = Mock.Create <ITagRepository>();
            var controller = new TagController(repo);

            Mock.Arrange(() => repo.Get(tag))
            .Throws(new KeyNotFoundException());

            var result = controller.Edit(tag);

            Assert.IsTrue(result is HttpNotFoundResult);
        }
        public void CanCreateNewTags()
        {
            var tagRepository     = new Mock <IRepository <Tag> >();
            var userManager       = new Mock <IIdentityMembershipProvider>();
            var contactRepository = new Mock <IRepository <Contact> >();

            var controller = new TagController(userManager.Object, tagRepository.Object, contactRepository.Object);

            var result = controller.Create(1, "NewTag") as OkNegotiatedContentResult <Tag>;

            tagRepository.Verify(tr => tr.Add(It.IsAny <Tag>()), Times.Once);
            tagRepository.Verify(tr => tr.SaveChanges(), Times.Once);
            Assert.AreEqual("NewTag", result.Content.Name);
        }
Exemplo n.º 35
0
        public void CanGetAllTags()
        {
            Tag[] expected =
            {
                new Tag { Id = 1, Description = "abc" },
                new Tag { Id = 2, Description = "def" }
            };
            Mock<ITagRepository> mock = new Mock<ITagRepository>();
            mock.Setup(f => f.GetAll())
                .Returns(expected);

            TagController controller = new TagController(mock.Object);
            Tag[] tags = controller.Get().ToArray();

            Assert.AreEqual(expected, tags);
        }
        public Response<Tag> postTag(Tag tag)
        {
            IncomingWebRequestContext requestContext = WebOperationContext.Current.IncomingRequest;

            Dictionary<string, string> data = new Dictionary<string, string>();

            string authString = requestContext.Headers[HttpRequestHeader.Authorization];

            data.Add("name", tag.name);
            data.Add("simple_name", tag.simple_name);
            data.Add("tag_group_id", tag.tag_group.ToString());

            Request request = makeRequest(requestContext, trimData(data), authString);

            TagController controller = new TagController();

            return controller.Call(request);
        }
        public Response<Tag> getTags(string tagGroupFilter, string limit, string page)
        {
            IncomingWebRequestContext requestContext = WebOperationContext.Current.IncomingRequest;

            Dictionary<string, string> data = new Dictionary<string, string>();

            string authString = requestContext.Headers[HttpRequestHeader.Authorization];

            data.Add("tag_group_id", tagGroupFilter);
            data.Add("limit", limit);
            data.Add("page", page);

            Request request = makeRequest(requestContext, trimData(data),authString);

            TagController controller = new TagController();

            return controller.Call(request);
        }
        public Response<Tag> getTagByMedia(string mediaId)
        {
            IncomingWebRequestContext requestContext = WebOperationContext.Current.IncomingRequest;

            Dictionary<string, string> data = new Dictionary<string, string>();

            string authString = requestContext.Headers[HttpRequestHeader.Authorization];

            data.Add("id", mediaId);

            Request request = makeRequest(requestContext, trimData(data), authString);

            TagController controller = new TagController();

            return controller.Call(request);
        }
Exemplo n.º 39
0
        public void CanUpdateTag()
        {
            Mock<ITagRepository> mock = new Mock<ITagRepository>();
            TagController controller = new TagController(mock.Object);

            controller.Put(new Tag { Id = 1, Description = "abc" });
        }