public void IfCacheIsEmptyDownloadsDataAndReturnsIt()
        {
            Cache.Setup(c => c.HasCached(It.IsAny <string>())).Returns(false);
            HttpClient.Setup(http => http.Get(USER_NAME)).ReturnsAsync(new KarmaResponse
            {
                Data         = Model,
                IsSuccessful = true
            });
            var client   = new ReactiveHabraClient(Cache.Object, HttpClient.Object, Scheduler);
            var expected = Scheduler.CreateHotObservable(OnNext(2, Model), OnCompleted <KarmaModel>(2));

            var results = Scheduler.Start(() => client.GetKarmaForUser(USER_NAME), 0, 1, 10);

            ReactiveAssert.AreElementsEqual(expected.Messages, results.Messages);
            Cache.Verify(cache => cache.Put(Model), Times.Once);
        }
        public void Test2()
        {
            Cache.Setup(cache => cache.HasCached(USER_NAME)).Returns(true);
            Cache.Setup(cache => cache.GetCachedItem(USER_NAME)).Returns(Model);

            HttpClient.Setup(http => http.Get(USER_NAME)).ReturnsAsync(new KarmaResponse
            {
                Data         = Model,
                IsSuccessful = true
            });
            var client   = new ReactiveHabraClient(Cache.Object, HttpClient.Object, Scheduler);
            var expected = Scheduler.CreateHotObservable(OnNext(201, Model), OnCompleted <KarmaModel>(201));


            var results = Scheduler.Start(() => client.GetKarmaForUser(USER_NAME), 0, 200, 500);

            ReactiveAssert.AreElementsEqual(expected.Messages, results.Messages);
            Cache.Verify(cache => cache.Put(Model), Times.AtMostOnce);
        }
        public void Test4()
        {
            Cache.Setup(c => c.HasCached(It.IsAny <string>())).Returns(false);
            var exception = new Exception("something went wrong");

            HttpClient.Setup(http => http.Get(USER_NAME)).ReturnsAsync(new KarmaResponse
            {
                Data         = null,
                Exception    = exception,
                IsSuccessful = false
            });
            var client   = new ReactiveHabraClient(Cache.Object, HttpClient.Object, Scheduler);
            var expected = Scheduler.CreateHotObservable(OnError <KarmaModel>(201, exception));


            var results = Scheduler.Start(() => client.GetKarmaForUser(USER_NAME), 0, 200, 500);

            ReactiveAssert.AreElementsEqual(expected.Messages, results.Messages);
        }