Ejemplo n.º 1
0
        public async Task UnobserveAsync_VideoIdProperty_DoesNotRaisePropertyChanged()
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            var    observeId   = 1;
            string?changedName = null;
            await app.Api.VideoId.ObserveAsync(observeId);

            try
            {
                app.Api.PropertyChanged += (s, e) =>
                {
                    changedName = e.Name;
                };
                await app.Api.UnobservePropertyAsync(observeId);

                await Task.Delay(100);

                await app.LoadVideoAsync();

                Assert.Null(changedName);
            }
            finally
            {
                await app.LogAndQuitAsync(_output);
            }
        }
Ejemplo n.º 2
0
        public async Task SendMessage_ConcurrentRequests_ReceivesAllResponses()
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            app.Controller.LogEnabled = true;
            app.Controller.DefaultOptions.ResponseTimeout = 5000;
            const int Concurrent = 20;
            var       requests   = new int[Concurrent];

            for (var i = 0; i < Concurrent; i++)
            {
                requests[i] = i;
            }

            try
            {
                var tasksClient = requests.ForEachOrderedAsync(x => app.Controller.SendMessageAsync(null, "client_name"));
                await tasksClient.ConfigureAwait(false);
            }
            finally
            {
                _output.WriteLine(app.Controller?.Log?.ToString());
            }

            // Success: No freeze and no crash.
            await app.LogAndQuitAsync(_output);
        }
        public static async Task <TestIntegrationSetup> CreateAsync()
        {
            var result = new TestIntegrationSetup();
            await result.InitConnection();

            return(result);
        }
Ejemplo n.º 4
0
        public async Task SendMessage_LoadFile_ReturnsSuccess()
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            await app.Controller.SendMessageAsync(null, "loadfile", app.SampleClip);

            await app.LogAndQuitAsync(_output);
        }
        public async Task GetVersionAsync_NoArg_ReturnsVersion()
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            var response = await app.Api.GetVersionAsync();

            Assert.True(response?.Data > 0);
            await app.LogAndQuitAsync(_output);
        }
        public async Task GetClientNameAsync_NoArg_ReturnsClientName()
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            var response = await app.Api.GetClientNameAsync();

            Assert.NotEmpty(response?.Data);
            await app.LogAndQuitAsync(_output);
        }
        public async Task InvalidCommand_DoNotWait_DoesNotReceiveError()
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            await app.Controller.SendMessageAsync(options : new ApiOptions()
            {
                WaitForResponse = false
            }, "invalidcommand");

            await app.LogAndQuitAsync(_output);
        }
        public async Task LoadFile_WithPrefix_ReturnsSuccess()
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            await app.Api.LoadFileAsync(app.SampleClip, options : new ApiOptions()
            {
                NoOsd = true
            });

            await app.LogAndQuitAsync(_output);
        }
Ejemplo n.º 9
0
        public async Task ConnectAsync_LoadFile_ReceivesEvent()
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            var received = new List <string>();

            app.Controller.EventReceived += (s, e) => received.Add(e.EventName);
            await app.Controller.SendMessageAsync(null, "loadfile", app.SampleClip);

            await Task.Delay(10);

            Assert.NotEmpty(received);
            await app.LogAndQuitAsync(_output);
        }
        public async Task IdleActive_Idle_ReturnsTrue()
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            try
            {
                var result = await app.Api.IdleActive.GetAsync();

                Assert.True(result);
            }
            finally
            {
                await app.LogAndQuitAsync(_output);
            }
        }
Ejemplo n.º 11
0
        public async Task MultiplyAsync_HrSeek_ThrowsException()
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            try
            {
                Task Act() => app.Api.HrSeek.MultiplyAsync(1);

                await Assert.ThrowsAsync <NotImplementedException>(Act);
            }
            finally
            {
                await app.LogAndQuitAsync(_output);
            }
        }
        public async Task RemoveAsync_KeyEmpty_ThrowsException(string key)
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            try
            {
                Task Act() => app.Api.YouTubeDlRawOptions.RemoveAsync(key);

                await Assert.ThrowsAnyAsync <ArgumentException>(Act);
            }
            finally
            {
                await app.LogAndQuitAsync(_output);
            }
        }
        public async Task GetAsync_YouTubeDlTryFirst_ReturnsNull()
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            try
            {
                var result = await app.Api.YouTubeDlTryFirst.GetAsync();

                Assert.Null(result);
            }
            finally
            {
                await app.LogAndQuitAsync(_output);
            }
        }
Ejemplo n.º 14
0
        public async Task GetAsync_HrSeek_ReturnsNull()
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            try
            {
                var result = await app.Api.HrSeek.GetAsync();

                Assert.Equal(HrSeekOption.Default, result);
            }
            finally
            {
                await app.LogAndQuitAsync(_output);
            }
        }
