Exemplo n.º 1
0
        public override int Delete(params object[] primaryKeys)
        {
            LayoutEntity layout            = Get(primaryKeys);
            var          layoutHtmlService = new LayoutHtmlService();

            layoutHtmlService.Delete(new Data.DataFilter().Where <LayoutHtml>(m => m.LayoutId, OperatorType.Equal, layout.ID));

            var zoneService = new ZoneService();

            zoneService.Delete(new Data.DataFilter().Where <ZoneEntity>(m => m.LayoutId, OperatorType.Equal, layout.ID));


            var pageService = new Page.PageService();

            pageService.Delete(new DataFilter().Where("LayoutId", OperatorType.Equal, layout.ID));

            var widgetService = new WidgetService();
            var widgets       = widgetService.Get(new DataFilter().Where("LayoutId", OperatorType.Equal, layout.ID));

            widgets.Each(m =>
            {
                m.CreateServiceInstance().DeleteWidget(m.ID);
            });
            Signal.Trigger(LayoutChanged);
            return(base.Delete(primaryKeys));
        }
Exemplo n.º 2
0
        public HomeController()
        {
            unitOfWork = new UnitOfWork();

            notificationService = new NotificationService(unitOfWork);
            widgetService       = new WidgetService(unitOfWork);
        }
Exemplo n.º 3
0
        public void TheWidgetShouldBeReturned()
        {
            //Arrange
            List<DomainWidget> values = new List<DomainWidget>
            {
                new DomainWidget
                {
                    Name = "Test Widget",
                    Description = "A test widget",
                    Manufacturer = "Radix2"
                },
                new DomainWidget
                {
                    Name = "Second Widget",
                    Description = "A second widget",
                    Manufacturer = "Radix2"
                }

            };
            IQueryable<DomainWidget> valuesQueryable = values.AsQueryable();

            var mockRepository = new Mock<IRepository>();
            mockRepository
                .Setup(x => x.All<DomainWidget>(It.IsAny<String[]>()))
                .Returns(()=> valuesQueryable);

            var widgetService = new WidgetService(mockRepository.Object);

            //Act
            var widgets = widgetService.Get();

            //Assert
            Assert.IsInstanceOf<List<DomainWidget>>(widgets);
        }
Exemplo n.º 4
0
        public WidgetServiceTest()
        {
            // meta repo
            _metaRepo = new SqlMetaRepository(_db);

            // setup CoreSettings
            var settingSvcMock = new Mock <ISettingService>();

            settingSvcMock.Setup(svc => svc.GetSettingsAsync <CoreSettings>()).Returns(Task.FromResult(new CoreSettings()));

            // set ContentRootPath to "Fan.IntegrationTests"
            var workingDirectory = Environment.CurrentDirectory;
            var projectDirectory = Directory.GetParent(workingDirectory).Parent.Parent.FullName;
            var env = new Mock <IHostingEnvironment>();

            env.Setup(m => m.ContentRootPath).Returns(projectDirectory);

            // logger
            var loggerWidgetSvc = _loggerFactory.CreateLogger <WidgetService>();
            var loggerThemeSvc  = _loggerFactory.CreateLogger <ThemeService>();

            // theme service
            themeService = new ThemeService(settingSvcMock.Object, env.Object, _cache, _metaRepo, loggerThemeSvc);

            _svc = new WidgetService(_metaRepo, themeService, _cache, settingSvcMock.Object, env.Object, loggerWidgetSvc)
            {
                // set widget dir
                WidgetDirectoryName = "Widgets"
            };
        }
Exemplo n.º 5
0
        public async Task <ActionResult> WidgetsAsync()
        {
            ViewBag.SyncOrAsync = "Asynchronous";
            var widgetService = new WidgetService();

            return(View("Widgets", await widgetService.GetWidgetsAsync()));
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var widgetService = new WidgetService();

            WidgetGridView.DataSource = widgetService.GetWidgets();
            WidgetGridView.DataBind();
        }
