Ejemplo n.º 1
0
        public static void TestClassInit(TestContext testContext)
        {
            //TestDirectory = testContext.TestRunDirectory;

            // Create test directory if it does not exist

            if (!Directory.Exists(TestDirectory))
            {
                Directory.CreateDirectory(TestDirectory);
            }
            else
            {
                ClearTestDirectory();
            }



            ApplicationBuildConfig.SetOverrideUserDataPath(TestDirectory);

            // Create test data
            Image img = Resources.testImg;

            img.Save(Path.Combine(TestDirectory, TestImages[0]));

            img = Resources.anonymus;
            img.Save(Path.Combine(TestDirectory, TestImages[1]));

            img = Resources.anonymus_small;
            img.Save(Path.Combine(TestDirectory, TestImages[2]));

            _applicationBuildConfig = Substitute.For <IApplicationBuildConfig>();
            _applicationBuildConfig.UserDataPath.Returns(TestDirectory);
            _applicationBuildConfig.DebugMode.Returns(true);
        }
        /// <summary>
        /// Tests the class initialize.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="InvalidProgramException">Local temp data folder was not found!</exception>
        protected static void RepositoryTestClassInit(TestContext context)
        {
            GlobalUnitTestConfig.Initialize(context);
            ApplicationBuildConfig.SetOverrideUserDataPath(GlobalUnitTestConfig.TempDataPath);
            _container = AutofacConfig.CreateContainer();
            context.Properties.Add("Container", _container);

            var tempDir = new DirectoryInfo(GlobalUnitTestConfig.TempDataPath);

            if (!tempDir.Exists)
            {
                throw new InvalidProgramException("Local temp data folder was not found!");
            }

            context.WriteLine("RepositoryTestClassInit configuration completed");
        }
        public static void BookmarkStorageInitialize(TestContext testContext)
        {
            GlobalSettings.UnitTestInitialize(TestDataPath);
            ApplicationBuildConfig.SetOverrideUserDataPath(TestDataPath);

            _genericImageRef = new ImageReferenceElement
            {
                Directory      = TestDataPath,
                FileName       = "testImage.jpg",
                CreationTime   = DateTime.Now,
                Size           = 1024,
                LastAccessTime = DateTime.Now.Date,
                LastWriteTime  = DateTime.Now.Date
            };
            _genericImageRef.CompletePath = Path.Combine(_genericImageRef.Directory, _genericImageRef.FileName);

            _container = ContainerFactory.CreateGenericContainerForApp();
            _scope     = _container.BeginLifetimeScope();
        }