public void GetBuildArtifact() { var pipeline = new TestBuildPipelineWithBuildArtifact(); var config = BuildConfiguration.CreateInstance(c => c.SetComponent(new TestBuildPipelineComponent { Pipeline = pipeline })); var context = new TestContextBase(pipeline, config); Assert.That(context.GetBuildArtifact <TestBuildArtifactA>(), Is.Null); Assert.That(context.GetBuildArtifact <TestBuildArtifactB>(), Is.Null); config.Build(); Assert.That(context.GetBuildArtifact <TestBuildArtifactA>(), Is.Not.Null); Assert.That(context.GetBuildArtifact <TestBuildArtifactB>(), Is.Null); Assert.That(config.Run().Succeeded, Is.True); config.CleanBuildArtifact(); Assert.That(context.GetBuildArtifact <TestBuildArtifactA>(), Is.Null); Assert.That(context.GetBuildArtifact <TestBuildArtifactB>(), Is.Null); Assert.Throws <ArgumentNullException>(() => context.GetBuildArtifact(null)); Assert.Throws <InvalidOperationException>(() => context.GetBuildArtifact(typeof(object))); Assert.Throws <InvalidOperationException>(() => context.GetBuildArtifact(typeof(TestBuildArtifactInvalidA))); Assert.Throws <InvalidOperationException>(() => context.GetBuildArtifact(typeof(TestBuildArtifactInvalidB))); }
public void SetValue_SkipObjectType() { var context = new TestContextBase(); Assert.DoesNotThrow(() => context.SetValue(new object())); Assert.That(context.Values.Length, Is.Zero); }
public TestResult(TestContextBase context, bool succeeded, DateTime startTime, DateTime endTime) { this.Succeeded = succeeded; this.StartTime = startTime; this.EndTime = endTime; this.Context = context; }
public void GetValueOrDefault() { var context = new TestContextBase(); Assert.That(context.GetValueOrDefault <TestValueA>(), Is.Not.Null); Assert.That(context.HasValue <TestValueA>(), Is.False); }
public void SetValue_SkipNullValues() { var context = new TestContextBase(); Assert.DoesNotThrow(() => context.SetValue <object>(null)); Assert.That(context.Values.Length, Is.Zero); }
public void GetOrCreateValue_WhenValueExist_DoesNotThrow() { var context = new TestContextBase(); context.SetValue(new TestValueA()); Assert.DoesNotThrow(() => context.GetOrCreateValue <TestValueA>()); }
public void GetValue() { var context = new TestContextBase(); var value = new TestValueA(); context.SetValue(value); Assert.That(context.GetValue <TestValueA>(), Is.EqualTo(value)); }
public void HasValue() { var context = new TestContextBase(); context.SetValue(new TestValueA()); Assert.That(context.HasValue <TestValueA>(), Is.True); Assert.That(context.HasValue <TestValueB>(), Is.False); }
public void GetValueOrDefault() { var context = new TestContextBase(); Assert.That(context.GetValueOrDefault <TestValueA>(), Is.Not.Null); Assert.That(context.HasValue <TestValueA>(), Is.False); Assert.Throws <InvalidOperationException>(() => context.GetValueOrDefault <object>()); }
public void GetOrCreateValue() { var context = new TestContextBase(); Assert.That(context.GetOrCreateValue <TestValueA>(), Is.Not.Null); Assert.That(context.HasValue <TestValueA>(), Is.True); Assert.That(context.GetValue <TestValueA>(), Is.Not.Null); Assert.That(context.Values.Length, Is.EqualTo(1)); }
public void RemoveValue() { var context = new TestContextBase(); context.SetValue(new TestValueA()); Assert.That(context.Values.Length, Is.EqualTo(1)); Assert.That(context.RemoveValue <TestValueA>(), Is.True); Assert.That(context.Values.Length, Is.Zero); }
public void GetValue() { var context = new TestContextBase(); var value = new TestValueA(); context.SetValue(value); Assert.That(context.GetValue <TestValueA>(), Is.EqualTo(value)); Assert.Throws <InvalidOperationException>(() => context.GetValue <object>()); }
public void HasValue() { var context = new TestContextBase(); context.SetValue(new TestValueA()); Assert.That(context.HasValue <TestValueA>(), Is.True); Assert.That(context.HasValue <TestValueB>(), Is.False); Assert.Throws <InvalidOperationException>(() => context.HasValue <object>()); }
public void RemoveValue() { var context = new TestContextBase(); context.SetValue(new TestValueA()); Assert.That(context.Values.Length, Is.EqualTo(1)); Assert.That(context.RemoveValue <TestValueA>(), Is.True); Assert.That(context.Values.Length, Is.Zero); Assert.Throws <InvalidOperationException>(() => context.RemoveValue <object>()); }
public void GetOrCreateValue() { var context = new TestContextBase(); Assert.That(context.GetOrCreateValue <TestValueA>(), Is.Not.Null); Assert.That(context.HasValue <TestValueA>(), Is.True); Assert.That(context.GetValue <TestValueA>(), Is.Not.Null); Assert.That(context.Values.Length, Is.EqualTo(1)); Assert.Throws <InvalidOperationException>(() => context.GetOrCreateValue <object>()); }
public void SetValue() { var context = new TestContextBase(); context.SetValue(new TestValueA()); context.SetValue <TestValueB>(); Assert.That(context.HasValue <TestValueA>(), Is.True); Assert.That(context.GetValue <TestValueA>(), Is.Not.Null); Assert.That(context.HasValue <TestValueB>(), Is.True); Assert.That(context.GetValue <TestValueB>(), Is.Not.Null); Assert.That(context.Values.Length, Is.EqualTo(2)); }
public void SetValue_WhenValueExist_OverrideValue() { var context = new TestContextBase(); var instance1 = new TestValueA(); var instance2 = new TestValueA(); context.SetValue(instance1); Assert.That(context.Values, Is.EqualTo(new[] { instance1 })); context.SetValue(instance2); Assert.That(context.Values, Is.EqualTo(new[] { instance2 })); }
public void TryGetComponent() { var pipeline = new TestBuildPipelineWithUsedComponents(); var config = BuildConfiguration.CreateInstance(c => c.SetComponent <TestBuildComponentA>()); var context = new TestContextBase(pipeline, config); Assert.That(context.TryGetComponent <TestBuildComponentA>(out _), Is.True); Assert.That(context.TryGetComponent <TestBuildComponentB>(out _), Is.False); Assert.Throws <InvalidOperationException>(() => context.TryGetComponent <TestBuildComponentC>(out _)); Assert.Throws <ArgumentNullException>(() => context.TryGetComponent(null, out _)); Assert.Throws <InvalidOperationException>(() => context.TryGetComponent(typeof(object), out _)); Assert.Throws <InvalidOperationException>(() => context.TryGetComponent(typeof(TestBuildComponentInvalid), out _)); }
public void GetComponentTypes() { var pipeline = new TestBuildPipelineWithUsedComponents(); var configB = BuildConfiguration.CreateInstance(c => c.SetComponent <TestBuildComponentB>()); var configA = BuildConfiguration.CreateInstance(c => { c.SetComponent <TestBuildComponentA>(); c.AddDependency(configB); }); var context = new TestContextBase(pipeline, configA); Assert.That(context.GetComponentTypes(), Is.EquivalentTo(new[] { typeof(TestBuildComponentA), typeof(TestBuildComponentB) })); }
public void GetComponentOrDefault() { var pipeline = new TestBuildPipelineWithUsedComponents(); var config = BuildConfiguration.CreateInstance(); var context = new TestContextBase(pipeline, config); Assert.That(context.HasComponent <TestBuildComponentA>(), Is.False); Assert.That(context.GetComponentOrDefault <TestBuildComponentA>(), Is.Not.Null); Assert.Throws <InvalidOperationException>(() => context.GetComponentOrDefault <TestBuildComponentC>()); Assert.Throws <ArgumentNullException>(() => context.GetComponentOrDefault(null)); Assert.Throws <InvalidOperationException>(() => context.GetComponentOrDefault(typeof(object))); Assert.Throws <InvalidOperationException>(() => context.GetComponentOrDefault(typeof(TestBuildComponentInvalid))); }
public void SetValue() { var context = new TestContextBase(); context.SetValue(new TestValueA()); context.SetValue <TestValueB>(); Assert.That(context.HasValue <TestValueA>(), Is.True); Assert.That(context.GetValue <TestValueA>(), Is.Not.Null); Assert.That(context.HasValue <TestValueB>(), Is.True); Assert.That(context.GetValue <TestValueB>(), Is.Not.Null); Assert.That(context.Values.Length, Is.EqualTo(2)); Assert.Throws <ArgumentNullException>(() => context.SetValue <TestValueA>(null)); Assert.Throws <InvalidOperationException>(() => context.SetValue(new object())); }
public void GetAllBuildArtifacts() { var pipeline = new TestBuildPipelineWithBuildArtifact(); var config = BuildConfiguration.CreateInstance(c => c.SetComponent(new TestBuildPipelineComponent { Pipeline = pipeline })); var context = new TestContextBase(pipeline, config); Assert.That(context.GetAllBuildArtifacts(), Is.Empty); config.Build(); Assert.That(context.GetAllBuildArtifacts().Select(a => a.GetType()), Is.EquivalentTo(new[] { typeof(TestBuildArtifactA) })); Assert.That(config.Run().Succeeded, Is.True); config.CleanBuildArtifact(); Assert.That(context.GetAllBuildArtifacts(), Is.Empty); }
public async Task RunAsync(Func <Task> next) { var testContext = new TestContextBase(); Console.WriteLine("With dependency injection framework and generic type implementation:"); var iocManager = new IocManager(); iocManager.Builder .RegisterGeneric(typeof(AsyncPipelineAggregator <>)) .AsImplementedInterfaces() .InstancePerDependency(); iocManager.RegisterByConvention(typeof(Program).Assembly); IIocResolver resolver = iocManager; var aggregator = resolver.Resolve <IAsyncPipelineAggregator <TestContextBase> >(); await aggregator.AggregateAsync(testContext, next); }
public void GetComponents() { var pipeline = new TestBuildPipelineWithUsedComponents(); var configB = BuildConfiguration.CreateInstance(c => c.SetComponent <TestBuildComponentB>()); var configA = BuildConfiguration.CreateInstance(c => { c.SetComponent <TestBuildComponentA>(); c.AddDependency(configB); }); var context = new TestContextBase(pipeline, configA); var components = context.GetComponents(); Assert.That(components.Count, Is.EqualTo(2)); Assert.That(components.Select(c => c.GetType()), Is.EquivalentTo(new[] { typeof(TestBuildComponentA), typeof(TestBuildComponentB) })); configA.SetComponent <TestBuildComponentC>(); Assert.Throws <InvalidOperationException>(() => context.GetComponents()); }
public void IsComponentInherited() { var pipeline = new TestBuildPipelineWithUsedComponents(); var configB = BuildConfiguration.CreateInstance(c => c.SetComponent <TestBuildComponentB>()); var configA = BuildConfiguration.CreateInstance(c => { c.SetComponent <TestBuildComponentA>(); c.AddDependency(configB); }); var context = new TestContextBase(pipeline, configA); Assert.That(context.IsComponentInherited <TestBuildComponentA>(), Is.False); Assert.That(context.IsComponentInherited <TestBuildComponentB>(), Is.True); Assert.Throws <InvalidOperationException>(() => context.IsComponentInherited <TestBuildComponentC>()); Assert.Throws <ArgumentNullException>(() => context.IsComponentInherited(null)); Assert.Throws <InvalidOperationException>(() => context.IsComponentInherited(typeof(object))); Assert.Throws <InvalidOperationException>(() => context.IsComponentInherited(typeof(TestBuildComponentInvalid))); }
public TestResultWithValue(TestContextBase context, T instance, TValue value, bool isSuccess, DateTime startTime, DateTime endTime) : base(context, instance, isSuccess, startTime, endTime) { this.Value = value; }
public TestResultWithException(TestContextBase context, T instance, TException exception, DateTime startTime, DateTime endTime) : base(context, instance, exception != null, startTime, endTime) { this.Exception = exception; }
public void GetValue_WhenValueDoesNotExist_IsNull() { var context = new TestContextBase(); Assert.That(context.GetValue <TestValueA>(), Is.Null); }