Exemplo n.º 7
0
        public ActionResult Widgets()
        {
            ViewBag.SyncOrAsync = "Synchronous";
            var widgetService = new WidgetService();

            return(View("Widgets", widgetService.GetWidgets()));
        }
        public async Task <ActionResult> PWGtimeOut(CancellationToken cancellationToken)
        {
            ViewBag.SyncType = "Asynchronous with CancellationToken";

            var widgetService = new WidgetService();
            var prodService   = new ProductService();
            var gizmoService  = new GizmoService();

            var widgetTask = widgetService.GetWidgetsAsync(cancellationToken);
            var prodTask   = prodService.GetProductsAsync(cancellationToken);
            var gizmoTask  = gizmoService.GetGizmosAsync(cancellationToken);

            await Task.WhenAll(widgetTask, prodTask, gizmoTask);

            var pwgVM = new ProdGizWidgetVM(
                widgetTask.Result,
                prodTask.Result,
                gizmoTask.Result
                );

            ViewBag.numGizmos   = pwgVM.gizmoList.Count();
            ViewBag.numWidgets  = pwgVM.widgetList.Count();
            ViewBag.numProducts = pwgVM.prodList.Count();

            return(View("PWG", pwgVM));
        }
Exemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var widgetService = new WidgetService();

            var widgetList = widgetService.GetWidgets();
            // ToDo, display Widgets
        }
Exemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            var widgetService = new WidgetService();
            var prodService   = new ProductService();
            var gizmoService  = new GizmoService();

            var pwgVM = new ProdGizWidgetVM(
                widgetService.GetWidgets(),
                prodService.GetProducts(),
                gizmoService.GetGizmos()
                );

            WidgetGridView.DataSource = pwgVM.widgetList;
            WidgetGridView.DataBind();
            ProductGridView.DataSource = pwgVM.prodList;
            ProductGridView.DataBind();
            GizmoGridView.DataSource = pwgVM.gizmoList;
            GizmoGridView.DataBind();

            stopWatch.Stop();
            ElapsedTimeLabel.Text = String.Format("Elapsed time: {0}",
                                                  stopWatch.Elapsed.Milliseconds / 1000.0);
        }
Exemplo n.º 11
0
        public void Revert(string ID, bool RetainLatest)
        {
            var page = Get(ID);

            if (page.IsPublishedPage)
            {
                if (RetainLatest)
                {//保留当前编辑版本
                    Update(new PageEntity {
                        IsPublish = false
                    },
                           new DataFilter(new List <string> {
                        "IsPublish"
                    }).Where("ID", OperatorType.Equal,
                             page.ReferencePageID));
                    page.PublishDate = DateTime.Now;
                    Add(page);
                }
                else
                {
                    Update(new PageEntity {
                        PublishDate = null
                    },
                           new DataFilter(new List <string> {
                        "PublishDate"
                    }).Where("ID", OperatorType.Equal,
                             page.ReferencePageID));
                    Delete(page.ReferencePageID); //删除当前的编辑版本,加入旧的版本做为编辑版本,再发布
                    page.ID = page.ReferencePageID;
                    page.ReferencePageID = null;
                    page.IsPublish       = false;
                    page.IsPublishedPage = false;
                    if (page.ExtendFields != null)
                    {
                        page.ExtendFields.Each(m => m.ActionType = ActionType.Create);
                    }
                    base.Add(page);
                }
                var widgets = WidgetService.GetByPageId(ID);
                widgets.Each(m =>
                {
                    var widgetService = m.CreateServiceInstance();
                    m = widgetService.GetWidget(m);
                    if (m.ExtendFields != null)
                    {
                        m.ExtendFields.Each(f => f.ActionType = ActionType.Create);
                    }
                    m.PageID = page.ID;
                    widgetService.Publish(m);
                });
                if (!RetainLatest)
                {
                    Publish(page);
                }
                else
                {
                    StaticPageCache.Delete(page.ReferencePageID);
                }
            }
        }
    /// <summary>
    /// Handles the Click event of the btnSubmit control.
    /// </summary>
    private void btnSubmit_Click(object sender, EventArgs e)
    {
        if (EditEnabled && propertiesForm.SaveData(null, false))
        {
            var properties = new NameValueCollection();
            propertiesForm.Fields.ForEach(fieldName =>
            {
                var fieldDataType = propertiesForm.FormInformation.GetFormField(fieldName).DataType;
                var fieldValue    = propertiesForm.Data.GetValue(fieldName);
                var value         = DataTypeManager.GetStringValue(TypeEnum.Field, fieldDataType, fieldValue, CultureHelper.EnglishCulture);

                properties.Add(fieldName, value);
            });

            try
            {
                WidgetService.StoreWidgetProperties(widgetInstanceGuid, properties);
                hdnSaveStatus.Value = "1";
            }
            catch (InvalidOperationException exception)
            {
                Service.Resolve <IEventLogService>().LogException("Newsletter", "SAVEWIDGETPROP", exception);
            }
        }
    }
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        widgetInstanceGuid = QueryHelper.GetGuid("widgetinstanceguid", Guid.Empty);

        widgetInstance = WidgetService.GetWidgetConfiguration(widgetInstanceGuid);
        if (widgetInstance == null)
        {
            ShowWidgetNotFound();
            return;
        }

        widgetTypeDefinition = EmailWidgetInfo.Provider.Get(widgetInstance.TypeIdentifier, SiteContext.CurrentSiteID);
        if (widgetTypeDefinition == null)
        {
            ShowWidgetNotFound();
            return;
        }

        widgetTypeFormInfo = new FormInfo(widgetTypeDefinition.EmailWidgetProperties);

        btnSubmit.Enabled = EditEnabled;
        SetClientApplicationData();
        SetupHeader();
        SetupForm();

        if (EditEnabled)
        {
            btnSubmit.Click += btnSubmit_Click;
        }

        // Add shadow below header actions
        ScriptHelper.RegisterModule(Page, "CMS/HeaderShadow");
    }
