public void PushItemChange() { var item = new Item("/test/test.txt") { ContentMetadata = new FileContentMetadata("text/plain", Encoding.UTF8) }; var itemChange = new ItemChange(ItemChangeType.Add, item) { NewContent = new ItemContent(ItemContentType.RawText, "Testing") }; var itemChanges = new ItemChange[] { itemChange }; IEnumerable<ItemChange> itemChangesAdded = null; bool saveChangesCalled = false; var fakeContext = new Fakes.StubIDestinationContext() { AddItemChangesIEnumerableOfItemChange = (changes) => { itemChangesAdded = changes; }, SaveChangesAsyncCancellationToken = (token) => { saveChangesCalled = true; return Task.FromResult(0); } }; var repo = new DestinationRepository(fakeContext); repo.PushItemChangesAsync(itemChanges, "/").Wait(); Assert.IsNotNull(itemChangesAdded); Assert.AreEqual("test/test.txt", itemChangesAdded.Single().Item.Path); Assert.AreSame(itemChange.Item.ContentMetadata, itemChangesAdded.Single().Item.ContentMetadata); Assert.AreSame(itemChange.NewContent, itemChangesAdded.Single().NewContent); Assert.IsTrue(saveChangesCalled); }
private async Task GetTrips() { bool canRun = true; this.Loading = true; RaisePropertyChanged("Loading"); await Task.Run(async() => { List <Trip> trips = await TripRepository.GetTrips(); trips_all = new List <Trip.All>(); if (trips == null || trips.Count == 0) { this.Error = "Geen trips gevonden"; canRun = false; this.Loading = false; RaiseAll(); return; } var count = trips.Count; if ((trips.Count >= 10) && canRun == true) { count = 10; } for (int i = 0; i < count; i++) { Task <User.All> user = Task.FromResult <User.All>(await UsersRepository.GetUserById(trips[i].Users_ID)); Task <Bob.All> bob = Task.FromResult <Bob.All>(await BobsRepository.GetBobById(trips[i].Bobs_ID)); Task <Users_Destinations> destination = Task.FromResult <Users_Destinations>(await DestinationRepository.GetDestinationById((trips[i].Destinations_ID))); Task <Party> party = Task.FromResult <Party>(await PartyRepository.GetPartyById(trips[i].Party_ID)); Trip.All newTrip = new Trip.All(); newTrip.Trip = trips[i]; newTrip.User = user.Result; newTrip.Bob = bob.Result; newTrip.Party = party.Result; newTrip.Destination = destination.Result; trips_all.Add(newTrip); } this.Trips = trips_all; canRun = false; this.Loading = false; RaiseAll(); }); }
public DestinationController(DestinationRepository repository) { _repository = repository; }