Ejemplo n.º 1
0
        public void WhenIRenameTheFolderFolderToRenameTo(string p0)
        {
            var environmentModel = EnvironmentRepository.Instance.FindSingle(model => model.Name == "localhost");
            ServerExplorerClientProxy repository = new ServerExplorerClientProxy(environmentModel.Connection);
            var result = repository.RenameItem(new ServerExplorerItem("FolderToRename", Guid.NewGuid(), ResourceType.Folder, null, Permissions.Administrator, "FolderToRename"), p0, Guid.Empty);

            Assert.AreEqual(result.Status, ExecStatus.Success);
            var explorerItemModel = repository.Load(Guid.Empty);

            ScenarioContext.Current.Add("localhost", explorerItemModel);
            ScenarioContext.Current.Add("newName", explorerItemModel);
        }
Ejemplo n.º 2
0
        public void WhenIRenameTheFolderTo(string folderToRename, string newName)
        {
            var environmentModel = EnvironmentRepository.Instance.FindSingle(model => model.Name == "localhost");
            ServerExplorerClientProxy repository = new ServerExplorerClientProxy(environmentModel.Connection);
            var result = repository.RenameItem(new ServerExplorerItem(folderToRename, Guid.NewGuid(), Common.Interfaces.Data.ResourceType.Folder, null, Permissions.Administrator, ""), newName, Guid.Empty);

            Assert.AreEqual(ExecStatus.Success, result.Status, "Rename failed: " + result.Message);
            var explorerItemModel = repository.Load(Guid.Empty);

            ScenarioContext.Current.Add("localhost", explorerItemModel);
            ScenarioContext.Current.Add("newName", explorerItemModel);
            ScenarioContext.Current.Add("folderName", newName);
        }
Ejemplo n.º 3
0
        public void ThenTheExplorerTreeForWillHave(string p0, Table table)
        {
            var allItems = new List <ExplorerItemModel>();

            foreach (var tableRow in table.Rows)
            {
                var parentName = tableRow["Parent"];
                var childName  = tableRow["Child"];
                var type       = tableRow["Type"];

                ResourceType resourceType;
                Enum.TryParse(type, out resourceType);
                var eim = new ExplorerItemModel
                {
                    DisplayName  = childName,
                    Children     = new ObservableCollection <IExplorerItemModel>(),
                    ResourceType = resourceType
                };

                var explorerItemModel = allItems.FirstOrDefault(model => model.DisplayName == parentName);
                if (explorerItemModel != null)
                {
                    explorerItemModel.Children.Add(eim);
                }
                allItems.Add(eim);
            }
            var folderName = ScenarioContext.Current.Get <string>("folderName");


            var itemModel = ScenarioContext.Current.Get <IExplorerItem>("localhost");
            var folder    = itemModel.Children.FirstOrDefault(a => a.DisplayName == folderName);

            Assert.IsNotNull(folder);
            Assert.AreEqual(itemModel.DisplayName, Environment.MachineName);
            Assert.AreEqual(folder.DisplayName, allItems[0].Children[0].DisplayName);
            Assert.AreEqual(folder.Children.Count, allItems[0].Children[0].Children.Count);
            // assert that the test directory exists
            foreach (var explorerItemModel in folder.Children)
            {
                Assert.IsTrue(allItems[0].Children[0].Children.Count(a => a.ResourceType == explorerItemModel.ResourceType && a.DisplayName == explorerItemModel.DisplayName) == 1);
            }

            var environmentModel = EnvironmentRepository.Instance.FindSingle(model => model.Name == "localhost");
            ServerExplorerClientProxy repository = new ServerExplorerClientProxy(environmentModel.Connection);

            repository.RenameItem(new ServerExplorerItem("FolderToRename", Guid.NewGuid(), ResourceType.Folder, null, Permissions.Administrator, "FolderToRename"), p0, Guid.Empty);
        }
Ejemplo n.º 4
0
        public void WhenIRenameTheResourcePrimitiveReturnTypeTestTo(string p0)
        {
            var environmentModel = EnvironmentRepository.Instance.FindSingle(model => model.Name == "localhost");
            ServerExplorerClientProxy repository = new ServerExplorerClientProxy(environmentModel.Connection);
            var item = repository.Load(Guid.Empty)
                       .Children.First(a => a.DisplayName == "ExplorerSpecsRenameItem")
                       .Children.First();


            var result = repository.RenameItem(item, "BobAndDora", Guid.Empty);

            Assert.AreEqual(result.Status, ExecStatus.Success);
            var explorerItemModel = repository.Load(Guid.Empty);

            ScenarioContext.Current.Add("localhost", explorerItemModel);
            ScenarioContext.Current.Add("newName", explorerItemModel);
        }
Ejemplo n.º 5
0
        public void WhenIRenameTheResourceTo(string itemToRename, string p1)
        {
            var environmentModel = EnvironmentRepository.Instance.FindSingle(model => model.Name == "localhost");
            ServerExplorerClientProxy repository = new ServerExplorerClientProxy(environmentModel.Connection);
            var item = repository.Load(Guid.Empty)
                       .Children.First(a => a.DisplayName == "ExplorerSpecsRenameItem")
                       .Children.FirstOrDefault(a => a.DisplayName == itemToRename);

            item.DisplayName = p1;

            var result = repository.RenameItem(item, p1, Guid.Empty);

            Assert.AreEqual(result.Status, ExecStatus.Success);
            var explorerItemModel = repository.Load(Guid.Empty);

            ScenarioContext.Current.Add("localhost", explorerItemModel);
            ScenarioContext.Current.Add("newName", explorerItemModel);
            ScenarioContext.Current.Add("folderName", "ExplorerSpecsRenameItem");
        }
        public void ClientExplorerRepository_RenameItem_ExpectRenameServiceCalled()
        {
            //------------Setup for test--------------------------
            var env        = new Mock <IEnvironmentConnection>();
            var comFactory = new Mock <ICommunicationControllerFactory>();
            var rep        = new ServerExplorerClientProxy(env.Object, comFactory.Object);
            var com        = new Mock <ICommunicationController>();
            var item       = new ServerExplorerItem("", Guid.Empty, ResourceType.DbService, null, Permissions.Contribute, "f");

            comFactory.Setup(a => a.CreateController("RenameItemService")).Returns(com.Object).Verifiable();
            com.Setup(a => a.ExecuteCommand <IExplorerItem>(env.Object, Guid.Empty)).Returns(item).Verifiable();

            //------------Execute Test---------------------------
            rep.RenameItem(item, "bob", Guid.Empty);
            //------------Assert Results-------------------------

            comFactory.Verify(a => a.CreateController("RenameItemService"));
            com.Verify(a => a.ExecuteCommand <IExplorerRepositoryResult>(env.Object, Guid.Empty));
            com.Verify(a => a.AddPayloadArgument("itemToRename", It.IsAny <string>()));
            com.Verify(a => a.AddPayloadArgument("newName", "bob"));
            com.Verify(a => a.ExecuteCommand <IExplorerRepositoryResult>(env.Object, Guid.Empty));
        }