Exemplo n.º 14
0
        public void TestTheBoom()
        {
            var mockData = GetStubData();
            var service  = new WidgetService(mockData.Object);

            service.Boom();
        }
Exemplo n.º 15
0
        public async Task <IViewComponentResult> InvokeAsync(Widget widget)
        {
            var blogTagsWidget = (BlogTagsWidget)widget;
            var tags           = (await _tagSvc.GetAllAsync()).Where(t => t.Count > 0).Take(blogTagsWidget.MaxTagsDisplayed);

            return(View(WidgetService.GetWidgetViewPath("BlogTags"), new Tuple <IEnumerable <Tag>, BlogTagsWidget>(tags, blogTagsWidget)));
        }
Exemplo n.º 16
0
        public void ConnectToExpensiveResourceAndGetAWidget()
        {
            var service = new WidgetService(new WidgetData());

            var widget = service.GetWidget(1); //gotta make sure my data has this widget!

            Assert.IsNotNull(widget);
        }
Exemplo n.º 17
0
        public async Task <IViewComponentResult> InvokeAsync(Widget widget)
        {
            var blogCategoriesWidget = (BlogCategoriesWidget)widget;
            var categories           = (await _catSvc.GetAllAsync()).Where(t => t.Count > 0);

            return(View(WidgetService.GetWidgetViewPath("BlogCategories"),
                        new Tuple <IEnumerable <Category>, BlogCategoriesWidget>(categories, blogCategoriesWidget)));
        }
Exemplo n.º 18
0
        public async Task <IViewComponentResult> InvokeAsync(Widget widget)
        {
            var blogArchivesWidget = (BlogArchivesWidget)widget;
            var years = await _statsSvc.GetArchivesAsync();

            return(View(WidgetService.GetWidgetViewPath("BlogArchives"),
                        new Tuple <Dictionary <int, List <MonthItem> >, BlogArchivesWidget>(years, blogArchivesWidget)));
        }
Exemplo n.º 19
0
        public void GetWidgetExpected()
        {
            var mockData = GetStubData();
            var service  = new WidgetService(mockData.Object);

            var widget = service.GetWidget(1);

            Assert.IsNotNull(widget);
        }
Exemplo n.º 20
0
        public IHtmlString GetHtml(Widget widget)
        {
            var viewData = new ViewDataDictionary();

            viewData.Add("CurrentWidget", widget);
            var service = new WidgetService(widget.Site);

            return(_htmlHelper.Partial(service.GetWidgetPath(widget), viewData));
        }
Exemplo n.º 21
0
        // public void OnGet() { }

        public IActionResult OnPost([FromServices] WidgetService service)
        {
            if (ModelState.IsValid)
            {
                var widget = service.Add(Name);
                return(RedirectToPage("Index"));
            }

            return(Page());
        }
Exemplo n.º 22
0
        private async Task GetWidgetSrvAsync()
        {
            var widgetService = new WidgetService();
            var widgetList    = await widgetService.GetWidgetsAsync();

            WidgetGridView.DataSource = widgetList;
            WidgetGridView.DataBind();

            stopWatch.Stop();
            ElapsedTimeLabel.Text = String.Format("Elapsed time: {0}", stopWatch.Elapsed.Milliseconds / 1000.0);
        }
