Exemple #1
0
        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);
        }
Exemple #2
0
        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>());
        }
Exemple #3
0
        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));
        }
Exemple #4
0
        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()));
        }
Exemple #5
0
        public void GetValueOrDefault()
        {
            var context = new TestContextBase();

            Assert.That(context.GetValueOrDefault <TestValueA>(), Is.Not.Null);
            Assert.That(context.HasValue <TestValueA>(), Is.False);
        }
Exemple #6
0
        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>());
        }
Exemple #7
0
        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));
        }
Exemple #8
0
        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>());
        }