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 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 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() { 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 GetValueOrDefault() { var context = new TestContextBase(); Assert.That(context.GetValueOrDefault <TestValueA>(), Is.Not.Null); Assert.That(context.HasValue <TestValueA>(), 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 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>()); }