Exemplo n.º 23
0
        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            ZoneWidgetCollection zones = new ZoneWidgetCollection();

            //Page
            string      pageId      = filterContext.RequestContext.HttpContext.Request.QueryString["ID"];
            PageService pageService = new PageService();
            PageEntity  page        = pageService.Get(pageId);

            if (page != null)
            {
                LayoutService layoutService = new LayoutService();
                var           layout        = layoutService.Get(page.LayoutId);
                layout.Page = page;
                WidgetService            widgetService = new WidgetService();
                IEnumerable <WidgetBase> widgets       = widgetService.Get(new DataFilter().Where <WidgetBase>(m => m.PageID, OperatorType.Equal, page.ID));
                Action <WidgetBase>      processWidget = m =>
                {
                    IWidgetPartDriver partDriver = Activator.CreateInstance(m.AssemblyName, m.ServiceTypeName).Unwrap() as IWidgetPartDriver;
                    WidgetPart        part       = partDriver.Display(partDriver.GetWidget(m), filterContext.HttpContext);
                    lock (zones)
                    {
                        if (zones.ContainsKey(part.Widget.ZoneID))
                        {
                            zones[part.Widget.ZoneID].Add(part);
                        }
                        else
                        {
                            WidgetCollection partCollection = new WidgetCollection();
                            partCollection.Add(part);
                            zones.Add(part.Widget.ZoneID, partCollection);
                        }
                    }
                };
                widgets.Each(processWidget);

                IEnumerable <WidgetBase> Layoutwidgets = widgetService.Get(new Data.DataFilter().Where <WidgetBase>(m => m.LayoutID, OperatorType.Equal, page.LayoutId));

                Layoutwidgets.Each(processWidget);

                layout.ZoneWidgets = zones;
                ViewResult viewResult = (filterContext.Result as ViewResult);
                if (viewResult != null)
                {
                    viewResult.MasterName = "~/Modules/Common/Views/Shared/_DesignPageLayout.cshtml";
                    viewResult.ViewData[LayoutEntity.LayoutKey] = layout;
                }
            }
            else
            {
                filterContext.Result = new HttpStatusCodeResult(404);
            }
        }
Exemplo n.º 24
0
        public JsonResult DeleteWidget(string ID)
        {
            WidgetService widgetService = new WidgetService();
            WidgetBase    widget        = widgetService.Get(ID);

            if (widget != null)
            {
                widget.CreateServiceInstance().DeleteWidget(ID);
                return(Json(true));
            }
            return(Json(false));
        }
Exemplo n.º 25
0
        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            ZoneWidgetCollection zones = new ZoneWidgetCollection();

            //Page
            string pageId = filterContext.RequestContext.HttpContext.Request.QueryString["ID"];
            PageService pageService = new PageService();
            PageEntity page = pageService.Get(pageId);

            if (page != null)
            {
                LayoutService layoutService = new LayoutService();
                var layout = layoutService.Get(page.LayoutId);
                layout.Page = page;
                WidgetService widgetService = new WidgetService();
                IEnumerable<WidgetBase> widgets = widgetService.Get(new DataFilter().Where<WidgetBase>(m => m.PageID, OperatorType.Equal, page.ID));
                Action<WidgetBase> processWidget = m =>
                {
                    IWidgetPartDriver partDriver = Activator.CreateInstance(m.AssemblyName, m.ServiceTypeName).Unwrap() as IWidgetPartDriver;
                    WidgetPart part = partDriver.Display(partDriver.GetWidget(m), filterContext.HttpContext);
                    lock (zones)
                    {
                        if (zones.ContainsKey(part.Widget.ZoneID))
                        {
                            zones[part.Widget.ZoneID].Add(part);
                        }
                        else
                        {
                            WidgetCollection partCollection = new WidgetCollection();
                            partCollection.Add(part);
                            zones.Add(part.Widget.ZoneID, partCollection);
                        }
                    }
                };
                widgets.Each(processWidget);

                IEnumerable<WidgetBase> Layoutwidgets = widgetService.Get(new Data.DataFilter().Where<WidgetBase>(m => m.LayoutID, OperatorType.Equal, page.LayoutId));

                Layoutwidgets.Each(processWidget);

                layout.ZoneWidgets = zones;
                ViewResult viewResult = (filterContext.Result as ViewResult);
                if (viewResult != null)
                {
                    viewResult.MasterName = "~/Modules/Common/Views/Shared/_DesignPageLayout.cshtml";
                    viewResult.ViewData[LayoutEntity.LayoutKey] = layout;
                }
            }
            else
            {
                filterContext.Result = new HttpStatusCodeResult(404);
            }
        }
