public async Task Should_not_return_dlc_objects_when_game_null()
        {
            var service = new DLCService(null, null, null, null, null, null);
            var result  = await service.GetAsync(null);

            result.Count.Should().Be(0);
        }
        public async Task Should_return_dlc_object_from_cache_when_exe_path_in_subfolder()
        {
            var dlcs = new List <IDLC>()
            {
                new DLC()
                {
                    Name = "test",
                    Path = "test"
                }
            };
            var cache = new Cache();

            cache.Set(new CacheAddParameters <List <IDLC> >()
            {
                Region = "DLC", Key = "Should_return_dlc_object_from_cache_when_exe_path_in_subfolder", Value = dlcs
            });

            var service = new DLCService(null, cache, null, null, null, null);
            var result  = await service.GetAsync(new Game()
            {
                ExecutableLocation = AppDomain.CurrentDomain.BaseDirectory + "\\subfolder\\test.exe",
                Type = "Should_return_dlc_object_from_cache_when_exe_path_in_subfolder"
            });

            result.Count.Should().Be(1);
            result.Should().BeEquivalentTo(dlcs);
        }
        public async Task Should_parse_dlc_object()
        {
            var mapper = new Mock <IMapper>();

            mapper.Setup(s => s.Map <IDLC>(It.IsAny <IDLCObject>())).Returns((IDLCObject o) =>
            {
                return(new DLC()
                {
                    Path = o.Path
                });
            });
            var reader    = new Mock <IReader>();
            var fileInfos = new List <IFileInfo>()
            {
                new FileInfo()
                {
                    Content = new List <string>()
                    {
                        "1"
                    },
                    FileName = "fake1.txt",
                    IsBinary = false
                },
                new FileInfo()
                {
                    Content = new List <string>()
                    {
                        "2"
                    },
                    FileName = "fake2.txt",
                    IsBinary = false
                }
            };

            reader.Setup(s => s.Read(It.IsAny <string>(), It.IsAny <IEnumerable <string> >())).Returns(fileInfos);
            var parser = new Mock <IDLCParser>();

            parser.Setup(s => s.Parse(It.IsAny <string>(), It.IsAny <IEnumerable <string> >())).Returns((string path, IEnumerable <string> values) =>
            {
                return(new DLCObject()
                {
                    Path = path,
                    Name = values.First()
                });
            });
            var service = new DLCService(null, new Cache(), reader.Object, parser.Object, null, mapper.Object);
            var result  = await service.GetAsync(new Game()
            {
                ExecutableLocation = AppDomain.CurrentDomain.BaseDirectory + "\\test.exe",
                Type = "Should_parse_dlc_object"
            });

            result.Count.Should().Be(2);
        }
        public async Task Should_not_sync_dlc_when_no_dlc()
        {
            var service = new DLCService(null, null, null, null, null, null);
            var result  = await service.SyncStateAsync(new Game()
            {
                ExecutableLocation = string.Empty,
                Type = "Should_not_sync_dlc_when_no_dlc"
            }, new List <IDLC>());

            result.Should().BeFalse();
        }
        public async Task Should_not_export_dlc_when_no_dlc()
        {
            var service = new DLCService(null, null, null, null, null, null);
            var result  = await service.ExportAsync(new Game()
            {
                ExecutableLocation = string.Empty,
                Type = "Should_not_return_dlc_objects_when_game_path_not_set"
            }, new List <IDLC>());

            result.Should().BeFalse();
        }
        public async Task Should_not_return_dlc_objects_when_game_path_not_set()
        {
            var service = new DLCService(null, new Cache(), null, null, null, null);
            var result  = await service.GetAsync(new Game()
            {
                ExecutableLocation = string.Empty,
                Type = "Should_not_return_dlc_objects_when_game_path_not_set"
            });

            result.Count.Should().Be(0);
        }
        public async Task Should_not_sync_dlc_when_no_game()
        {
            var service = new DLCService(null, null, null, null, null, null);
            var result  = await service.SyncStateAsync(null, new List <IDLC>()
            {
                new DLC()
                {
                    Name = "test",
                    Path = "dlc/dlc01.dlc"
                }
            });

            result.Should().BeFalse();
        }
        public async Task Should_export_dlc()
        {
            var dlcExport = new Mock <IDLCExporter>();

            dlcExport.Setup(p => p.ExportDLCAsync(It.IsAny <DLCParameters>())).ReturnsAsync((DLCParameters p) => { return(p.DLC.Any()); });
            var service = new DLCService(dlcExport.Object, null, null, null, null, null);
            var result  = await service.ExportAsync(new Game()
            {
                ExecutableLocation = string.Empty,
                Type = "Should_export_dlc"
            }, new List <IDLC>()
            {
                new DLC()
                {
                    Name      = "test",
                    Path      = "dlc/dlc01.dlc",
                    IsEnabled = false
                }
            });

            result.Should().BeTrue();
        }
        public async Task Should_sync_dlc()
        {
            var dlc = new DLC()
            {
                Name      = "test",
                Path      = "dlc/dlc01.dlc",
                IsEnabled = true
            };
            var dlc2 = new DLC()
            {
                Name      = "test",
                Path      = "dlc/dlc02.dlc",
                IsEnabled = true
            };
            var dlcExport = new Mock <IDLCExporter>();

            dlcExport.Setup(p => p.GetDisabledDLCAsync(It.IsAny <DLCParameters>())).ReturnsAsync(() => new List <IDLCObject>()
            {
                new DLCObject()
                {
                    Path = "dlc/dlc01.dlc"
                }
            });
            var service = new DLCService(dlcExport.Object, null, null, null, null, null);
            var result  = await service.SyncStateAsync(new Game()
            {
                ExecutableLocation = string.Empty,
                Type = "Should_sync_dlc"
            }, new List <IDLC>()
            {
                dlc, dlc2
            });

            result.Should().BeTrue();
            dlc.IsEnabled.Should().BeFalse();
            dlc2.IsEnabled.Should().BeTrue();
        }