예제 #1
0
        public void sendNotificationTest()
        {
            // string s = null; //per te bere fail mocknews ne rastet kur nuk ka mesazh
            DataSet   ds = new DataSet();
            DataTable dt = new DataTable("MyTable");

            dt.Columns.Add(new DataColumn("Emer", typeof(string)));
            dt.Columns.Add(new DataColumn("Email", typeof(string)));
            dt.Columns.Add(new DataColumn("TipiAbonimi", typeof(string)));
            DataRow dr = dt.NewRow();

            dr["Emer"]        = "user";
            dr["Email"]       = "email"; //to fail remove @...
            dr["TipiAbonimi"] = "0";
            dt.Rows.Add(dr);
            ds.Tables.Add(dt);
            var mockdm   = new Mock <IDataManager>();
            var mockem   = new Mock <IEmailer>();
            var mocknews = new Mock <INewsRetrievercs>();

            mockdm.Setup(x => x.getEntity()).Returns(ds);
            mocknews.Setup(x => x.Kontrollo(It.IsAny <string>())).Returns("test");
            //mocknews.Setup(x => x.Kontrollo(It.IsAny<string>())).Returns(s); // to fail

            UserRegister userRegister = new UserRegister();
            var          rez          = userRegister.sendNotification(mocknews.Object, mockdm.Object);

            Assert.AreEqual(true, rez);
        }