diff --git a/LightweightIocContainer/AssemblyInfo.cs b/LightweightIocContainer/AssemblyInfo.cs new file mode 100644 index 0000000..18bea16 --- /dev/null +++ b/LightweightIocContainer/AssemblyInfo.cs @@ -0,0 +1,7 @@ +// Author: Gockner, Simon +// Created: 2019-07-04 +// Copyright(c) 2019 SimonG. All Rights Reserved. + +using System.Runtime.CompilerServices; + +[assembly:InternalsVisibleTo("Test.LightweightIocContainer")] \ No newline at end of file diff --git a/Test.LightweightIocContainer/EnumerableExtensionTest.cs b/Test.LightweightIocContainer/EnumerableExtensionTest.cs new file mode 100644 index 0000000..ddc724c --- /dev/null +++ b/Test.LightweightIocContainer/EnumerableExtensionTest.cs @@ -0,0 +1,77 @@ +// Author: Gockner, Simon +// Created: 2019-07-03 +// Copyright(c) 2019 SimonG. All Rights Reserved. + +using System.Collections.Generic; +using LightweightIocContainer; +using NUnit.Framework; + +namespace Test.LightweightIocContainer +{ + [TestFixture] + public class EnumerableExtensionTest + { + #region TestClasses + + private class ListObject + { + public int Index { get; set; } + } + + private class Given : ListObject + { + + } + + #endregion TestClasses + + + [Test] + public void TestFirstOrGivenNoPredicateEmpty() + { + List list = new List(); + Assert.IsInstanceOf(list.FirstOrGiven()); + } + + [Test] + public void TestFirstOrGivenNoPredicate() + { + List list = new List() + { + new ListObject() {Index = 0}, + new ListObject() {Index = 1}, + new ListObject() {Index = 2}, + new ListObject() {Index = 3} + }; + + ListObject listObject = list.FirstOrGiven(); + + Assert.IsNotInstanceOf(listObject); + Assert.AreEqual(0, listObject.Index); + } + + [Test] + public void TestFirstOrGivenPredicateEmpty() + { + List list = new List(); + Assert.IsInstanceOf(list.FirstOrGiven(o => o.Index == 2)); + } + + [Test] + public void TestFirstOrGivenPredicate() + { + List list = new List() + { + new ListObject() {Index = 0}, + new ListObject() {Index = 1}, + new ListObject() {Index = 2}, + new ListObject() {Index = 3} + }; + + ListObject listObject = list.FirstOrGiven(o => o.Index == 2); + + Assert.IsNotInstanceOf(listObject); + Assert.AreEqual(2, listObject.Index); + } + } +} \ No newline at end of file