Пример #1
0
        protected virtual void SetupTestEntity()
        {
            var shimUser = new ShimUser();

            shimUser.UserIDGet = () => { return(UserId); };
            var user = shimUser.Instance;

            var shimEcnSession = new ShimECNSession();
            var ecnSession     = shimEcnSession.Instance;

            ecnSession.CurrentUser = user;

            var shimMasterPage = new ShimAccounts();

            shimMasterPage.UserSessionGet = () => { return(ecnSession); };
            var masterPage = shimMasterPage.Instance;

            var shimPage = new ShimPage();

            shimPage.MasterGet = () => { return(masterPage); };
            var page = shimPage.Instance;

            _testEntity        = new T();
            _testEntity.ID     = TestEntityId;
            _testEntity.Page   = page;
            _testEntityPrivate = new PrivateObject(_testEntity);
        }
        public void RenderToolbarsContainer_InternalToolBarsIDNotEmpty_RenderHTMLTextWriter(Position toolbarsPosition)
        {
            // Arrange
            _privateObj.SetProperty("InternalToolBarsID", "1,2");
            var shimPage = new ShimPage();

            ShimPage.AllInstances.FindControlString = (obj, id) =>
            {
                return(new Toolbar());
            };
            _privateObj.SetProperty("Page", shimPage.Instance);
            _toolbarsContainer.ToolbarsPosition = toolbarsPosition;
            var          stringWriter     = new StringWriter();
            var          outputTextWriter = new HtmlTextWriter(stringWriter);
            const string HiddenInput      = "<input type=\"hidden\" value=\"\" id=\"_toolbars\" name=\"_toolbars\" />";
            const string Width            = "width:100%";
            const string PositionValue    = "position:Absolute";

            // Act
            _privateObj.Invoke(_MethodRenderToolbarsContainer, new object[] { outputTextWriter });
            var actualResult = stringWriter.ToString();

            // Assert
            actualResult.ShouldSatisfyAllConditions(
                () => actualResult.ShouldNotBeNullOrWhiteSpace(),
                () => actualResult.ShouldContain(PositionValue),
                () => actualResult.ShouldContain(HiddenInput),
                () => actualResult.ShouldContain(Width)
                );
        }
Пример #3
0
        public void Setup()
        {
            _context = ShimsContext.Create();
            ShimWebControl.AllInstances.StyleGet = (x) =>
            {
                return(CreateCssStyleCollection());
            };
            ShimHttpCapabilitiesBase.AllInstances.BrowserGet = (x) => "IE";
            HttpRequest request = new ShimHttpRequest
            {
                BrowserGet = () => new HttpBrowserCapabilities()
            };

            ShimControl.AllInstances.PageGet = (x) =>
            {
                Page page = new ShimPage
                {
                    RequestGet      = () => request,
                    ClientScriptGet = () =>
                    {
                        return(new ShimClientScriptManager
                        {
                            GetWebResourceUrlTypeString = (type, ressourceName) => { return SampleImagePath; }
                        });
                    }
                };
                return(page);
            };
        }
Пример #4
0
        private ShimPage GetMockOfPage(string browser)
        {
            var shimPage                    = new ShimPage();
            var shimHttpRequest             = new ShimHttpRequest();
            var shimHttpBrowserCapabilities = new ShimHttpBrowserCapabilities();

            ShimHttpCapabilitiesBase.AllInstances.BrowserGet = (obj) => browser;
            ShimHttpRequest.AllInstances.BrowserGet          = (obj) => shimHttpBrowserCapabilities.Instance;
            ShimPage.AllInstances.RequestGet      = (obj) => shimHttpRequest.Instance;
            ShimPage.AllInstances.ClientScriptGet = (obj) => new ShimClientScriptManager().Instance;
            ShimClientScriptManager.AllInstances.GetWebResourceUrlTypeString = (obj, type, url) => DummyString;
            return(shimPage);
        }
Пример #5
0
        private void SetupPage()
        {
            if (_shimsContext == null)
            {
                throw new InvalidOperationException("_shimsContext local member must be initialized to setup the Page shim object");
            }

            ShimPage.AllInstances.GetPostBackClientEventControlString = (page, control, value) => string.Empty;

            _shimPage                 = new ShimPage();
            _shimPage.SessionGet      = () => _shimHttpSessionState;
            _shimPage.ServerGet       = () => _shimHttpServerUtility;
            _shimPage.ClientScriptGet = () => _shimClientScriptManager;
        }
