Esempio n. 1
0
        public void TestStoreAtDefaultLocation()
        {
            FileAssert.DoesNotExist(_testLocation);
            FileStream openStream = File.Create(_testLocation);

            openStream.Close();
            StorageSettings.StorageDefaultLocation = _testLocation;
            Environment.CurrentDirectory           = TestContext.CurrentContext.TestDirectory;
            IDictionary <CharacterClass, IEnumerable <IBuild> > builds = new Dictionary <CharacterClass, IEnumerable <IBuild> >();

            builds[CharacterClass.Barbarian] = new List <IBuild>()
            {
                BuildBuilder.BuildDefaultBuild()
            };

            _manager = new StorageManager();
            _manager.StoreAtDefaultLocation(builds);

            FileAssert.Exists(_testLocation);
            string[] lines = File.ReadAllLines(_testLocation);
            Assert.IsTrue(lines.Length > 0);
            Assert.IsFalse(string.IsNullOrEmpty(lines[0]));
            IBuildSerializer serializer = new BuildSerializer();
            IDictionary <CharacterClass, IEnumerable <IBuild> > deserializedBuilds = serializer.Deserialize(_testLocation);

            Assert.AreEqual(1, deserializedBuilds[CharacterClass.Barbarian].Count());
            Assert.AreEqual(BuildBuilder.BuildDefaultBuild(), deserializedBuilds[CharacterClass.Barbarian].First());
        }
Esempio n. 2
0
        public override void Initialize()
        {
            base.Initialize();

            var progress = new Progress <BuilderProgress>();

            progress.ProgressChanged += ProgressChanged;

            _context                   = new AdminBuildContext(CurrentWindow.AdminSettings, progress);
            _context.Logger            = new MHLab.Patch.Utilities.Logging.Logger(CurrentWindow.AdminSettings.GetLogsFilePath());
            _context.Serializer        = new NewtonsoftSerializer();
            _context.LocalizedMessages = CurrentWindow.Localization;
            _context.Initialize();

            _builder = new BuildBuilder(_context);
        }
        public override void Initialize()
        {
            base.Initialize();

            var progress = new Progress <BuilderProgress>();

            progress.ProgressChanged += ProgressChanged;

            _context                   = new AdminBuildContext(CurrentWindow.AdminSettings, progress);
            _context.Logger            = new SimpleLogger(_context.FileSystem, CurrentWindow.AdminSettings.GetLogsFilePath(), CurrentWindow.AdminSettings.DebugMode);
            _context.Serializer        = new JsonSerializer();
            _context.LocalizedMessages = CurrentWindow.Localization;
            _context.Initialize();

            _builder = new BuildBuilder(_context);
        }