public async Task WhenRestorePackagesAndModuleLoaderIsNotInitializedThenExceptionIsThrown()
        {
            // ARRANGE
            var nugetClient             = new NugetClient(new HttpClientFactory());
            var moduleFeedClientFactory = new ModuleFeedClientFactory();
            var options      = new ModuleLoaderOptions();
            var moduleLoader = new ModuleLoader(nugetClient, moduleFeedClientFactory, options);

            // ACT
            var ex = await Assert.ThrowsAsync <ModuleLoaderInternalException>(() => moduleLoader.RestoreUnits());

            // ASSERT
            Assert.NotNull(ex);
        }
        public void WhenInitializeModuleLoaderAndNoEnvironmentVariableThenExceptionIsThrown()
        {
            // ARRANGE
            Environment.SetEnvironmentVariable("SID_MODULE", null);
            var nugetClient             = new NugetClient(new HttpClientFactory());
            var moduleFeedClientFactory = new ModuleFeedClientFactory();
            var options      = new ModuleLoaderOptions();
            var moduleLoader = new ModuleLoader(nugetClient, moduleFeedClientFactory, options);

            // ACT
            var exception = Assert.Throws <ModuleLoaderConfigurationException>(() => moduleLoader.Initialize());

            // ASSERT
            Assert.NotNull(exception);
            Assert.Equal($"The SID_MODULE environment variable must be set", exception.Message);
        }
        public void WhenInitializeModuleLoaderAndEnvironmentVariableIsNotValidThenExceptionIsThrown()
        {
            // ARRANGE
            var nugetClient             = new NugetClient(new HttpClientFactory());
            var moduleFeedClientFactory = new ModuleFeedClientFactory();
            var options      = new ModuleLoaderOptions();
            var moduleLoader = new ModuleLoader(nugetClient, moduleFeedClientFactory, options);

            Environment.SetEnvironmentVariable("SID_MODULE", "invalid");

            // ACT
            var exception = Assert.Throws <ModuleLoaderConfigurationException>(() => moduleLoader.Initialize());

            // ASSERT
            Assert.NotNull(exception);
            Assert.Equal("The directory specified in the SID_MODULE environment variable doesn't exist", exception.Message);
        }
        public void WhenInitializeModuleLoaderAndNugetSourcesIsNullThenExceptionIsThrown()
        {
            // ARRANGE
            var nugetClient             = new NugetClient(new HttpClientFactory());
            var moduleFeedClientFactory = new ModuleFeedClientFactory();

            Environment.SetEnvironmentVariable("SID_MODULE", "C:\\");
            var options = new ModuleLoaderOptions
            {
                NugetSources = null
            };
            var moduleLoader = new ModuleLoader(nugetClient, moduleFeedClientFactory, options);

            // ACT
            var exception = Assert.Throws <ModuleLoaderConfigurationException>(() => moduleLoader.Initialize());

            // ASSERT
            Assert.NotNull(exception);
            Assert.Equal("At least one nuget sources must be specified", exception.Message);
        }
        public void WhenInitializeModuleLoaderAndConfigurationFileDoesntExistThenExceptionIsThrown()
        {
            // ARRANGE
            SetCurrentAssembly();
            RemoveFiles();
            var nugetClient             = new NugetClient(new HttpClientFactory());
            var moduleFeedClientFactory = new ModuleFeedClientFactory();

            Environment.SetEnvironmentVariable("SID_MODULE", "C:\\");
            var options = new ModuleLoaderOptions
            {
                NugetSources  = new[] { "nuget" },
                ProjectName   = "projectName",
                ModuleFeedUri = new Uri("http://localhost/configuration")
            };
            var moduleLoader = new ModuleLoader(nugetClient, moduleFeedClientFactory, options);

            // ACT
            var exception = Assert.Throws <FileNotFoundException>(() => moduleLoader.Initialize());

            // ASSERT
            Assert.NotNull(exception);
        }