public void Indexer_ReturnsItem_IfAvailable_Else_ReturnsNull()
        {
            var actualID = 1;
            var fakeID   = 2;
            var repo     = new RepositorySystem();

            var itemA = Substitute.For <IItemInfo>();

            itemA.ID = actualID;

            repo.Add(itemA);

            Assert.AreEqual(itemA, repo[actualID]);
            Assert.IsNull(repo[fakeID]);
        }
        /// <summary>  </summary>
        public static void Init(DBCfgViewModel dBConfig)
        {
            _DBCfgViewModel = dBConfig;
            RepositorySystem               repositorySystem               = new RepositorySystem(dBConfig);
            RepositoryOrganizationType     repositoryOrganizationType     = new RepositoryOrganizationType(dBConfig);
            RepositoryAttributionType      repositoryAttributionType      = new RepositoryAttributionType(dBConfig);
            RepositoryOrganization         repositoryOrganization         = new RepositoryOrganization(dBConfig);
            RepositoryPrivilegeGroup       repositoryPrivilegeGroup       = new RepositoryPrivilegeGroup(dBConfig);
            RepositoryPrivilege            repositoryPrivilege            = new RepositoryPrivilege(dBConfig);
            RepositoryRelationPositionRole repositoryRelationPositionRole = new RepositoryRelationPositionRole(dBConfig);
            RepositoryUser repositoryUser = new RepositoryUser(dBConfig);

            IocUnity.AddTransient <BusinessSystem>();
            IocUnity.AddTransient <BusinessUser>();
            IocUnity.AddTransient <BusinessRole>();
            IocUnity.AddTransient <BusinessPrivilege>();
            IocUnity.AddTransient <BusinessOrganization>();
            IocUnity.AddTransient <BusinessItem>();
            RepositoryRelationUserOrganization repositoryRelationUserOrganization = new RepositoryRelationUserOrganization(dBConfig);
            RepositoryRole repositoryRole = new RepositoryRole(dBConfig);
            RepositoryRelationRolePrivilege        repositoryRelationRolePrivilege        = new RepositoryRelationRolePrivilege(dBConfig);
            RepositoryRelationUserPrivilege        repositoryRelationUserPrivilege        = new RepositoryRelationUserPrivilege(dBConfig);
            RepositoryRelationUserRole             repositoryRelationUserRole             = new RepositoryRelationUserRole(dBConfig);
            RepositoryRelationOrganization         repositoryRelationOrganization         = new RepositoryRelationOrganization(dBConfig);
            RepositioryRelationOrganizationForeign repositioryRelationOrganizationForeign = new RepositioryRelationOrganizationForeign(dBConfig);
            RepositoryItem               repositoryItem        = new RepositoryItem(dBConfig);
            RepositoryItemContent        repositoryItemContent = new RepositoryItemContent(dBConfig);
            BaseData <TRelationRoleItem> rBaseData             = new BaseData <TRelationRoleItem>(dBConfig);

            IocUnity.AddSingleton(rBaseData);
            IocUnity.AddSingleton(repositoryItem);
            IocUnity.AddSingleton(repositoryItemContent);
            IocUnity.AddSingleton(repositoryRelationOrganization);
            IocUnity.AddSingleton(repositoryRelationUserRole);
            IocUnity.AddSingleton(repositoryRelationUserOrganization);
            IocUnity.AddSingleton(repositorySystem);
            IocUnity.AddSingleton(repositoryOrganizationType);
            IocUnity.AddSingleton(repositoryAttributionType);
            IocUnity.AddSingleton(repositoryOrganization);
            IocUnity.AddSingleton(repositoryPrivilegeGroup);
            IocUnity.AddSingleton(repositoryPrivilege);
            IocUnity.AddSingleton(repositoryRelationPositionRole);
            IocUnity.AddSingleton(repositoryUser);
            IocUnity.AddSingleton(repositoryRole);
            IocUnity.AddSingleton(repositoryRelationRolePrivilege);
            IocUnity.AddSingleton(repositoryRelationUserPrivilege);
            IocUnity.AddSingleton(repositioryRelationOrganizationForeign);
        }
        public void Clear_RemovesAllItems()
        {
            var repo = new RepositorySystem();

            var itemA = Substitute.For <IItemInfo>();

            itemA.ID = 1;
            var itemB = Substitute.For <IItemInfo>();

            itemB.ID = 2;

            repo.Add(itemA);
            repo.Add(itemB);
            repo.Clear();

            Assert.AreEqual(0, repo.Count);
        }
        public void Add_OverwritesItem_IfIdExists()
        {
            var sharedID = 1;
            var repo     = new RepositorySystem();

            var itemA = Substitute.For <IItemInfo>();

            itemA.ID = sharedID;
            var itemB = Substitute.For <IItemInfo>();

            itemB.ID = sharedID;

            repo.Add(itemA);
            repo.Add(itemB);

            Assert.AreEqual(itemB, repo[sharedID]);
        }
        public void Add_MakesItemInfoAvailable()
        {
            var repo = new RepositorySystem();

            var itemA = Substitute.For <IItemInfo>();

            itemA.ID = 1;
            var itemB = Substitute.For <IItemInfo>();

            itemB.ID = 2;

            repo.Add(itemA);
            repo.Add(itemB);

            Assert.AreEqual(itemA, repo[itemA.ID]);
            Assert.AreEqual(itemB, repo[itemB.ID]);
        }
        public void Count_ReturnsNumberOfItems()
        {
            var repo = new RepositorySystem();

            var itemA = Substitute.For <IItemInfo>();

            itemA.ID = 1;
            var itemB = Substitute.For <IItemInfo>();

            itemB.ID = 2;

            repo.Add(itemA);
            Assert.AreEqual(1, repo.Count);
            repo.Add(itemB);
            Assert.AreEqual(2, repo.Count);
            repo.Clear();
            Assert.AreEqual(0, repo.Count);
        }
        public void AddRange_AddsOrOverwritesFullList()
        {
            var sharedID = 1;
            var uniqueID = 2;
            var repo     = new RepositorySystem();

            var itemA = Substitute.For <IItemInfo>();

            itemA.ID = sharedID;
            var itemB = Substitute.For <IItemInfo>();

            itemB.ID = sharedID;
            var itemC = Substitute.For <IItemInfo>();

            itemC.ID = uniqueID;

            repo.Add(itemA);
            repo.Add(itemB);
            repo.Add(itemC);

            Assert.AreEqual(itemB, repo[sharedID]);
            Assert.AreEqual(itemC, repo[uniqueID]);
        }