Пример #6
0
        private void SetupPage()
        {
            if (_shimsContext == null)
            {
                throw new NullReferenceException("_shimsContext local member must be initialized to setup the Page shim object");
            }

            ShimPage.AllInstances.GetPostBackClientEventControlString = (page, control, value) => string.Empty;
            ShimPage.AllInstances.RegisterStartupScriptStringString   = (page, key, value) => _registeredScripts[key] = value;

            _shimPage                 = new ShimPage();
            _shimPage.SessionGet      = () => _shimHttpSessionState;
            _shimPage.ServerGet       = () => _shimHttpServerUtility;
            _shimPage.ClientScriptGet = () => _shimClientScriptManager;
        }
Пример #7
0
        public void SetUp()
        {
            shimsContext = ShimsContext.Create();

            ICustomerRepository customerRepository = new InMemoryCustomerRepository();
            customerRepository.Add(new Customer { CustomerId = 0, Name = "Customer 1" });
            customerRepository.Add(new Customer { CustomerId = 1, Name = "Customer 2" });
            customerRepository.Add(new Customer { CustomerId = 2, Name = "Customer 3" });

            ISalesOrderRepository salesOrderRepository = new InMemorySalesOrderRepository();
            salesOrderRepository.Add(new SalesOrder { Customer = new Customer { CustomerId = 0, Name = "Customer 1" }, SalesOrderId = 0, Lines = new List<OrderLine> { new OrderLine { Price = 5, Quantity = 5 } } });

            webPart = new SalesOrderWebPart();
            var page = new ShimPage() { IsPostBackGet = () => { return false; } };
            page.BehaveAsDefaultValue();

            var molesWebPart = new ShimControl((Control)webPart) { PageGet = () => { return page; } };
            webPart.Inject(customerRepository, salesOrderRepository);
        }
        public void SetUp()
        {
            shimsContext = ShimsContext.Create();

            ICustomerRepository customerRepository = new InMemoryCustomerRepository();

            customerRepository.Add(new Customer {
                CustomerId = 0, Name = "Customer 1"
            });
            customerRepository.Add(new Customer {
                CustomerId = 1, Name = "Customer 2"
            });
            customerRepository.Add(new Customer {
                CustomerId = 2, Name = "Customer 3"
            });

            ISalesOrderRepository salesOrderRepository = new InMemorySalesOrderRepository();

            salesOrderRepository.Add(new SalesOrder {
                Customer = new Customer {
                    CustomerId = 0, Name = "Customer 1"
                }, SalesOrderId = 0, Lines = new List <OrderLine> {
                    new OrderLine {
                        Price = 5, Quantity = 5
                    }
                }
            });

            webPart = new SalesOrderWebPart();
            var page = new ShimPage()
            {
                IsPostBackGet = () => { return(false); }
            };

            page.BehaveAsDefaultValue();

            var molesWebPart = new ShimControl((Control)webPart)
            {
                PageGet = () => { return(page); }
            };

            webPart.Inject(customerRepository, salesOrderRepository);
        }
Пример #9
0
        private ShimPage GetMockOfPage(string browser)
        {
            var shimPage                    = new ShimPage();
            var shimHttpRequest             = new ShimHttpRequest();
            var shimHttpBrowserCapabilities = new ShimHttpBrowserCapabilities();

            ShimHttpCapabilitiesBase.AllInstances.BrowserGet = (obj) => browser;
            ShimHttpRequest.AllInstances.BrowserGet          = (obj) => shimHttpBrowserCapabilities.Instance;
            ShimPage.AllInstances.RequestGet      = (obj) => shimHttpRequest.Instance;
            ShimPage.AllInstances.ClientScriptGet = (obj) => new ShimClientScriptManager().Instance;
            ShimClientScriptManager.AllInstances.GetWebResourceUrlTypeString = (obj, type, url) => DummyString;
            ShimHttpRequest.AllInstances.ParamsGet = (obj) =>
            {
                var collection = new NameValueCollection();
                collection.Add("__EVENTARGUMENT", "DELETEFILE:");
                return(collection);
            };
            ShimNameObjectCollectionBase.AllInstances.CountGet = (obj) => 1;
            ShimHttpRequest.AllInstances.FilesGet     = (obj) => new ShimHttpFileCollection();
            ShimPage.AllInstances.TraceGet            = (obj) => new TraceContext(new ShimHttpContext());
            ShimTraceContext.AllInstances.WriteString = (obj, str) => { };
            return(shimPage);
        }