public void Post_Edit_Model_Is_Null()
        {
            // Arrange
            var             id = -1;
            InformationItem informationItem          = null;
            var             informationItemViewModel = new InformationItemViewModel()
            {
                PictureUrl = "/Content/Images/pizza_1.jpg",
                Position   = 1,
                Title      = "Menu",
                Content    = "Ut at viverra arcu. Donec sed interdum nulla, eu porttitor lorem. Morbi efficitur sapien ullamcorper lorem vestibulum, ut aliquet turpis consequat. Suspendisse ac nibh non velit scelerisque bibendum. "
            };
            var service    = Substitute.For <IInformationItemService>();
            var validator  = new ModelValidator <InformationItemViewModel>(informationItemViewModel);
            var controller = new InformationItemController(service);

            service.GetInfomrationItem(id).Returns(informationItem);

            // Act
            var valid = validator.IsValid();

            validator.AddToModelError(controller);
            var result     = controller.Edit(informationItemViewModel) as HttpNotFoundResult;
            var statusCode = result.StatusCode;

            // Assert
            Assert.That(result, !Is.Null);
            Assert.That(valid, Is.True);
            Assert.That(404, Is.EqualTo(statusCode));
        }
        public void Delete_Not_Ajax_Request()
        {
            // Arrange
            var id = 1;
            var informationItem = new InformationItem()
            {
                ID         = 1,
                PictureUrl = "/Content/Images/pizza_1.jpg",
                Position   = 1,
                Title      = "Menu",
                Content    = "Ut at viverra arcu. Donec sed interdum nulla, eu porttitor lorem. Morbi efficitur sapien ullamcorper lorem vestibulum, ut aliquet turpis consequat. Suspendisse ac nibh non velit scelerisque bibendum. "
            };
            var service        = Substitute.For <IInformationItemService>();
            var fakeController = new FakeController();
            var controller     = new InformationItemController(service);

            fakeController.PrepareFakeRequest();
            controller.ControllerContext = fakeController.GetControllerContext <InformationItemController>(new RouteData(), controller);
            service.GetInfomrationItem(id).Returns(informationItem);

            // Act
            var result      = controller.Delete(id) as RedirectToRouteResult;
            var ajaxRequest = controller.Request.IsAjaxRequest();
            var actionName  = result.RouteValues.Values.ElementAt(0);

            // Assert
            Assert.That(result, !Is.Null);
            Assert.That(ajaxRequest, Is.False);
            Assert.That("Index", Is.EqualTo(actionName));
        }
        public void Delete_Good()
        {
            // Arrange
            var id = 1;
            var informationItem = new InformationItem()
            {
                ID         = 1,
                PictureUrl = "/Content/Images/pizza_1.jpg",
                Position   = 1,
                Title      = "Menu",
                Content    = "Ut at viverra arcu. Donec sed interdum nulla, eu porttitor lorem. Morbi efficitur sapien ullamcorper lorem vestibulum, ut aliquet turpis consequat. Suspendisse ac nibh non velit scelerisque bibendum. "
            };
            var service        = Substitute.For <IInformationItemService>();
            var fakeController = new FakeController();
            var controller     = new InformationItemController(service);

            fakeController.PrepareFakeAjaxRequest();
            controller.ControllerContext = fakeController.GetControllerContext <InformationItemController>(new RouteData(), controller);
            service.GetInfomrationItem(id).Returns(informationItem);
            service.DeleteInfomationItem(informationItem);
            service.SaveInfomrationItem();

            // Act
            var result              = controller.Delete(id) as JsonResult;
            var ajaxRequest         = controller.Request.IsAjaxRequest();
            var jsonRequestBehavior = result.JsonRequestBehavior;
            var data = result.Data;

            // Assert
            Assert.That(result, !Is.Null);
            Assert.That(ajaxRequest, Is.True);
            Assert.That(JsonRequestBehavior.AllowGet, Is.EqualTo(jsonRequestBehavior));
            Assert.That("", Is.EqualTo(data));
        }
Ejemplo n.º 4
0
    public void Inspecionar()
    {
        //  Debug.LogError("interagindo asdasd");

        if (inspencionado.transform.tag == "Personagens")
        {
            //      Debug.LogError("interagindo personagem");
            acompanhante = inspencionado.GetComponent <CharacterNPC>();

            if (acompanhante != null)
            {
                acompanhante.chamarCanvasMissao();
            }
            else
            {
                var npcConversar = inspencionado.GetComponent <InformacaoPerosonagem>();
                if (npcConversar != null)
                {
                    npcConversar.Conversar();
                }
            }
        }
        else if (inspencionado.transform.tag == "ItemInformativo")
        {
            information = inspencionado.GetComponent <InformationItem>();
            information.ExibirInformativoTP();
        }
    }
Ejemplo n.º 5
0
 public void UpdateItem(int at, InformationItem item)
 {
     if (at >= _items.Count)
     {
         return;
     }
     _items[at].UpdateItem(item);
 }
