public void Get_byId(string transactionId) { // Get Stubs Basket stub_data = Basket_Stub.getBokingStubData().Where(x => x.TransactionNumber == transactionId).FirstOrDefault(); // Mock <IRepository> repository = new Mock <IRepository>(); repository.Setup(x => x.getBasketById(transactionId)).Returns(stub_data); // // Controller Instance BasketController controller = new BasketController(repository.Object); // // Get Result Basket result = controller.Get(transactionId); // End //Assert Assert.Equal(stub_data, result); // }
public void Get_test() { // Get Stubs var stub_data = Basket_Stub.getBokingStubData(); // // Mock Mock <IRepository> repository = new Mock <IRepository>(); repository.Setup(x => x.getAllBaskets()).Returns(() => stub_data); // // Controller Instance BasketController controller = new BasketController(repository.Object); // // Get Result var result = controller.Get(); // End // Assert - should be 20 Assert.Equal(stub_data.Count(), result.Count()); }