示例#1
0
        public async Task ConfigurationService_ConfigureAsync_User_ComponentsAreConfiguredWithUser()
        {
            var context = new TestCommandContext();
            var service = new ConfigurationService(context);

            var component1 = new Mock <IConfigurableComponent>();
            var component2 = new Mock <IConfigurableComponent>();
            var component3 = new Mock <IConfigurableComponent>();

            service.AddComponent(component1.Object);
            service.AddComponent(component2.Object);
            service.AddComponent(component3.Object);

            await service.ConfigureAsync(ConfigurationTarget.User);

            component1.Verify(x => x.ConfigureAsync(
                                  context.Environment, EnvironmentVariableTarget.User,
                                  It.IsAny <IGitConfiguration>(), GitConfigurationLevel.Global),
                              Times.Once);
            component2.Verify(x => x.ConfigureAsync(
                                  context.Environment, EnvironmentVariableTarget.User,
                                  It.IsAny <IGitConfiguration>(), GitConfigurationLevel.Global),
                              Times.Once);
            component3.Verify(x => x.ConfigureAsync(
                                  context.Environment, EnvironmentVariableTarget.User,
                                  It.IsAny <IGitConfiguration>(), GitConfigurationLevel.Global),
                              Times.Once);
        }
示例#2
0
        public async Task ConfigurationService_UnconfigureAsync_System_ComponentsAreUnconfiguredWithSystem()
        {
            var context = new TestCommandContext();
            var service = new ConfigurationService(context);

            var component1 = new Mock <IConfigurableComponent>();
            var component2 = new Mock <IConfigurableComponent>();
            var component3 = new Mock <IConfigurableComponent>();

            service.AddComponent(component1.Object);
            service.AddComponent(component2.Object);
            service.AddComponent(component3.Object);

            await service.UnconfigureAsync(ConfigurationTarget.System);

            component1.Verify(x => x.UnconfigureAsync(
                                  context.Environment, EnvironmentVariableTarget.Machine,
                                  It.IsAny <IGitConfiguration>(), GitConfigurationLevel.System),
                              Times.Once);
            component2.Verify(x => x.UnconfigureAsync(
                                  context.Environment, EnvironmentVariableTarget.Machine,
                                  It.IsAny <IGitConfiguration>(), GitConfigurationLevel.System),
                              Times.Once);
            component3.Verify(x => x.UnconfigureAsync(
                                  context.Environment, EnvironmentVariableTarget.Machine,
                                  It.IsAny <IGitConfiguration>(), GitConfigurationLevel.System),
                              Times.Once);
        }
        public async Task ConfigurationService_UnconfigureAsync_User_ComponentsAreUnconfiguredWithUser()
        {
            var context = new TestCommandContext();
            var service = new ConfigurationService(context);

            var component1 = new Mock <IConfigurableComponent>();
            var component2 = new Mock <IConfigurableComponent>();
            var component3 = new Mock <IConfigurableComponent>();

            service.AddComponent(component1.Object);
            service.AddComponent(component2.Object);
            service.AddComponent(component3.Object);

            await service.UnconfigureAsync(ConfigurationTarget.User);

            component1.Verify(x => x.UnconfigureAsync(ConfigurationTarget.User),
                              Times.Once);
            component2.Verify(x => x.UnconfigureAsync(ConfigurationTarget.User),
                              Times.Once);
            component3.Verify(x => x.UnconfigureAsync(ConfigurationTarget.User),
                              Times.Once);
        }