Ejemplo n.º 15
0
        public async Task GetAsync_Volume_ReturnsValue()
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            try
            {
                var result = await app.Api.Volume.GetAsync();

                Assert.True(result > 0);
            }
            finally
            {
                await app.LogAndQuitAsync(_output);
            }
        }
        public async Task RemoveAsync_Empty_ThrowsException(string prop)
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            try
            {
                Task Act() => app.Api.ResetOnNextFile.RemoveAsync(prop);

                await Assert.ThrowsAnyAsync <ArgumentException>(Act);
            }
            finally
            {
                await app.LogAndQuitAsync(_output);
            }
        }
        public async Task GetAsync_ResetOnNextFile_ReturnsEmptyList()
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            try
            {
                var result = await app.Api.ResetOnNextFile.GetAsync();

                Assert.NotNull(result);
                Assert.Empty(result);
            }
            finally
            {
                await app.LogAndQuitAsync(_output);
            }
        }
        public async Task GetAsync_YouTubeDlRawOptions_ReturnsEmptyList()
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            try
            {
                var result = await app.Api.YouTubeDlRawOptions.GetAsync();

                Assert.NotNull(result);
                Assert.Empty(result);
            }
            finally
            {
                await app.LogAndQuitAsync(_output);
            }
        }
        public async Task SetAsync_Empty_ReturnsValue(string value)
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            try
            {
                await app.Api.YouTubeDlTryFirst.SetAsync(value);

                var result = await app.Api.YouTubeDlTryFirst.GetAsync();

                Assert.Null(result);
            }
            finally
            {
                await app.LogAndQuitAsync(_output);
            }
        }
        public async Task SetNoAsync_VideoId_VideoIdSet()
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            try
            {
                await app.Api.VideoId.SetNoAsync();

                var result = await app.Api.VideoId.GetNoAsync();

                Assert.True(result);
            }
            finally
            {
                await app.LogAndQuitAsync(_output);
            }
        }
        public async Task GetNoAsync_VideoId_ReturnsFalse()
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            try
            {
                await app.Api.VideoId.SetAsync(0);

                var response = await app.Api.VideoId.GetNoAsync();

                Assert.False(response);
            }
            finally
            {
                await app.LogAndQuitAsync(_output);
            }
        }
        public async Task GetAsync_ValueNo_ReturnsNull()
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            try
            {
                await app.Api.VideoId.SetNoAsync();

                var result = await app.Api.VideoId.GetAsync();

                Assert.Null(result);
            }
            finally
            {
                await app.LogAndQuitAsync(_output);
            }
        }
        public async Task Metadata_ValidFile_ReturnsDictionary()
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            try
            {
                await app.Api.LoadFileAsync(app.SampleClip);

                var result = await app.Api.Metadata.Metadata.GetAsync();

                Assert.NotEmpty(result);
            }
            finally
            {
                await app.LogAndQuitAsync(_output);
            }
        }
Ejemplo n.º 24
0
        public async Task SetAsync_HrSeek_HasNewValue(HrSeekOption value)
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            try
            {
                await app.Api.HrSeek.SetAsync(value);

                var result = await app.Api.HrSeek.GetAsync();

                Assert.Equal(value, result);
            }
            finally
            {
                await app.LogAndQuitAsync(_output);
            }
        }
        public async Task DemuxerCacheTime_ValidFile_ReturnsValue()
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            try
            {
                await app.Api.LoadFileAsync(app.SampleClip);

                var result = await app.Api.DemuxerCacheTime.GetAsync();

                Assert.NotNull(result);
            }
            finally
            {
                await app.LogAndQuitAsync(_output);
            }
        }
        public async Task SetAsync_Empty_ListEmpty(string prop)
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            try
            {
                await app.Api.ResetOnNextFile.SetAsync(prop);

                var result = await app.Api.ResetOnNextFile.GetAsync();

                Assert.Empty(result);
            }
            finally
            {
                await app.LogAndQuitAsync(_output);
            }
        }
Ejemplo n.º 27
0
        public async Task CycleAsync_HrSeekDown_HasLowerValue()
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            try
            {
                await app.Api.HrSeek.CycleAsync(CycleDirection.Down);

                var result = await app.Api.HrSeek.GetAsync();

                Assert.NotEqual(HrSeekOption.Default, result);
            }
            finally
            {
                await app.LogAndQuitAsync(_output);
            }
        }
        public async Task SetAsync_MultipleValues_HasMultipleValues()
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            try
            {
                await app.Api.ResetOnNextFile.SetAsync(propList);

                var result = await app.Api.ResetOnNextFile.GetAsync();

                Assert.Equal(propList, result);
            }
            finally
            {
                await app.LogAndQuitAsync(_output);
            }
        }
        public async Task SetAsync_SingleValue_HasSingleValue(string prop)
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            try
            {
                await app.Api.ResetOnNextFile.SetAsync(prop);

                var result = await app.Api.ResetOnNextFile.GetAsync();

                Assert.Single(result);
                Assert.Equal(prop, result.First());
            }
            finally
            {
                await app.LogAndQuitAsync(_output);
            }
        }
        public async Task AddAsync_SingleValue_ReturnsValue(string key, string value)
        {
            using var app = await TestIntegrationSetup.CreateAsync();

            try
            {
                await app.Api.YouTubeDlRawOptions.AddAsync(key, value);

                var result = await app.Api.YouTubeDlRawOptions.GetAsync();

                Assert.Single(result);
                Assert.Equal(new[] { new KeyValuePair <string, string>(key, value ?? "") }, result);
            }
            finally
            {
                await app.LogAndQuitAsync(_output);
            }
        }