Exemplo n.º 26
0
        public JsonResult SaveWidgetPosition(List <WidgetBase> widgets)
        {
            var widgetService = new WidgetService();

            widgets.Each(m =>
            {
                widgetService.Update(m, new Data.DataFilter(new List <string> {
                    "Position"
                }).Where <WidgetBase>(n => n.ID, OperatorType.Equal, m.ID));
            });
            return(Json(true));
        }
Exemplo n.º 27
0
        public void DeleteVersion(string ID)
        {
            PageEntity page = Get(ID);

            if (page != null)
            {
                var widgets = WidgetService.Get(m => m.PageID == page.ID);
                widgets.Each(m => m.CreateServiceInstance().DeleteWidget(m.ID));
                DataArchivedService.Delete(CacheTrigger.PageWidgetsArchivedKey.FormatWith(page.ID));
            }
            base.Delete(ID);
        }
Exemplo n.º 28
0
        public void DeleteVersion(string ID)
        {
            PageEntity page = Get(ID);

            if (page != null)
            {
                var widgets = WidgetService.Get(m => m.PageID == page.ID);
                widgets.Each(m => m.CreateServiceInstance().DeleteWidget(m.ID));
                StaticPageCache.Delete(page.ID);
            }
            base.Delete(ID);
        }
        public async Task <ActionResult> WidgetsAsync()
        {
            System.Diagnostics.Debug.WriteLine("Entering WidgetsAsync. Context: " + SynchronizationContext.Current.GetHashCode());
            ViewBag.SyncOrAsync = "Asynchronous";
            var widgetService = new WidgetService();
            var widgets       = await widgetService.GetWidgetsAsync();

            ViewBag.numWidgets = widgets.Count();
            System.Diagnostics.Debug.WriteLine("Leaving WidgetsAsync");

            return(View("Widgets", widgets));
        }
Exemplo n.º 30
0
 public ActionResult Edit(string ID, string ReturnUrl)
 {
     var widgetService = new WidgetService();
     var widgetBase = widgetService.Get(ID);
     var widget = widgetBase.CreateServiceInstance().GetWidget(widgetBase);
     ViewBag.ReturnUrl = ReturnUrl;
     if (widget.FormView.IsNotNullAndWhiteSpace())
     {
         return View(widget.FormView, widget);
     }
     return View(widget);
 }
Exemplo n.º 31
0
        public ActionResult Edit(string ID, string ReturnUrl)
        {
            var widgetService = new WidgetService();
            var widgetBase    = widgetService.Get(ID);
            var widget        = widgetBase.CreateServiceInstance().GetWidget(widgetBase);

            ViewBag.ReturnUrl = ReturnUrl;
            if (widget.FormView.IsNotNullAndWhiteSpace())
            {
                return(View(widget.FormView, widget));
            }
            return(View(widget));
        }
Exemplo n.º 32
0
        public void WidgetCacheIsUsed()
        {
            var mockData = GetStubData();

            var service = new WidgetService(mockData.Object);

            var widgets1 = service.GetAllWidgets();
            var widgets2 = service.GetAllWidgets();

            //check behavior: cache should be used in second call
            mockData.Verify(d => d.GetWidgets(), Times.Once);
            Assert.AreEqual(widgets1.Count(), widgets2.Count());
        }
Exemplo n.º 33
0
        public void AuthorizationRequiredForCreditPurchasesOver1000UsDollars()
        {
            var mockData = GetStubData();
            var service  = new WidgetService(mockData.Object);

            var receiptModel =
                service.PurchaseWidgets(new[] { new WidgetModel {
                                                    Id = 0, Name = "Something", Price = 1001.00m
                                                } },
                                        "creditcard", 1001.00m);

            Assert.IsTrue(receiptModel.Message.Contains("Authorization"));
        }
