public void InitializeWithNull()
        {
            IReadOnlyList <object> list = ImmutableSingleton.Create <object> (null);

            Assert.That(list.Count, Is.EqualTo(1));
            Assert.That(list[0], Is.Null);
        }
        private IReadOnlyList <AccessType> ConvertRequiredAccessTypeEnums(IReadOnlyList <Enum> requiredAccessTypeEnums)
        {
            if (requiredAccessTypeEnums.Count == 1)
            {
                var requiredAccessTypeEnum = requiredAccessTypeEnums[0];
                if (s_readAccessTypeAsEnum.Equals(requiredAccessTypeEnum))
                {
                    return(s_readAccessTypeAsList);
                }
                if (s_editAccessTypeAsEnum.Equals(requiredAccessTypeEnum))
                {
                    return(s_editAccessTypeAsList);
                }
                return(ImmutableSingleton.Create(AccessType.Get(requiredAccessTypeEnum)));
            }

            var requiredAccessTypes = new AccessType[requiredAccessTypeEnums.Count];

            for (int i = 0; i < requiredAccessTypeEnums.Count; i++)
            {
                requiredAccessTypes[i] = ConvertEnumToAccessType(requiredAccessTypeEnums[i]);
            }

            return(requiredAccessTypes);
        }
        public void Index_WithLessThan0_ThrowsArgumentOutOfRangeException()
        {
            IReadOnlyList <string> list = ImmutableSingleton.Create("B");

            Assert.That(
                () => list[-1],
                Throws.TypeOf <ArgumentOutOfRangeException>()
                .With.Message.EqualTo("The list contains only a single item.\r\nParameter name: index\r\nActual value was -1."));
        }
        public void Enumerate_Foreach()
        {
            var items = new List <string>();

            foreach (var item in  ImmutableSingleton.Create("B"))
            {
                items.Add(item);
            }

            Assert.That(items, Is.EqualTo(new[] { "B" }));
        }
        public void Enumerate_NonGeneric()
        {
            IReadOnlyList <string> list       = ImmutableSingleton.Create("B");
            IEnumerator            enumerator = list.ToNonGenericEnumerable().GetEnumerator();

            Assert.That(() => enumerator.Current, Throws.InvalidOperationException.With.Message.EqualTo("Enumeration has not started. Call MoveNext."));
            Assert.That(enumerator.MoveNext(), Is.True);
            Assert.That(enumerator.Current, Is.EqualTo("B"));
            Assert.That(enumerator.MoveNext(), Is.False);
            Assert.That(() => enumerator.Current, Throws.InvalidOperationException.With.Message.EqualTo("Enumeration already finished."));
            enumerator.Reset();
            Assert.That(() => enumerator.Current, Throws.InvalidOperationException.With.Message.EqualTo("Enumeration has not started. Call MoveNext."));
            Assert.That(enumerator.MoveNext(), Is.True);
            Assert.That(enumerator.Current, Is.EqualTo("B"));
        }
        public void Index_With0_ReturnsItem()
        {
            IReadOnlyList <string> list = ImmutableSingleton.Create("B");

            Assert.That(list[0], Is.EqualTo("B"));
        }
        public void Count()
        {
            IReadOnlyList <string> list = ImmutableSingleton.Create("A");

            Assert.That(list.Count, Is.EqualTo(1));
        }