public void GetTop_ShouldReturnInstanceOfIQueryable() { // Arrange var mockedRepository = new Mock <IRepository <RemunerationBill> >(); var billService = new RemunerationBillService(mockedRepository.Object); RemunerationBill mockedBill = new FakeRemunerationBill(); RemunerationBill mockedBill2 = new FakeRemunerationBill(); RemunerationBill mockedBill3 = new FakeRemunerationBill(); mockedBill.Id = 2; mockedBill2.Id = 3; mockedBill3.Id = 4; // Act billService.Create(mockedBill); billService.Create(mockedBill2); billService.Create(mockedBill3); var query = billService.GetTop(3); // Assert Assert.IsInstanceOf <IQueryable <RemunerationBill> >(query); }
public void GetTop_ShouldInvokeOnlyOnce() { // Arrange var mockedRepository = new Mock <IRepository <RemunerationBill> >(); var billService = new RemunerationBillService(mockedRepository.Object); RemunerationBill mockedBill = new FakeRemunerationBill(); RemunerationBill mockedBill2 = new FakeRemunerationBill(); RemunerationBill mockedBill3 = new FakeRemunerationBill(); mockedBill.Id = 2; mockedBill2.Id = 3; mockedBill3.Id = 4; // Act billService.Create(mockedBill); billService.Create(mockedBill2); billService.Create(mockedBill3); billService.GetTop(3); // Assert mockedRepository.Verify(r => r.All, Times.Once); }