Exemplo n.º 1
0
        public void GetTypeByNameTest()
        {
            var actual   = MockKernel.Get <DataService>().GetTypeByName("Book");
            var expected = typeof(Book);

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 2
0
        public void GetListOfTypesTest()
        {
            var actual   = MockKernel.Get <DataService>().GetListOfTypes();
            var expected = new  List <string> {
                "User",
                "Book"
            };

            Assert.AreEqual(actual, expected);
        }
Exemplo n.º 3
0
        public frmImportUtility()
        {
            // initialize Viewmodel
            viewModel = MockKernel.Get().GetImportViewModel() as ImportViewModel;

            InitializeComponent();
            ApplyCustomTheme();

            viewModel.PropertyChanged += ViewModel_PropertyChanged;
            this.objectListView.SetObjects(viewModel.Importableobjects);
        }
Exemplo n.º 4
0
        public void GetByIdAndTypeTest()
        {
            var expected = new User {
                Id = 123, Login = "******"
            };

            MockKernel.GetMock <IRepository <User> >().Setup(ur => ur.GetById(5)).Returns(expected);

            var actual = MockKernel.Get <DataService>().GetByIdAndType(5, "User");

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 5
0
        public frmImportUtility()
        {
            // initialize Viewmodel
            viewModel = MockKernel.Get().GetImportViewModel();

            InitializeComponent();
            ApplyCustomTheme();

            viewModel.PropertyChanged += ViewModel_PropertyChanged;
            this.objectListView.SetObjects(viewModel.Importableobjects);

            this.toolStripComboBox1.SelectedIndex = 0;
        }
Exemplo n.º 6
0
        public void GetDataByTypeTest()
        {
            var testBooks = new List <Book>
            {
                new Book {
                    Id = 123, Description = "Desr"
                }
            };

            MockKernel.GetMock <IRepository <Book> >().Setup(br => br.GetAll()).Returns(testBooks);
            var actual = MockKernel.Get <DataService>().GetDataByType("Book");

            Assert.AreEqual(testBooks, actual);
        }
Exemplo n.º 7
0
        async Task CreatePackage(string outpath)
        {
            if (MainController.Get().ActiveMod == null)
            {
                MessageBox.Show("No project loaded!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            MainController.Get().ProjectStatus = EProjectStatus.Busy;
            var packeddir  = Path.Combine(MainController.Get().ActiveMod.ProjectDirectory, @"packed\");
            var contentdir = Path.Combine(MainController.Get().ActiveMod.ProjectDirectory, @"packed\content\");

            if (!Directory.Exists(contentdir))
            {
                Directory.CreateDirectory(contentdir);
            }
            else
            {
                var di = new DirectoryInfo(contentdir);
                foreach (var file in di.GetFiles())
                {
                    file.Delete();
                }
                foreach (var dir in di.GetDirectories())
                {
                    dir.Delete(true);
                }
            }
            var   packtask = MockKernel.Get().GetMainViewModel().PackAndInstallMod();
            await packtask;
            var   installdir = Path.Combine(MainController.Get().ActiveMod.ProjectDirectory, @"Installer/");

            if (!Directory.Exists(installdir))
            {
                Directory.CreateDirectory(installdir);
            }
            var asm = WKPackage.CreateModAssembly(modversionTB.Text, modnameTB.Text, new Tuple <string, string, string, string, string, string>(authorTB.Text, donateTF.Text, webTF.Text, facebookTF.Text, twitterTF.Text, youtubeTF.Text), descriptionRTB.Text, largedescRTB.Text, licenseTB.Text, new Tuple <Color, bool, Color>(headercolor, useblackCB.Checked, iconbg), new List <XElement>());
            var pkg = new WKPackage(asm, iconpathTB.Text, Path.Combine(MainController.Get().ActiveMod.ProjectDirectory, @"packed"));

            pkg.Save(outpath);
            MainController.LogString("Installer created: " + outpath + "\n", Logtype.Success);
            if (!File.Exists(outpath))
            {
                MainController.Get().ProjectStatus = EProjectStatus.Errored;
                MainController.LogString("Couldn't create installer. Something went wrong.", Logtype.Error);
                return;
            }
            MainController.Get().ProjectStatus = EProjectStatus.Ready;
            Commonfunctions.ShowFileInExplorer(outpath);
        }
Exemplo n.º 8
0
        public void ShowStringsGUIModal()
        {
            var StringsGui = MockKernel.Get().StringsGui;

            if (StringsGui == null)
            {
                StringsGui = new frmStringsGui();
                StringsGui.ShowDialog();
            }
            else
            {
                StringsGui.ShowDialog();
            }
        }
Exemplo n.º 9
0
        public frmWcc()
        {
            viewModel = MockKernel.Get().GetModkitViewModel();
            viewModel.PropertyChanged += ViewModel_PropertyChanged;

            InitializeComponent();

            ApplyCustomTheme();

            objectListView.SetObjects(viewModel.Commands);
            propertyGrid.SelectedObject = viewModel.SelectedObject;

            this.Icon = new Icon(UIController.GetIconByKey(EAppIcons.Wcc), new Size(16, 16));
        }
Exemplo n.º 10
0
        public frmBulkEditor()
        {
            InitializeComponent();


            // initialize Viewmodel
            viewModel = MockKernel.Get().GetBulkEditorViewModel();

            ApplyCustomTheme();

            propertyGrid.SelectedObject = viewModel.Options;

            viewModel.PerformStep     += (sender, e) => this.PerformStep();
            viewModel.PropertyChanged += ViewModel_PropertyChanged;
        }
        public void GivenEnableCachingFalse_WhenConfigure_ThenContextCachingNotConfigured()
        {
            ICache expected = MockRepository.GenerateMock <ICache>();

            MockKernel.Expect(m => m.Resolve <ICache>()).Return(expected);
            Target.EnableCaching = false;

            using (EducationDataContext actual = new EducationDataContext())
            {
                Target.Configure(MockKernel, actual);

                Assert.IsNull(actual.Cache);
                Assert.AreEqual(CachingPolicy.NoCaching, actual.CachingPolicy);
            }
        }
Exemplo n.º 12
0
        public frmRadish()
        {
            // initialize Viewmodel
            viewModel = MockKernel.Get().GetRadishVM() as RadishViewModel;
            if (viewModel.IsCorrupt)
            {
                this.Close();
            }

            InitializeComponent();
            ApplyCustomTheme();

            // Set control objects
            WorkflowobjectListView.SetObjects(RadishController.Get().Configuration.Workflows);

            PropertyGrid.SelectedObject         = viewModel.CurrentWorkflow;
            PropertyGridSettings.SelectedObject = RadishController.GetConfig();
        }
Exemplo n.º 13
0
        public void RequestStringsGUI()
        {
            var StringsGui = MockKernel.Get().StringsGui;

            if (StringsGui == null)
            {
                StringsGui = new frmStringsGui();
            }

            if (StringsGui.AreHashesDifferent())
            {
                var result =
                    MessageBox.Show(
                        "There are no encoded CSV files in your mod, do you want to open Strings Encoder GUI?",
                        "", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (result == DialogResult.Yes)
                {
                    StringsGui.ShowDialog();
                }
            }
        }
Exemplo n.º 14
0
 void IWindowFactory.ShowOutput() => MockKernel.Get().ShowOutput();
Exemplo n.º 15
0
 void IWindowFactory.ShowConsole() => MockKernel.Get().ShowConsole();
Exemplo n.º 16
0
        public void DeleteDataByTypeAndId()
        {
            MockKernel.Get <DataService>().DeleteDataByTypeAndId("Book", 8);

            MockKernel.GetMock <IRepository <Book> >().Verify(br => br.Delete(8));
        }
Exemplo n.º 17
0
        private void btSave_Click(object sender, EventArgs e)
        {
            if (!File.Exists(textBoxGame.Text))
            {
                DialogResult = DialogResult.None;
                textBoxGame.Focus();
                MessageBox.Show("Invalid witcher3.exe path", "failed to save.");
                return;
            }

            if (!File.Exists(textBoxWcc.Text))
            {
                DialogResult = DialogResult.None;
                textBoxWcc.Focus();
                MessageBox.Show("Invalid wcc_lite.exe path", "failed to save.");
                return;
            }

            MainController.Get().ProjectStatus  = EProjectStatus.Busy;
            MainController.Get().StatusProgress = 0;

            // get configs
            var config   = MainController.Get().Configuration;
            var uiconfig = UIController.Get().Configuration;

            // Apply Theme
            bool applyTheme = uiconfig.ColorTheme != (EColorThemes)comboBoxTheme.SelectedItem;

            // save settings
            config.ExecutablePath = textBoxGame.Text;
            config.WccLite        = textBoxWcc.Text;

            // double check that r4depot exists
            if (string.IsNullOrEmpty(config.DepotPath))
            {
                DirectoryInfo wccDir     = new FileInfo(textBoxWcc.Text).Directory.Parent.Parent;
                string        wcc_r4data = Path.Combine(wccDir.FullName, "r4data");
                if (Directory.Exists(wcc_r4data))
                {
                    config.DepotPath = wcc_r4data;
                }
            }
            config.DepotPath  = textBoxDepot.Text;
            config.GameModDir = textBoxModDir.Text;
            config.GameDlcDir = textBoxDlcDir.Text;

            config.TextLanguage              = txTextLanguage.Text;
            config.VoiceLanguage             = txVoiceLanguage.Text;
            config.UncookExtension           = (EUncookExtension)comboBoxExtension.SelectedItem;
            config.IsWelcomeFormDisabled     = checkBoxDisableWelcomeForm.Checked;
            config.IsAutoInstallModsDisabled = !checkBoxAutoInstall.Checked;

            uiconfig.ColorTheme  = (EColorThemes)comboBoxTheme.SelectedItem;
            config.UpdateChannel = (EUpdateChannel)comboBoxUpdateChannel.SelectedItem;

            // save configs
            config.Save();
            uiconfig.Save();

            MainController.Get().UpdateWccHelper(config.WccLite);


            if (applyTheme)
            {
                MockKernel.Get().Window.GlobalApplyTheme();
                RequestApplyTheme?.Invoke();
            }

            /// debug console enabling
            try
            {
                IniParser ip = new IniParser(Path.Combine(MainController.Get().Configuration.GameRootDir, "bin\\config\\base\\general.ini"));
                if (!ip.HasSection("General") || ip.GetSetting("General", "DBGConsoleOn", true) != "true")
                {
                    if (MessageBox.Show(
                            "WolvenKit has detected that your game has the debug console disabled. It is a useful tool when testing mods. Would you like it to be enabled?",
                            "Debug console enabling", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        ip.AddSetting("General", "DBGConsoleOn", "true");
                        ip.Save();
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.ToString());
            }

            // patch wcc_lite
            try
            {
                using (var fs = new FileStream(textBoxWcc.Text, FileMode.Open))
                    using (var bw = new BinaryWriter(fs))
                    {
                        var shawcc = System.Security.Cryptography.SHA256.Create().ComputeHash(fs).Aggregate("", (c, n) => c += n.ToString("x2"));
                        switch (shawcc)
                        {
                        case wcc_sha256:
                        {
                            if (MessageBox.Show("wcc_lite is a great tool by CD Projekt red but" +
                                                "due to some internal problems they didn't really have time to properly develop it, and is very slow " +
                                                "because it is searching for a CD Projekt red mssql server.\n" +
                                                "WolvenKit can patch this with a method figured out by blobbins on the witcher 3 forums." +
                                                "Would you like to perform this patch?", "wcc_lite faster patch", MessageBoxButtons.YesNo, MessageBoxIcon.Question) ==
                                DialogResult.Yes)
                            {
                                //We perform the patch
                                bw.BaseStream.Seek(0x00713CD0, SeekOrigin.Begin);
                                bw.Write(new byte[0xDD].Select(x => x = 0x90).ToArray());

                                //Recompute hash
                                fs.Seek(0, SeekOrigin.Begin);
                                shawcc = System.Security.Cryptography.SHA256.Create().ComputeHash(fs).Aggregate("", (c, n) => c += n.ToString("x2"));
                                if (shawcc == wcc_sha256_patched)
                                {
                                    MessageBox.Show("Succesfully patched!", "Patch completed", MessageBoxButtons.OK,
                                                    MessageBoxIcon.Information);
                                }
                                else
                                {
                                    MessageBox.Show("Failed to patch! Please reinstall wcc_lite and try again",
                                                    "Patch completed", MessageBoxButtons.OK,
                                                    MessageBoxIcon.Error);
                                }
                            }



                            break;
                        }

                        case wcc_sha256_patched2:
                        case wcc_sha256_patched:
                        {
                            //Do nothing we are cool.
                            break;
                        }

                        default:
                        {
                            DialogResult = DialogResult.None;
                            textBoxGame.Focus();
                            MessageBox.Show("Invalid wcc_lite.exe path you seem to have on older version",
                                            "failed to save.");
                            return;
                        }
                        }
                    }
            }
            catch (UnauthorizedAccessException)
            {
                //wcc_lite is installed to C:\\Program files
                MessageBox.Show("Please restart WolvenKit as administrator. Couldn't access " + textBoxWcc.Text,
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                // Exit with error code 0 so we don't raise a windows error and the user can restart it so we have access to the files.
                Environment.Exit(0);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.ToString());
            }

            MainController.Get().StatusProgress = 100;
            MainController.Get().ProjectStatus  = EProjectStatus.Ready;
        }
        public override void Arrange()
        {
            base.Arrange();

            MockKernel.Setup(k => k.Resolve(It.IsAny <IRequest>())).Returns(new object[] { new TestType(), new string(new [] { 'a' }) });
        }
Exemplo n.º 19
0
 public void Initialize()
 {
     MockKernel.GetMock <IRepository <Book> >().ResetCalls();
     MockKernel.GetMock <IRepository <User> >().ResetCalls();
 }