public void Should_Return_Page_Content_Options_Successfully() { RunActionInTransaction(session => { var content = TestDataProvider.CreateNewContent(); var pageContent = TestDataProvider.CreateNewPageContent(content); FillContentWithOptions(content); FillPageContentWithOptions(content, pageContent); session.SaveOrUpdate(pageContent); session.Flush(); session.Clear(); // Create command var unitOfWork = new DefaultUnitOfWork(session); var command = new GetPageContentOptionsCommand(); var repository = new DefaultRepository(unitOfWork); command.UnitOfWork = unitOfWork; command.Repository = repository; command.CmsConfiguration = Container.Resolve<ICmsConfiguration>(); command.OptionService = new DefaultOptionService(repository, new HttpRuntimeCacheService(), command.CmsConfiguration); // Execute command var result = command.Execute(pageContent.Id); // Should return 4 options: 2 with assigned values, 1 without parent option and 1 unassigned Assert.IsNotNull(result); Assert.IsNotNull(result.OptionValues); Assert.AreEqual(result.OptionValues.Count, 5); Assert.IsNotNull(result.OptionValues.FirstOrDefault(o => o.OptionKey == content.ContentOptions[0].Key && o.OptionValue == pageContent.Options[0].Value && o.OptionDefaultValue == content.ContentOptions[0].DefaultValue && !o.UseDefaultValue && !o.CanEditOption)); Assert.IsNotNull(result.OptionValues.FirstOrDefault(o => o.OptionKey == content.ContentOptions[1].Key && o.OptionValue == pageContent.Options[1].Value && o.OptionDefaultValue == content.ContentOptions[1].DefaultValue && !o.UseDefaultValue && !o.CanEditOption)); Assert.IsNotNull(result.OptionValues.FirstOrDefault(o => o.OptionKey == content.ContentOptions[2].Key && o.OptionValue == content.ContentOptions[2].DefaultValue && o.OptionDefaultValue == content.ContentOptions[2].DefaultValue && o.UseDefaultValue && !o.CanEditOption)); Assert.IsNotNull(result.OptionValues.FirstOrDefault(o => o.OptionKey == pageContent.Options[2].Key && o.OptionValue == pageContent.Options[2].Value && o.OptionDefaultValue == null && o.CanEditOption)); Assert.IsNotNull(result.OptionValues.FirstOrDefault(o => o.OptionKey == pageContent.Options[3].Key && o.OptionValue == pageContent.Options[3].Value && o.OptionDefaultValue == null && o.CanEditOption)); }); }
public void Should_Return_Page_Content_Options_Successfully() { RunActionInTransaction(session => { var content = TestDataProvider.CreateNewContent(); var pageContent = TestDataProvider.CreateNewPageContent(content); FillContentWithOptions(content); FillPageContentWithOptions(content, pageContent); session.SaveOrUpdate(pageContent); session.Flush(); session.Clear(); // Create command var unitOfWork = new DefaultUnitOfWork(session); var command = new GetPageContentOptionsCommand(); var repository = new DefaultRepository(unitOfWork); command.UnitOfWork = unitOfWork; command.Repository = repository; command.CmsConfiguration = Container.Resolve <ICmsConfiguration>(); command.OptionService = new DefaultOptionService(repository, new HttpRuntimeCacheService(), command.CmsConfiguration); // Execute command var result = command.Execute(pageContent.Id); // Should return 4 options: 2 with assigned values, 1 without parent option and 1 unassigned Assert.IsNotNull(result); Assert.IsNotNull(result.OptionValues); Assert.AreEqual(result.OptionValues.Count, 5); Assert.IsNotNull(result.OptionValues.FirstOrDefault(o => o.OptionKey == content.ContentOptions[0].Key && o.OptionValue == pageContent.Options[0].Value && o.OptionDefaultValue == content.ContentOptions[0].DefaultValue && !o.UseDefaultValue && !o.CanEditOption)); Assert.IsNotNull(result.OptionValues.FirstOrDefault(o => o.OptionKey == content.ContentOptions[1].Key && o.OptionValue == pageContent.Options[1].Value && o.OptionDefaultValue == content.ContentOptions[1].DefaultValue && !o.UseDefaultValue && !o.CanEditOption)); Assert.IsNotNull(result.OptionValues.FirstOrDefault(o => o.OptionKey == content.ContentOptions[2].Key && o.OptionValue == content.ContentOptions[2].DefaultValue && o.OptionDefaultValue == content.ContentOptions[2].DefaultValue && o.UseDefaultValue && !o.CanEditOption)); Assert.IsNotNull(result.OptionValues.FirstOrDefault(o => o.OptionKey == pageContent.Options[2].Key && o.OptionValue == pageContent.Options[2].Value && o.OptionDefaultValue == null && o.CanEditOption)); Assert.IsNotNull(result.OptionValues.FirstOrDefault(o => o.OptionKey == pageContent.Options[3].Key && o.OptionValue == pageContent.Options[3].Value && o.OptionDefaultValue == null && o.CanEditOption)); }); }
public void Should_Return_Page_Content_Options_Successfully() { RunActionInTransaction(session => { var content = TestDataProvider.CreateNewContent(); var pageContent = TestDataProvider.CreateNewPageContent(content); FillContentWithOptions(content); FillPageContentWithOptions(content, pageContent); session.SaveOrUpdate(pageContent); session.Flush(); session.Clear(); // Create command var unitOfWork = new DefaultUnitOfWork(session); var command = new GetPageContentOptionsCommand(); command.UnitOfWork = unitOfWork; command.Repository = new DefaultRepository(unitOfWork); // Execute command var result = command.Execute(pageContent.Id); // Should return 4 options: 2 with assigned values, 1 without parent option and 1 unassigned Assert.IsNotNull(result); Assert.IsNotNull(result.WidgetOptions); Assert.AreEqual(result.WidgetOptions.Count, 4); Assert.IsNotNull(result.WidgetOptions.FirstOrDefault(o => o.OptionKey == content.ContentOptions[0].Key && o.OptionValue == pageContent.Options[0].Value && o.OptionDefaultValue == content.ContentOptions[0].DefaultValue)); Assert.IsNotNull(result.WidgetOptions.FirstOrDefault(o => o.OptionKey == content.ContentOptions[1].Key && o.OptionValue == pageContent.Options[1].Value && o.OptionDefaultValue == content.ContentOptions[1].DefaultValue)); Assert.IsNotNull(result.WidgetOptions.FirstOrDefault(o => o.OptionKey == content.ContentOptions[2].Key && o.OptionValue == null && o.OptionDefaultValue == content.ContentOptions[2].DefaultValue)); Assert.IsNotNull(result.WidgetOptions.FirstOrDefault(o => o.OptionKey == pageContent.Options[2].Key && o.OptionValue == pageContent.Options[2].Value && o.OptionDefaultValue == null)); }); }
public void Should_Return_Page_Content_Options_Successfully() { RunActionInTransaction(session => { var content = TestDataProvider.CreateNewContent(); var pageContent = TestDataProvider.CreateNewPageContent(content); FillContentWithOptions(content); FillPageContentWithOptions(content, pageContent); session.SaveOrUpdate(pageContent); session.Flush(); session.Clear(); // Create command var unitOfWork = new DefaultUnitOfWork(session); var command = new GetPageContentOptionsCommand(); command.UnitOfWork = unitOfWork; command.Repository = new DefaultRepository(unitOfWork); // Execute command var result = command.Execute(pageContent.Id); // Should return 4 options: 2 with assigned values, 1 without parent option and 1 unassigned Assert.IsNotNull(result); Assert.IsNotNull(result.WidgetOptions); Assert.AreEqual(result.WidgetOptions.Count, 4); Assert.IsNotNull(result.WidgetOptions.FirstOrDefault(o => o.OptionKey == content.ContentOptions[0].Key && o.OptionValue == pageContent.Options[0].Value && o.OptionDefaultValue == content.ContentOptions[0].DefaultValue)); Assert.IsNotNull(result.WidgetOptions.FirstOrDefault(o => o.OptionKey == content.ContentOptions[1].Key && o.OptionValue == pageContent.Options[1].Value && o.OptionDefaultValue == content.ContentOptions[1].DefaultValue)); Assert.IsNotNull(result.WidgetOptions.FirstOrDefault(o => o.OptionKey == content.ContentOptions[2].Key && o.OptionValue == null && o.OptionDefaultValue == content.ContentOptions[2].DefaultValue)); Assert.IsNotNull(result.WidgetOptions.FirstOrDefault(o => o.OptionKey == pageContent.Options[2].Key && o.OptionValue == pageContent.Options[2].Value && o.OptionDefaultValue == null)); }); }