public void TestCheckLoadAllowedURLListData() { Console.WriteLine("Before TestCheckLoadAllowedURLListData"); //Create the mocked inputcontext Mockery mock = new Mockery(); IInputContext mockedInputContext = DnaMockery.CreateDatabaseInputContext(); //XmlDocument siteconfig = new XmlDocument(); //siteconfig.LoadXml("<SITECONFIG />"); ISite site = mock.NewMock<ISite>(); //Stub.On(site).GetProperty("SiteConfig").Will(Return.Value(siteconfig.FirstChild)); Stub.On(site).GetProperty("SiteID").Will(Return.Value(1)); User user = new User(mockedInputContext); Stub.On(mockedInputContext).GetProperty("ViewingUser").Will(Return.Value(user)); Stub.On(mockedInputContext).GetProperty("CurrentSite").Will(Return.Value(site)); // Create the stored procedure reader for the UITemplate object using (IDnaDataReader reader = mockedInputContext.CreateDnaDataReader("getallallowedurls")) { Stub.On(mockedInputContext).Method("CreateDnaDataReader").With("getallallowedurls").Will(Return.Value(reader)); AllowedURLs allowedURLs = new AllowedURLs(); allowedURLs.LoadAllowedURLLists(mockedInputContext); Assert.IsTrue(allowedURLs.DoesAllowedURLListContain(1, "www.bbc.co.uk"), "Does not report that it contains the bbc web address"); } Console.WriteLine("After TestCheckLoadAllowedURLListData"); }
/// <summary> /// Helper method for creating the mocked AllowedURLs object /// </summary> /// <param name="mockedInput">The context that you want to add the AllowedURLs mocked object to</param> /// <returns>The new mocked AllowedURLs object</returns> public static IAllowedURLs SetDefaultAllowedURLs(IInputContext mockedInput) { //IAllowedURLs mockedAllowedURLs = _mockery.NewMock<IAllowedURLs>(); //Stub.On(mockedAllowedURLs).Method("DoesAllowedURLListContain").Will(Return.Value(true)); //Stub.On(mockedAllowedURLs).Method("WriteWarningToLog").Will(Return.Value(null)); //Stub.On(mockedAllowedURLs).Method("WriteToLog").Will(Return.Value(null)); //Stub.On(mockedInput).GetProperty("AllowedURLs").Will(Return.Value(mockedAllowedURLs)); //return mockedAllowedURLs; AllowedURLs urls = new AllowedURLs(); urls.LoadAllowedURLLists(mockedInput); Stub.On(mockedInput).GetProperty("AllowedURLs").Will(Return.Value(urls)); return urls; }
private void InitialiseAllowedURLs(object context) { AllowedURLs allowedURLs = new AllowedURLs(); allowedURLs.LoadAllowedURLLists((IAppContext)context); _allowedURLs = allowedURLs; ((IAppContext)context).Diagnostics.WriteToLog("Initialisation", "Initialised AllowedURLs"); }