Beispiel #1
0
        public static void InitDb(TestContext context)
        {
            var mockContact = new Mock <DbSet <ContactRequest> >();

            var contacts = new List <ContactRequest>
            {
                new ContactRequest {
                    Comment = "test commenr 1",
                    Email   = "*****@*****.**",
                    Name    = "an1yone"
                }
            }.AsQueryable();

            mockContact.As <IQueryable <ContactRequest> >().Setup(m => m.Provider).Returns(contacts.Provider);
            mockContact.As <IQueryable <ContactRequest> >().Setup(m => m.Expression).Returns(contacts.Expression);
            mockContact.As <IQueryable <ContactRequest> >().Setup(m => m.ElementType).Returns(contacts.ElementType);
            mockContact.As <IQueryable <ContactRequest> >().Setup(m => m.GetEnumerator()).Returns(contacts.GetEnumerator());


            var mockContext = new Mock <AppDemoDbContext>();

            mockContext.Setup(c => c.ContactRequests).Returns(mockContact.Object);

            MockContext = mockContext;
            MockDb      = mockContext.Object;
        }
Beispiel #2
0
 public ContactRequestRepository(AppDemoDbContext db)
 {
     this.db = db;
 }