public void Add_RequestForAddItem_AddNewItem()
        {
            GroupSettingsContainer groupSettingsStub = null;

            SpaceSize expectedSize = new SpaceSize()
            {
                TotalSize = 100, FreeSize = 30, UsedSize = 70
            };

            var forAdd = new Container()
            {
                Name     = "Container1",
                IsActive = true,
                Items    = new List <IGroupTreeItem>()
                {
                    new Container()
                    {
                        Name = "Container2", Size = new SpaceSize()
                    },
                    new Group()
                    {
                        Name = "Group2", Size = expectedSize
                    }
                },
                Size = expectedSize
            };

            var expectedContainer = new ContainerProjection(new Container()
            {
                Name  = "Root",
                Size  = expectedSize,
                Items = new List <IGroupTreeItem>()
                {
                    forAdd
                }
            });

            _mockService.Setup(settings => settings.LoadGroupTree()).Returns(groupSettingsStub);
            _groupContainerStub = new UnityContainer();
            _groupContainerStub.RegisterInstance <IGroupSettings>(_mockService.Object);
            _groupContainerStub.RegisterInstance <IAccountRegistry>(_accountRegistryStub.Object);
            _groupContainerStub.RegisterType <IContainer, Container>(new InjectionConstructor());
            _groupContainerStub.RegisterType <IGroup, Group>(new InjectionConstructor());

            GroupTreeRegistry registry = new GroupTreeRegistry(_groupContainerStub);

            registry.Initialization();
            registry.Add(new List <string>(), forAdd);

            IContainerProjection rootProjection = registry.GetContainerProjection(new List <string>(), null);

            Assert.IsTrue(expectedContainer.Equals(rootProjection));
        }
        public void SetActive_RequestForSetActive_SetActiveState()
        {
            var groupSettingsStub = new GroupSettingsContainer()
            {
                Name  = "Root",
                Items = new List <GroupSettingsItem>()
                {
                    new GroupSettingsContainer()
                    {
                        Name  = "Container1",
                        Items = new List <GroupSettingsItem>()
                        {
                            new GroupSettingsContainer()
                            {
                                Name = "Container2"
                            },
                            new GroupSettingsGroup()
                            {
                                Name = "Group2", Items = new List <string>()
                                {
                                    "Account1"
                                }
                            }
                        },
                        IsActive = true
                    },
                    new GroupSettingsGroup()
                    {
                        Name = "Group", Items = new List <string>()
                        {
                            "Account1"
                        }
                    }
                }
            };
            SpaceSize expectedSize = new SpaceSize()
            {
                TotalSize = 100, FreeSize = 80, UsedSize = 20
            };

            var expectedContainer = new ContainerProjection(new Container()
            {
                Name  = "Root",
                Size  = expectedSize,
                Items = new List <IGroupTreeItem>()
                {
                    new Container()
                    {
                        Name     = "Container1",
                        IsActive = false,
                        Items    = new List <IGroupTreeItem>()
                        {
                            new Container()
                            {
                                Name = "Container2", Size = new SpaceSize()
                            },
                            new Group()
                            {
                                Name = "Group2", Size = expectedSize, Items = new List <IAccountProjection>()
                                {
                                    _accountStub.Object
                                }
                            }
                        },
                        Size = expectedSize
                    },
                    new Group()
                    {
                        Name = "Group", Size = expectedSize, Items = new List <IAccountProjection>()
                        {
                            _accountStub.Object
                        }
                    },
                }
            });

            _mockService.Setup(settings => settings.LoadGroupTree()).Returns(groupSettingsStub);
            _accountRegistryStub.Setup(accountRegistry => accountRegistry.Find("Account1")).Returns(_accountStub.Object);
            _accountStub.SetupGet(accountProjection => accountProjection.Size).Returns(() => expectedSize);
            _accountStub.SetupGet(accountProjection => accountProjection.Login).Returns(() => "Account1");

            _groupContainerStub = new UnityContainer();
            _groupContainerStub.RegisterInstance <IGroupSettings>(_mockService.Object);
            _groupContainerStub.RegisterInstance <IAccountRegistry>(_accountRegistryStub.Object);
            _groupContainerStub.RegisterType <IContainer, Container>(new InjectionConstructor());
            _groupContainerStub.RegisterType <IGroup, Group>(new InjectionConstructor());

            GroupTreeRegistry registry = new GroupTreeRegistry(_groupContainerStub);

            registry.Initialization();
            registry.SetActive(new List <string>(), "Container1", false);

            IContainerProjection rootProjection = registry.GetContainerProjection(new List <string>(), null);

            Assert.IsTrue(expectedContainer.Equals(rootProjection));
        }