Пример #1
0
 public CachingStateVm(CachingState cachingState)
 {
     _cachingState = cachingState;
     var progress = cachingState.Progress;
     _finalSize = progress.Select(x => x.Total).ToProperty(this, x => x.FinalSize);
     _cachedSize = progress.Select(x => x.Current).ToProperty(this, x => x.CachedSize);
     _isFullyCached = progress.Select(x => x.Current != 0UL && x.Current == x.Total).ToProperty(this, x => x.IsFullyCached, false);
     _isInitialized = this.WhenAny(x => x.FinalSize, ch => ch.Value > 0).ToProperty(this, x => x.IsInitialized, false);
 }
Пример #2
0
        //[Fact]
        public void Test_Caching_State_Initialization()
        {
            var downloaderMock = new Mock<IBackgroundDownloader>();
            downloaderMock.Setup(x => x.Load(It.IsAny<string>(), It.IsAny<IProgress<ProgressValue>>(), It.IsAny<CancellationToken>()))
                          .Returns(Task.FromResult(new Uri("http://google.com")));
            var storageMock = new Mock<IPodcastsStorage>();
            storageMock.Setup(x => x.MoveFromTransferTempStorage(It.IsAny<Uri>(), It.IsAny<IPodcastItem>()))
                       .Returns(Task.FromResult(new Uri("http://google.com")));
            var podcastMock = new Mock<IPodcastItem>();
            podcastMock.Setup(x => x.Title).Returns("title");
            podcastMock.Setup(x => x.PodcastUri).Returns(new Uri("http://google.com"));

            var state = new CachingState(podcastMock.Object, downloaderMock.Object, storageMock.Object);
            state.Init();

            //Assert.NotNull(state.Progress);
            //Assert.True(state.IsFullyCached);
            //Assert.Equal(0d, state.FinalSize);
        }
Пример #3
0
        public FileModel(PodcastId id, [CanBeNull]CacheInfo cacheInfo)
        {
            Id = id;
            State = new CachingState();
			UpdateCachingState(cacheInfo);
		}