public async Task IsImplicitlyActive_WhenAccessedInDeactivateAsync_ReturnsFalse() { var project = ConfiguredProjectFactory.ImplementProjectConfiguration("Debug|AnyCPU"); var service = CreateInstance(project, out ProjectValueDataSource <IConfigurationGroup <ProjectConfiguration> > source); service.Load(); Assert.False(service.IsImplicitlyActive); var configurationGroups = IConfigurationGroupFactory.CreateFromConfigurationNames("Debug|AnyCPU"); await source.SendAsync(configurationGroups); await Task.Delay(500); // Wait for data to be sent Assert.True(service.IsImplicitlyActive); bool?result = null; var implicitActiveService = IImplicitlyActiveServiceFactory.ImplementDeactivateAsync(() => { result = service.IsImplicitlyActive; }); service.ImplicitlyActiveServices.Add(implicitActiveService); configurationGroups = IConfigurationGroupFactory.CreateFromConfigurationNames("Debug|x86"); await source.SendAndCompleteAsync(configurationGroups, service.TargetBlock); Assert.False(result); }
public async Task WhenActiveConfigurationChangesAndNoLongerMatches_CallsDeactivateAsync() { var project = ConfiguredProjectFactory.ImplementProjectConfiguration("Debug|AnyCPU"); var service = CreateInstance(project, out ProjectValueDataSource <IConfigurationGroup <ProjectConfiguration> > source); service.Load(); Assert.False(service.IsImplicitlyActive); var configurationGroups = IConfigurationGroupFactory.CreateFromConfigurationNames("Debug|AnyCPU"); await source.SendAsync(configurationGroups); await Task.Delay(500); // Wait for data to be sent Assert.True(service.IsImplicitlyActive); int callCount = 0; var implicitActiveService = IImplicitlyActiveServiceFactory.ImplementDeactivateAsync(() => { callCount++; }); service.ImplicitlyActiveServices.Add(implicitActiveService); configurationGroups = IConfigurationGroupFactory.CreateFromConfigurationNames("Debug|x86"); await source.SendAndCompleteAsync(configurationGroups, service.TargetBlock); Assert.Equal(1, callCount); }
public async Task WhenActiveConfigurationChangesAndMatches_CallsActivateAsync(string[] configurations, string currentConfiguration) { var project = ConfiguredProjectFactory.ImplementProjectConfiguration(currentConfiguration); var service = CreateInstance(project, out ProjectValueDataSource <IConfigurationGroup <ProjectConfiguration> > source); service.Load(); int callCount = 0; var implicitActiveService = IImplicitlyActiveServiceFactory.ImplementActivateAsync(() => { callCount++; }); service.ImplicitlyActiveServices.Add(implicitActiveService); var configurationGroups = IConfigurationGroupFactory.CreateFromConfigurationNames(configurations); await source.SendAndCompleteAsync(configurationGroups, service.TargetBlock); Assert.Equal(1, callCount); }