Example #1
0
        public async Task CachingEmptyHashtagListDoesNothing()
        {
            // Arrange
            using (var con = OpenConnection())
                using (var cache = new SqliteCache(con))
                {
                    // Act ReSharper disable once AccessToDisposedClosure
                    var ex = await ExceptionAssert.CatchAsync <Exception>(() => cache.AddHashtags(new List <string>()));

                    // Assert
                    Assert.IsNull(ex);
                }
        }
Example #2
0
        public async Task MissingArgumentThrowsException()
        {
            // Arrange
            var client = new Mock <IHttpClient>();
            var proxy  = new MediaProxyServer(client.Object);

            var request  = new Mock <IHttpRequest>();
            var response = new Mock <IHttpResponse>();

            // Act
            var respEx = await ExceptionAssert.CatchAsync <ArgumentNullException>(() => proxy.HandleRequest(request.Object, null));

            var reqEx = await ExceptionAssert.CatchAsync <ArgumentNullException>(() => proxy.HandleRequest(null, response.Object));

            // Assert
            Assert.IsNotNull(respEx);
            Assert.IsNotNull(reqEx);
            Assert.AreEqual("response", respEx.ParamName);
            Assert.AreEqual("request", reqEx.ParamName);
        }
Example #3
0
        public async Task MissingUpdateExeDoesNotCrashUpdateCheck()
        {
            // Arrange
            var context = new Mock <IContextEntry>();

            context.Setup(c => c.Twitter.LogCurrentRateLimits()).Returns(Task.CompletedTask);
            var contextList = new Mock <ITwitterContextList>();

            contextList.SetupGet(c => c.Contexts).Returns(new[] { context.Object });
            var notifier      = new Mock <INotifier>();
            var columnList    = new Mock <IColumnDefinitionList>();
            var columnFactory = new Mock <IColumnFactory>();
            var generalCfg    = new GeneralConfig {
                CheckForUpdates = true
            };
            var config = new Mock <IConfig>();

            config.SetupGet(c => c.General).Returns(generalCfg);
            var vm = new MainViewModel(contextList.Object, notifier.Object, columnList.Object, columnFactory.Object)
            {
                Configuration = config.Object,
                Dispatcher    = new SyncDispatcher()
            };

            var updaterFactory = new Mock <IAppUpdaterFactory>();

            updaterFactory.Setup(f => f.Construct(It.IsAny <bool>())).Throws(new Exception("Update.exe not found"));

            vm.UpdateFactory = updaterFactory.Object;

            // Act
            var ex = await ExceptionAssert.CatchAsync <Exception>(() => vm.OnLoad(null));

            // Assert
            Assert.IsNull(ex);

            updaterFactory.Verify(f => f.Construct(It.IsAny <bool>()), Times.Once());
        }