Пример #1
0
        /// <summary>
        /// Test to make sure that we can add emails to the banned emails table
        /// </summary>
        private void TestAddingSampleDataToBannedEmails(string email, bool complaintBanned, bool signinBanned)
        {
            // Create the context for the object
            IInputContext context = DnaMockery.CreateDatabaseInputContext();
            DnaMockery.SetDefaultDiagnostics(context);

            // Mock up the request params for the test
            Stub.On(context).Method("DoesParamExist").With("show", "Do we have the number of items to show?").Will(Return.Value(false));
            Stub.On(context).Method("DoesParamExist").With("skip", "Do we have the number of items to skip?").Will(Return.Value(false));
            Stub.On(context).Method("DoesParamExist").With("ViewAll", "Are we viewing all items?").Will(Return.Value(false));
            Stub.On(context).Method("DoesParamExist").With("ViewByLetter", "Are we wanting to search by letter?").Will(Return.Value(false));

            // Mock the action params
            Stub.On(context).Method("DoesParamExist").With("togglecomplaintban", "Are we toggling the complaint ban for an email").Will(Return.Value(false));
            Stub.On(context).Method("DoesParamExist").With("togglesigninban", "Are we toggling the signin ban for an email").Will(Return.Value(false));
            Stub.On(context).Method("DoesParamExist").With("remove", "Are we tring to remove an email").Will(Return.Value(false));

            // Mock the add params
            Stub.On(context).Method("DoesParamExist").With("AddEmail", "Are we tring to remove an email").Will(Return.Value(true));
            Stub.On(context).Method("GetParamStringOrEmpty").With("NewEmail", "Get the new email address to add").Will(Return.Value(email));
            Stub.On(context).Method("GetParamStringOrEmpty").With("NewComplaintBanned", "Get the complaint banned setting").Will(Return.Value(complaintBanned ? "on" : ""));
            Stub.On(context).Method("GetParamStringOrEmpty").With("NewSignInBanned", "Get the signin banned setting").Will(Return.Value(signinBanned ? "on" : ""));
            Stub.On(context).Method("UrlEscape").WithAnyArguments().Will(Return.Value("Escaped EMail"));

            // Create the editor
            IUser mockedUser = DnaMockery.CurrentMockery.NewMock<IUser>();
            Stub.On(mockedUser).GetProperty("UserID").Will(Return.Value(1090558353));
            Stub.On(mockedUser).GetProperty("UserName").Will(Return.Value("username"));
            Stub.On(context).GetProperty("ViewingUser").Will(Return.Value(mockedUser));

            // Now create banned email object and process the request
            BannedEmailsPageBuilder testBannedEmails = new BannedEmailsPageBuilder(context);
            testBannedEmails.ProcessRequest();

            // Get the resultant XML from the object
            System.Xml.XmlNode testXML = testBannedEmails.RootElement;

            // Check the search params
            Assert.AreEqual("0", testXML.SelectSingleNode("//BANNEDEMAILS/SKIP").InnerText, "We should have a default value of 0 for the skip value");
            Assert.AreEqual("20", testXML.SelectSingleNode("//BANNEDEMAILS/SHOW").InnerText, "We should have a default value of 20 for the show value");
            Assert.AreEqual("", testXML.SelectSingleNode("//BANNEDEMAILS/SEARCHLETTER").InnerText, "We should have a default value of empty for the search letter value");
            Assert.AreEqual("0", testXML.SelectSingleNode("//BANNEDEMAILS/SEARCHTYPE").InnerText, "The search type value should be 0!");

            // Now check to make sure that the email was actually added
            Assert.IsNotNull(testXML.SelectSingleNode("//BANNEDEMAILS/BANNEDEMAILLIST/BANNEDEMAIL[EMAIL = '" + email + "']"), "Failed to find the email we just added");
        }
Пример #2
0
        public void TestGetBannedEmailsWithSeachByLetter()
        {
            // Create the context for the object
            IInputContext context = DnaMockery.CreateDatabaseInputContext();
            DnaMockery.SetDefaultDiagnostics(context);

            // Mock up the request params for the test
            Stub.On(context).Method("DoesParamExist").With("show", "Do we have the number of items to show?").Will(Return.Value(false));
            Stub.On(context).Method("DoesParamExist").With("skip", "Do we have the number of items to skip?").Will(Return.Value(false));
            Stub.On(context).Method("DoesParamExist").With("ViewAll", "Are we viewing all items?").Will(Return.Value(false));
            Stub.On(context).Method("DoesParamExist").With("ViewByLetter", "Are we wanting to search by letter?").Will(Return.Value(true));
            Stub.On(context).Method("GetParamStringOrEmpty").With("ViewByLetter", "Get the search letter").Will(Return.Value("g"));
            Stub.On(context).Method("UrlEscape").WithAnyArguments().Will(Return.Value("Escaped EMail"));

            // Mock the action params
            Stub.On(context).Method("DoesParamExist").With("togglecomplaintban", "Are we toggling the complaint ban for an email").Will(Return.Value(false));
            Stub.On(context).Method("DoesParamExist").With("togglesigninban", "Are we toggling the signin ban for an email").Will(Return.Value(false));
            Stub.On(context).Method("DoesParamExist").With("remove", "Are we tring to remove an email").Will(Return.Value(false));
            Stub.On(context).Method("DoesParamExist").With("AddEmail", "Are we tring to remove an email").Will(Return.Value(false));

            // Now create banned email object and process the request
            BannedEmailsPageBuilder testBannedEmails = new BannedEmailsPageBuilder(context);
            testBannedEmails.ProcessRequest();

            // Get the resultant XML from the object
            System.Xml.XmlNode testXML = testBannedEmails.RootElement;

            Assert.AreEqual("0", testXML.SelectSingleNode("//BANNEDEMAILS/SKIP").InnerText, "We should have a default value of 0 for the skip value");
            Assert.AreEqual("20", testXML.SelectSingleNode("//BANNEDEMAILS/SHOW").InnerText, "We should have a default value of 20 for the show value");
            Assert.AreEqual("g", testXML.SelectSingleNode("//BANNEDEMAILS/SEARCHLETTER").InnerText, "We should have the letter 'g' as the value");
            Assert.AreEqual("1", testXML.SelectSingleNode("//BANNEDEMAILS/SEARCHTYPE").InnerText, "The search type value should be 1!");
            Assert.AreEqual("1", testXML.SelectSingleNode("//BANNEDEMAILS/TOTALEMAILS").InnerText, "We should have only one in the totals field");
        }