public int Convert_ExpectedResults(string columnId)
        {
            //Preparing
            var configuration = new AssetsSourceConfiguration(Environment.CurrentDirectory + "\\TestFiles\\AssetsConfigFile.json");

            return(configuration.Convert(columnId));
        }
        public void SaveChanges_Successfull()
        {
            //Arrange
            string jsonPath      = Environment.CurrentDirectory + "\\TestFiles\\AssetsConfigFile.json";
            var    config        = new AssetsSourceConfiguration(jsonPath);
            var    oldConfig     = config.GetJsonObject();
            var    newJsonConfig = new JsonConfiguration
            {
                FirstRow              = 10,
                MakeColumn            = "AA",
                ModelColumn           = "AB",
                InventoryNumberColumn = "AC",
                UserColumn            = "AD",
                LocationColumn        = "AF"
            };

            //Act
            config.Update(newJsonConfig);
            config.SaveChanges();
            var updatedConfig     = new AssetsSourceConfiguration(jsonPath);
            var updatedJsonConfig = updatedConfig.GetJsonObject();

            updatedConfig.Update(oldConfig);
            updatedConfig.SaveChanges();

            //Assert
            Assert.AreEqual(newJsonConfig.FirstRow, updatedJsonConfig.FirstRow);
            Assert.AreEqual(newJsonConfig.MakeColumn, updatedJsonConfig.MakeColumn);
            Assert.AreEqual(newJsonConfig.ModelColumn, updatedJsonConfig.ModelColumn);
            Assert.AreEqual(newJsonConfig.InventoryNumberColumn, updatedJsonConfig.InventoryNumberColumn);
            Assert.AreEqual(newJsonConfig.UserColumn, updatedJsonConfig.UserColumn);
            Assert.AreEqual(newJsonConfig.LocationColumn, updatedJsonConfig.LocationColumn);
        }
        public void CreateAssetsSourceConfiguration_Successfull()
        {
            var configuration = new AssetsSourceConfiguration(Environment.CurrentDirectory + "\\TestFiles\\AssetsConfigFile.json");

            Assert.AreEqual(configuration.FirstRow, 2);
            Assert.AreEqual(configuration.MakeIndex, 1);
            Assert.AreEqual(configuration.ModelIndex, 2);
            Assert.AreEqual(configuration.InventoryNumberIndex, 3);
            Assert.AreEqual(configuration.UserIndex, 4);
            Assert.AreEqual(configuration.LocationIndex, 5);
        }
Ejemplo n.º 4
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            //Register dialog service singlton
            var dialogService = new Dialog(null);

            dialogService.Register <MainWindowViewModel, MainWindow>();
            dialogService.Register <MessageDialogViewModel, MessageDialog>();
            dialogService.Register <ConfigureDialogViewModel, ConfigureDialog>();
            dialogService.Register <AboutViewModel, AboutDialog>();
            DI.AddSinglton <IDialogService>(dialogService);

            //Register Categories Provider as singlton
            ICategoriesProvider catsProvider = new CategoriesProvider();

            DI.AddSinglton <ICategoriesProvider>(catsProvider);

            //Register message composer as singlton.
            DI.AddSinglton <IMessageComposer>(new MessageComposer());

            var assetsConfig = new AssetsSourceConfiguration(Environment.CurrentDirectory + "\\Configs\\ExcelConfig.json");

            DI.AddSinglton <IAssetSourceConfiguration>(assetsConfig);

            var appSettingsProvider = new JsonSettingsProvider(Environment.CurrentDirectory + "\\Configs\\AppSettings.json");

            DI.AddSinglton <ISettingsProvider>(appSettingsProvider);

            var assetsSource = new ExcelAssetReader();

            assetsSource.Configure(assetsConfig);

            DI.AddSinglton <IAssetSource>(assetsSource);

            DI.AddSinglton <IClipBoard>(new ClipboardService());

            //Register mail service as scoped
            DI.AddService <IMailService, OutlookMailService>();

            DI.AddTransient(typeof(MainWindowViewModel));

            DI.Construct();
            IRC.Helpdesk.ViewModels.DI.SetProvider(DI.Provider);

            DI.GetService <IDialogService>().ShowWindow <MainWindowViewModel>(DI.GetService <MainWindowViewModel>(), true);
        }