Ejemplo n.º 6
0
        private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var name    = InformationItemNameTextBox.Text;
            var content = InformationItemContentTextBox.Text;

            if (name != "" && content != "")
            {
                var item = new InformationItem(name, content);
                informationItemList.Add(item);
            }
        }
        private void Initialize()
        {
            if (_isInitialized)
            {
                return;
            }
            InformationItem informationItem = new InformationItem();

            Add(informationItem);
            //Add 6 items to the gallery
            //for (int i = 0; i < 6; i++)
            //{
            //    string name = string.Format("Item {0}", i);
            //    Add(new GalleryItem(name, this.LargeImage != null ? ((ImageSource)this.LargeImage).Clone() : null, name));
            //}
            _isInitialized = true;
        }
        public void Good_Post_Create()
        {
            // Arrange
            var informationItemViewModel = new InformationItemViewModel()
            {
                Position = 1,
                Title    = "Menu",
                Content  = "Ut at viverra arcu. Donec sed interdum nulla, eu porttitor lorem. Morbi efficitur sapien ullamcorper lorem vestibulum, ut aliquet turpis consequat. Suspendisse ac nibh non velit scelerisque bibendum. "
            };
            var informationItem = new InformationItem()
            {
                Position = 1,
                Title    = "Menu",
                Content  = "Ut at viverra arcu. Donec sed interdum nulla, eu porttitor lorem. Morbi efficitur sapien ullamcorper lorem vestibulum, ut aliquet turpis consequat. Suspendisse ac nibh non velit scelerisque bibendum. "
            };
            var fileName    = "text.jpg";
            var fileLength  = 1000;
            var contentType = "image";
            var fakeImage   = Substitute.For <HttpPostedFileBase>();
            var validator   = new ModelValidator <InformationItemViewModel>(informationItemViewModel);
            var service     = Substitute.For <IInformationItemService>();

            fakeImage.FileName.Returns(fileName);
            fakeImage.ContentType.Returns(contentType);
            fakeImage.ContentLength.Returns(fileLength);

            var controller = new InformationItemController(service);

            service.MapViewModelToObject(informationItemViewModel).Returns(informationItem);
            informationItem.PictureUrl = service.AddInformationItemImage(fakeImage);
            service.CreateInformationItem(informationItem);
            service.SaveInfomrationItem();

            // Act
            var valid = validator.IsValid();

            validator.AddToModelError(controller);
            var result     = controller.Create(informationItemViewModel, fakeImage) as RedirectToRouteResult;
            var actionName = result.RouteValues.Values.ElementAt(0);

            // Assert
            Assert.That(result, !Is.Null);
            Assert.That("Index", Is.EqualTo(actionName));
            Assert.That(valid, Is.True);
        }
        public void Get_Edit_Model_Null()
        {
            // Arrange
            var             id = 1;
            InformationItem informationItem = null;
            var             service         = Substitute.For <IInformationItemService>();
            var             controller      = new InformationItemController(service);

            service.GetInfomrationItem(id).Returns(informationItem);

            // Act
            var result     = controller.Edit(id) as HttpNotFoundResult;
            var statusCode = result.StatusCode;

            // Assert
            Assert.That(result, !Is.Null);
            Assert.That(404, Is.EqualTo(statusCode));
        }
        public void Good_Get_Edit()
        {
            // Arrange
            var id = 1;
            var informationItem = new InformationItem()
            {
                ID         = 1,
                PictureUrl = "/Content/Images/pizza_1.jpg",
                Position   = 1,
                Title      = "Menu",
                Content    = "Ut at viverra arcu. Donec sed interdum nulla, eu porttitor lorem. Morbi efficitur sapien ullamcorper lorem vestibulum, ut aliquet turpis consequat. Suspendisse ac nibh non velit scelerisque bibendum. "
            };
            var informationItemViewModel = new InformationItemViewModel()
            {
                ID         = 1,
                PictureUrl = "/Content/Images/pizza_1.jpg",
                Position   = 1,
                Title      = "Menu",
                Content    = "Ut at viverra arcu. Donec sed interdum nulla, eu porttitor lorem. Morbi efficitur sapien ullamcorper lorem vestibulum, ut aliquet turpis consequat. Suspendisse ac nibh non velit scelerisque bibendum. "
            };
            var service        = Substitute.For <IInformationItemService>();
            var fakeController = new FakeController();
            var controller     = new InformationItemController(service);

            fakeController.PrepareFakeAjaxRequest();
            controller.ControllerContext = fakeController.GetControllerContext <InformationItemController>(new RouteData(), controller);
            service.GetInfomrationItem(id).Returns(informationItem);
            service.MapObjectToViewModel(informationItem).Returns(informationItemViewModel);
            // Act
            var result      = controller.Edit(id) as PartialViewResult;
            var viewName    = result.ViewName;
            var model       = result.Model;
            var ajaxRequest = controller.Request.IsAjaxRequest();

            // Assert
            Assert.That(result, !Is.Null);
            Assert.That("_EditPartial", Is.EqualTo(viewName));
            Assert.That(ajaxRequest, Is.True);
            Assert.That(model, !Is.Null);
        }
Ejemplo n.º 11
0
        public InformationItemViewModel MapObjectToViewModel(InformationItem model)
        {
            var result = _mapper.Map <InformationItem, InformationItemViewModel>(model);

            return(result);
        }
Ejemplo n.º 12
0
        public InformationItem MapViewModelToObject(InformationItemViewModel viewModel, InformationItem model)
        {
            var result = _mapper.Map <InformationItemViewModel, InformationItem>(viewModel, model);

            return(result);
        }
Ejemplo n.º 13
0
 public void UpdateInformationItem(InformationItem informationItem)
 {
     _repository.Update(informationItem);
 }
Ejemplo n.º 14
0
 public void CreateInformationItem(InformationItem infomationItem)
 {
     _repository.Insert(infomationItem);
 }
Ejemplo n.º 15
0
 public void DeleteInfomationItem(InformationItem informationItem)
 {
     _repository.Delete(informationItem);
 }
Ejemplo n.º 16
0
 public void AddItem(InformationItem item)
 {
     item.Instantiate(gameObject.transform, _elementSprite);
 }