Unit testing

Jul 5, 2016 at 1:29 PM
Hello,

I want to unit test the project I am working on. I am using FakeItEasy to fake the classes. However, I can not raise the event because "Cannot access internal constructor RecordChangedEventArgs".

Here is my code:

namespace SqlNotify.Test
{

    [TestFixture]
    public class UnitTest1
    {
        [Test]
        public void TestMethod1()
        {

            var sql = A.Fake<SqlTableDependency<Transaction>>(x => x.WithArgumentsForConstructor(
                () => new SqlTableDependency<Transaction>("connstring")));

            var db = A.Fake<SqlNotifyOp2Entities>();

            var handler = new NotificationHandler(db, sql);


            sql.OnChanged += Raise.With(sender: sql, e: new RecordChangedEventArgs<Transaction>());

            A.CallTo(() => sql.Start(120, 180)).MustHaveHappened();
        }
    }
}
can you give any alternative?

Regards,
Tanvir.
Coordinator
Jul 6, 2016 at 10:30 AM
Hi.

Can this be helpful ?

tableDependency.OnChanged += (sender, e) => { };