public void Init() { this.fakeBus = A.Fake <IBusClient>(); var path1 = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName; AppDomain.CurrentDomain.SetData("DataDirectory", Path.Combine(path1, "App_Data")); // create test data this.orders = JsonLoad.Orders(); this.restaurants = JsonLoad.Restaurants(); this.users = JsonLoad.User(); order = orders.FirstOrDefault(); this.confirmOrder = JsonLoad.ConfirmOrder(); // setup DbSet var set = A.Fake <DbSet <OrderService.Data.Model.Order> >(o => o.Implements(typeof(IQueryable <Order>)) .Implements(typeof(IDbAsyncEnumerable <Order>))).SetupData(this.orders); var setUser = A.Fake <DbSet <OrderService.Data.Model.User> >(o => o.Implements(typeof(IQueryable <User>)) .Implements(typeof(IDbAsyncEnumerable <User>))).SetupData(this.users); var setRestaurant = A.Fake <DbSet <OrderService.Data.Model.Restaurant> >(o => o.Implements(typeof(IQueryable <Restaurant>)) .Implements(typeof(IDbAsyncEnumerable <Restaurant>))).SetupData(this.restaurants); // arrange this.dataContext = A.Fake <Data.OrderDataContext>(); A.CallTo(() => dataContext.Orders.Add(A <Order> .Ignored)).Returns(order); A.CallTo(() => dataContext.Orders).Returns(set); A.CallTo(() => dataContext.Users).Returns(setUser); A.CallTo(() => dataContext.Restaurants).Returns(setRestaurant); }
public void Init() { this.busFake = A.Fake <IBusClient>(); var path1 = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName; AppDomain.CurrentDomain.SetData("DataDirectory", Path.Combine(path1, "App_Data")); // create test data this.user = JsonLoad.User(); var set = A.Fake <DbSet <User> >(o => o.Implements(typeof(IQueryable <User>)).Implements(typeof(IDbAsyncEnumerable <User>))).SetupData(user); // setup DbSet // arrange this.dataContext = A.Fake <Data.OrderDataContext>(); A.CallTo(() => dataContext.Users).Returns(set); }