Exemplo n.º 34
0
        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            var zones = new ZoneWidgetCollection();
            var cache = new StaticCache();
            //Page
            string path = filterContext.RequestContext.HttpContext.Request.Path;
            if (path.EndsWith("/") && path.Length > 1)
            {
                path = path.Substring(0, path.Length - 1);
                //filterContext.HttpContext.Response.Redirect(path);
                filterContext.Result = new RedirectResult(path);
                return;
            }
            bool publish = !ReView.Review.Equals(filterContext.RequestContext.HttpContext.Request.QueryString[ReView.QueryKey], StringComparison.CurrentCultureIgnoreCase);
            var page = new PageService().GetByPath(path, publish);
            if (page != null)
            {
                var layoutService = new LayoutService();
                LayoutEntity layout = layoutService.Get(page.LayoutId);
                layout.Page = page;

                Action<WidgetBase> processWidget = m =>
                {
                    IWidgetPartDriver partDriver = cache.Get("IWidgetPartDriver_" + m.AssemblyName + m.ServiceTypeName, source =>
                         Activator.CreateInstance(m.AssemblyName, m.ServiceTypeName).Unwrap() as IWidgetPartDriver
                    );
                    WidgetPart part = partDriver.Display(partDriver.GetWidget(m), filterContext.HttpContext);
                    lock (zones)
                    {
                        if (zones.ContainsKey(part.Widget.ZoneID))
                        {
                            zones[part.Widget.ZoneID].Add(part);
                        }
                        else
                        {
                            var partCollection = new WidgetCollection { part };
                            zones.Add(part.Widget.ZoneID, partCollection);
                        }
                    }
                };
                var layoutWidgetsTask = Task.Factory.StartNew(layoutId =>
                {
                    var widgetServiceIn = new WidgetService();
                    IEnumerable<WidgetBase> layoutwidgets = widgetServiceIn.Get(new DataFilter().Where("LayoutID", OperatorType.Equal, layoutId));
                    layoutwidgets.Each(processWidget);
                }, page.LayoutId);


                var widgetService = new WidgetService();
                IEnumerable<WidgetBase> widgets = widgetService.Get(new DataFilter().Where("PageID", OperatorType.Equal, page.ID));
                int middle = widgets.Count() / 2;
                var pageWidgetsTask = Task.Factory.StartNew(() => widgets.Skip(middle).Each(processWidget));
                widgets.Take(middle).Each(processWidget);
                Task.WaitAll(new[] { pageWidgetsTask, layoutWidgetsTask });

                layout.ZoneWidgets = zones;
                var viewResult = (filterContext.Result as ViewResult);
                if (viewResult != null)
                {
                    //viewResult.MasterName = "~/Modules/Easy.Web.CMS.Page/Views/Shared/_Layout.cshtml";
                    viewResult.ViewData[LayoutEntity.LayoutKey] = layout;
                }
            }
            else
            {
                filterContext.Result = new HttpStatusCodeResult(404);
            }
        }
Exemplo n.º 35
0
        public void TheServiceShouldThrowAnExceptionIfWidgetModelIsNotValid()
        {
            //Arrange
            var mockRepository = new Mock<IRepository>();
            mockRepository
                .Setup(x => x.Create(It.IsAny<Widget>()))
                .Throws(new Exception());

            var mockWidgetService = new WidgetService(mockRepository.Object);

            //Act
            mockWidgetService.Post(new Domain.Models.Widgets.Widget());

            //Assert

        }
Exemplo n.º 36
0
 public WidgetsController(WidgetService service)
 {
     _service = service;
 }
Exemplo n.º 37
0
 public WidgetServiceTests()
 {
     _widgetService = new WidgetService(Session);
 }
Exemplo n.º 38
0
        public void TheWidgetShouldBePersisted()
        {
            //Arrange
            var value = new DomainWidget
            {
                Name = "Test Widget",
                Description = "A test widget",
                Manufacturer = "Radix2"
            };
            var mockRepository = new Mock<IRepository>();
            mockRepository
                .Setup(x => x.Create(It.IsAny<Widget>()));

            var widgetService = new WidgetService(mockRepository.Object);

            //Act
            widgetService.Post(value);

            //Assert
            mockRepository.Verify(v=>v.Create(It.IsAny<Widget>()));
        }
Exemplo n.º 39
0
 public JsonResult SaveWidgetPosition(List<WidgetBase> widgets)
 {
     var widgetService = new WidgetService();
     widgets.Each(m =>
     {
         widgetService.Update(m, new Data.DataFilter(new List<string> { "Position" }).Where<WidgetBase>(n => n.ID, OperatorType.Equal, m.ID));
     });
     return Json(true);
 }
Exemplo n.º 40
0
 public JsonResult DeleteWidget(string ID)
 {
     WidgetService widgetService = new WidgetService();
     WidgetBase widget = widgetService.Get(ID);
     if (widget != null)
     {
         widget.CreateServiceInstance().DeleteWidget(ID);
         return Json(true);
     }
     return Json(false);
 }
 public void CanLoad()
 {
     var service = new WidgetService();
     service.Load("CommonLibrary.Web.Modules.Tests");
     var links = service.Create("Links");
 }