本文整理汇总了C#中Dev2.Models.ExplorerItemModel类的典型用法代码示例。如果您正苦于以下问题:C# ExplorerItemModel类的具体用法?C# ExplorerItemModel怎么用?C# ExplorerItemModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExplorerItemModel类属于Dev2.Models命名空间,在下文中一共展示了ExplorerItemModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateModels
protected StudioResourceRepository CreateModels(bool isChecked, Mock<IContextualResourceModel> mockResourceModel, out IEnvironmentModel environmentModel, out IExplorerItemModel resourceVm, out IExplorerItemModel rootItem)
{
Mock<IContextualResourceModel> resourceModel = mockResourceModel;
var connection = new Mock<IEnvironmentConnection>();
var mockEnvironmentModel = new Mock<IEnvironmentModel>();
mockEnvironmentModel.Setup(e => e.Connection).Returns(connection.Object);
mockEnvironmentModel.Setup(a => a.AuthorizationService).Returns(new Mock<IAuthorizationService>().Object);
environmentModel = Dev2MockFactory.SetupEnvironmentModel(resourceModel, new List<IResourceModel>()).Object;
var serverItemModel = new ExplorerItemModel { DisplayName = "localhost", ResourceType = ResourceType.Server, EnvironmentId = environmentModel.ID, ResourcePath = "", ResourceId = Guid.NewGuid() };
rootItem = serverItemModel;
ExplorerItemModel workflowsFolder = new ExplorerItemModel { DisplayName = "WORKFLOWS", ResourceType = ResourceType.Folder, ResourcePath = "WORKFLOWS", EnvironmentId = mockEnvironmentModel.Object.ID, ResourceId = Guid.NewGuid() };
serverItemModel.Children.Add(workflowsFolder);
var studioResourceRepository = new StudioResourceRepository(serverItemModel, _Invoke);
resourceModel.Setup(model => model.Category).Returns("WORKFLOWS\\" + resourceModel.Object.DisplayName);
TestEnvironmentRespository testEnvironmentRespository = new TestEnvironmentRespository(environmentModel);
// ReSharper disable ObjectCreationAsStatement
new EnvironmentRepository(testEnvironmentRespository);
// ReSharper restore ObjectCreationAsStatement
IEnvironmentModel internalEnvironmentModel = environmentModel;
studioResourceRepository.GetCurrentEnvironment = () => internalEnvironmentModel.ID;
studioResourceRepository.AddResouceItem(resourceModel.Object);
resourceVm = workflowsFolder.Children[0];
resourceVm.IsChecked = isChecked;
return studioResourceRepository;
}
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:29,代码来源:DeployStatsCalculatorTests.cs
示例2: EnvironmentTreeViewModel_PermissionsChanged_DeployToTrue_ChildrenIsNotCleared
public void EnvironmentTreeViewModel_PermissionsChanged_DeployToTrue_ChildrenIsNotCleared()
{
var connection = CreateConnection();
connection.Setup(c => c.IsAuthorized).Returns(true);
var authorizationService = new Mock<IAuthorizationService>();
authorizationService.Setup(e => e.IsAuthorized(AuthorizationContext.DeployTo, null)).Returns(true);
var mockEnvironmentModel = new Mock<IEnvironmentModel>();
mockEnvironmentModel.SetupGet(x => x.Connection.AppServerUri).Returns(new Uri("http://127.0.0.1/"));
mockEnvironmentModel.Setup(model => model.Equals(It.IsAny<IEnvironmentModel>())).Returns(true);
mockEnvironmentModel.Setup(e => e.IsAuthorized).Returns(true);
mockEnvironmentModel.Setup(model => model.AuthorizationService).Returns(authorizationService.Object);
mockEnvironmentModel.Setup(model => model.Connection).Returns(connection.Object);
var environmentVm = new ExplorerItemModel(new Mock<IConnectControlSingleton>().Object, StudioResourceRepository.Instance);
var child = new Mock<IExplorerItemModel>().Object;
environmentVm.Children.Add(child);
environmentVm.Children.Add(child);
environmentVm.Children.Add(child);
authorizationService.Setup(e => e.IsAuthorized(AuthorizationContext.DeployTo, null)).Returns(true);
connection.Raise(c => c.PermissionsChanged += null, EventArgs.Empty);
Assert.AreEqual(3, environmentVm.Children.Count);
}
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:25,代码来源:EnvironmentTreeViewModelTests.cs
示例3: ExplorerItemModel_Constructor_HasChildrenCollectionInstantiated
public void ExplorerItemModel_Constructor_HasChildrenCollectionInstantiated()
{
//------------Setup for test--------------------------
//------------Execute Test---------------------------
var explorerItemModel = new ExplorerItemModel(new Mock<IConnectControlSingleton>().Object, new Mock<IStudioResourceRepository>().Object);
//------------Assert Results-------------------------
Assert.IsNotNull(explorerItemModel);
Assert.IsNotNull(explorerItemModel.Children);
Assert.AreEqual(0, explorerItemModel.ChildrenCount);
}
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:10,代码来源:ExplorerItemModelTest.cs
示例4: StudioResourceRepository
//This is for testing only need better way of putting this together
internal StudioResourceRepository(ExplorerItemModel explorerItem, Action<System.Action, DispatcherPriority> invoke)
{
ExplorerItemModelClone = a => a.Clone();
ExplorerItemModels = new ObservableCollection<IExplorerItemModel>();
_invoke = invoke;
if(explorerItem != null)
{
LoadItemsToTree(explorerItem.EnvironmentId, explorerItem);
Instance = this;
}
}
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:12,代码来源:StudioResourceRepository.cs
示例5: DeployStatsCalculator_Calculate_HasFolders_Expect_NoFoldersCounted
public void DeployStatsCalculator_Calculate_HasFolders_Expect_NoFoldersCounted()
{
//------------Setup for test--------------------------
var conn = new Mock<IConnectControlSingleton>().Object;
var studio = new Mock<IStudioResourceRepository>().Object;
ExplorerItemModel navigationItemViewModel = new ExplorerItemModel(conn,studio){ResourceType = ResourceType.Folder,IsChecked = true};
IEnvironmentModel environmentModel = Dev2MockFactory.SetupEnvironmentModel().Object;
bool actual = DeployStatsCalculator.DeploySummaryPredicateNew(navigationItemViewModel, environmentModel);
Assert.IsFalse(actual);
}
开发者ID:Robin--,项目名称:Warewolf,代码行数:11,代码来源:DeployStatsCalculatorTests.cs
示例6: ExplorerView_Move_FolderExpectRename
// ReSharper disable once InconsistentNaming
public void ExplorerView_Move_FolderExpectRename()
{
//------------Setup for test--------------------------
var stud = new Mock<IStudioResourceRepository>();
var model1 = new ExplorerItemModel(new Mock<IConnectControlSingleton>().Object, new Mock<IStudioResourceRepository>().Object) { ResourceType = ResourceType.Folder, ResourcePath = "bob" };
var model2 = new ExplorerItemModel(new Mock<IConnectControlSingleton>().Object, new Mock<IStudioResourceRepository>().Object) { ResourceType = ResourceType.Folder, ResourcePath = "dave", Parent = new ExplorerItemModel(new Mock<IConnectControlSingleton>().Object, new Mock<IStudioResourceRepository>().Object) { ResourcePath = "moo" } };
stud.Setup(a => a.MoveItem(model1, "bob"));
ExplorerView.MoveItem(model1, model2, stud.Object);
//------------Execute Test---------------------------
stud.Verify(a => a.MoveItem(model1, "dave"));
//------------Assert Results-------------------------
}
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:14,代码来源:ExplorereViewTests.cs
示例7: ExplorerItemModel_Constructor_Has4ChildrenCount
public void ExplorerItemModel_Constructor_Has4ChildrenCount()
{
//------------Setup for test--------------------------
//------------Execute Test---------------------------
var connectControlSingleton = new Mock<IConnectControlSingleton>().Object;
var explorerItemModel = new ExplorerItemModel(connectControlSingleton, new Mock<IStudioResourceRepository>().Object);
explorerItemModel.Children.Add(new ExplorerItemModel(connectControlSingleton, new Mock<IStudioResourceRepository>().Object) { ResourceType = ResourceType.WorkflowService });
explorerItemModel.Children.Add(new ExplorerItemModel(connectControlSingleton, new Mock<IStudioResourceRepository>().Object) { ResourceType = ResourceType.WorkflowService });
explorerItemModel.Children.Add(new ExplorerItemModel(connectControlSingleton, new Mock<IStudioResourceRepository>().Object) { ResourceType = ResourceType.WorkflowService });
explorerItemModel.Children.Add(new ExplorerItemModel(connectControlSingleton, new Mock<IStudioResourceRepository>().Object) { ResourceType = ResourceType.WorkflowService });
//------------Assert Results-------------------------
Assert.IsNotNull(explorerItemModel);
Assert.IsNotNull(explorerItemModel.Children);
Assert.AreEqual(4, explorerItemModel.ChildrenCount);
}
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:15,代码来源:ExplorerItemModelTest.cs
示例8: DragDropHelpers_PreventDrop_DataContextViewModelSameEnvironmentID_ReturnsFalse
public void DragDropHelpers_PreventDrop_DataContextViewModelSameEnvironmentID_ReturnsFalse()
{
//------------Setup for test--------------------------
var environmentMock = new Mock<IEnvironmentModel>();
Guid guid = Guid.NewGuid();
environmentMock.Setup(model => model.ID).Returns(guid);
var data = new ExplorerItemModel(new Mock<IConnectControlSingleton>().Object, new Mock<IStudioResourceRepository>().Object) { Permissions = Permissions.Execute, ResourceType = ResourceType.DbService, EnvironmentId = environmentMock.Object.ID };
var dataContext = new Mock<IWorkflowDesignerViewModel>();
dataContext.Setup(model => model.EnvironmentModel).Returns(environmentMock.Object);
var dragDropHelpers = new DragDropHelpers(GetMockWorkflowDesignerView(dataContext.Object));
//------------Execute Test---------------------------
bool canDoDrop = dragDropHelpers.PreventDrop(GetMockDataObjectWithFormatData(new[] { "ExplorerItemModel" }, data));
//------------Assert Results-------------------------
Assert.IsFalse(canDoDrop);
}
开发者ID:Robin--,项目名称:Warewolf,代码行数:15,代码来源:DragDropHelpersTests.cs
示例9: ExplorerView_Move_FolderExpectPopup
// ReSharper disable once InconsistentNaming
public void ExplorerView_Move_FolderExpectPopup()
{
//------------Setup for test--------------------------
var stud = new Mock<IStudioResourceRepository>();
var popup = new Mock<IPopupController>();
CustomContainer.Register(popup.Object);
var model1 = new ExplorerItemModel(new Mock<IConnectControlSingleton>().Object, new Mock<IStudioResourceRepository>().Object) { ResourceType = ResourceType.Folder, ResourcePath = "bob",EnvironmentId = Guid.NewGuid()};
var model2 = new ExplorerItemModel(new Mock<IConnectControlSingleton>().Object, new Mock<IStudioResourceRepository>().Object) { ResourceType = ResourceType.Folder, ResourcePath = "dave", Parent = new ExplorerItemModel(new Mock<IConnectControlSingleton>().Object, new Mock<IStudioResourceRepository>().Object) { ResourcePath = "moo" } };
stud.Setup(a => a.MoveItem(model1, "bob"));
ExplorerView.MoveItem(model1, model2, stud.Object);
//------------Execute Test---------------------------
popup.Verify(a=>a.Show());
popup.VerifySet(a => a.Description = "You are not allowed to move items between Servers using the explorer. Please use the deploy instead");
//------------Assert Results-------------------------
}
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:17,代码来源:ExplorereViewTests.cs
示例10: MoveItem
public static void MoveItem(ExplorerItemModel source, ExplorerItemModel destination, IStudioResourceRepository rep)
{
if (source != null)
{
if(source.EnvironmentId != destination.EnvironmentId)
{
var popup = CustomContainer.Get<IPopupController>();
popup.Description = "You are not allowed to move items between Servers using the explorer. Please use the deploy instead";
popup.Buttons = MessageBoxButton.OK;
popup.Header = "Invalid Action";
popup.ImageType = MessageBoxImage.Error;
popup.Show();
}
else
switch (destination.ResourceType)
{
case ResourceType.Folder:
case ResourceType.Server:
rep.MoveItem(source, destination.ResourcePath);
break;
default:
rep.MoveItem(source, destination.Parent.ResourcePath);
break;
}
}
}
开发者ID:Robin--,项目名称:Warewolf,代码行数:27,代码来源:ExplorerView.xaml.cs
示例11: StudioResourceRepository_DeleteItem_ItemParentNull_Exception
public void StudioResourceRepository_DeleteItem_ItemParentNull_Exception()
{
//------------Setup for test--------------------------
var _propertyChangedCalled = false;
var mockExplorerResourceRepository = new Mock<IClientExplorerResourceRepository>();
mockExplorerResourceRepository.Setup(m => m.DeleteItem(It.IsAny<IExplorerItem>(), It.IsAny<Guid>()))
.Returns(new ExplorerRepositoryResult(ExecStatus.Success, "Success"))
.Verifiable();
var environmentId = Guid.NewGuid();
var workflowId = Guid.NewGuid();
var folderID = Guid.NewGuid();
SetupEnvironmentRepo(environmentId);
var mockVersionRepository = new Mock<IVersionRepository>();
var repository = new StudioResourceRepository(GetTestData(workflowId.ToString(), folderID: folderID), environmentId, _invoke)
{
GetVersionProxy = id => mockVersionRepository.Object,
GetExplorerProxy = id => mockExplorerResourceRepository.Object
};
var folderItem = repository.FindItemById(folderID);
ExplorerItemModel item = folderItem.Parent as ExplorerItemModel;
// ReSharper disable PossibleNullReferenceException
item.PropertyChanged += (sender, args) =>
// ReSharper restore PossibleNullReferenceException
{
if(args.PropertyName == "ChildrenCount")
{
_propertyChangedCalled = true;
}
};
//------------Execute Test---------------------------
ExplorerItemModel explorerItemModel = new ExplorerItemModel();
repository.DeleteItem(explorerItemModel);
//------------Assert Results-------------------------
Assert.IsFalse(_propertyChangedCalled);
}
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:38,代码来源:StudioResourceRepositoryTests.cs
示例12: DragDropHelpers_PreventDrop_UserIsAuthorized_False
public void DragDropHelpers_PreventDrop_UserIsAuthorized_False()
{
//------------Setup for test--------------------------
var data = new ExplorerItemModel(new Mock<IConnectControlSingleton>().Object, new Mock<IStudioResourceRepository>().Object) { Permissions = Permissions.Execute, ResourceType = ResourceType.WorkflowService };
var dataContext = new Mock<IWorkflowDesignerViewModel>();
var differentEnvironment = new Mock<IEnvironmentModel>();
differentEnvironment.Setup(model => model.ID).Returns(Guid.Empty);
dataContext.Setup(model => model.EnvironmentModel).Returns(differentEnvironment.Object);
var dragDropHelpers = new DragDropHelpers(GetMockWorkflowDesignerView(dataContext.Object));
//------------Execute Test---------------------------
var canDoDrop = dragDropHelpers.PreventDrop(GetMockDataObjectWithFormatData(new[] { "ExplorerItemModel" }, data));
//------------Assert Results-------------------------
Assert.IsFalse(canDoDrop);
}
开发者ID:Robin--,项目名称:Warewolf,代码行数:17,代码来源:DragDropHelpersTests.cs
示例13: CreateModels
protected static StudioResourceRepository CreateModels(bool isChecked, IEnvironmentModel environmentModel, out IExplorerItemModel resourceVm)
{
Mock<IContextualResourceModel> resourceModel = Dev2MockFactory.SetupResourceModelMock(ResourceType.WorkflowService, Guid.NewGuid());
var serverItemModel = new ExplorerItemModel { DisplayName = "localhost", ResourceType = Common.Interfaces.Data.ResourceType.Server, EnvironmentId = environmentModel.ID, ResourceId = Guid.NewGuid(), ResourcePath = "" };
ExplorerItemModel workflowsFolder = new ExplorerItemModel { DisplayName = "WORKFLOWS", ResourceType = Common.Interfaces.Data.ResourceType.Folder, ResourcePath = "WORKFLOWS", ResourceId = Guid.NewGuid(), EnvironmentId = environmentModel.ID };
serverItemModel.Children.Add(workflowsFolder);
var studioResourceRepository = new StudioResourceRepository(serverItemModel, Invoke);
resourceModel.Setup(model => model.Category).Returns("WORKFLOWS\\" + resourceModel.Object.DisplayName);
resourceModel.Setup(a => a.ServerID).Returns(environmentModel.ID);
var env = new Mock<IEnvironmentModel>();
resourceModel.Setup(a => a.Environment).Returns(env.Object);
env.Setup(a => a.ID).Returns(environmentModel.ID);
TestEnvironmentRespository testEnvironmentRespository = new TestEnvironmentRespository(environmentModel);
// ReSharper disable ObjectCreationAsStatement
new EnvironmentRepository(testEnvironmentRespository);
// ReSharper restore ObjectCreationAsStatement
IEnvironmentModel internalEnvironmentModel = environmentModel;
studioResourceRepository.GetCurrentEnvironment = () => internalEnvironmentModel.ID;
studioResourceRepository.AddResouceItem(resourceModel.Object);
resourceVm = workflowsFolder.Children[0];
resourceVm.IsChecked = isChecked;
return studioResourceRepository;
}
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:27,代码来源:DeployViewModelTestBase.cs
示例14: TestNavigationItemViewModelMouseDownBehavior
public void NavigationItemViewModelMouseDownBehavior_OnMouseDown_OpenOnDoubleClickIsTrueAndClickCountIsOne_PublishesEvent()
{
//------------Setup for test--------------------------
var eventPublisher = new Mock<IEventAggregator>();
var behavior = new TestNavigationItemViewModelMouseDownBehavior(eventPublisher.Object) { OpenOnDoubleClick = true };
var connection = new Mock<IEnvironmentConnection>();
connection.Setup(c => c.ServerEvents).Returns(new Mock<IEventPublisher>().Object);
var environmentModel = new Mock<IEnvironmentModel>();
environmentModel.Setup(e => e.Connection).Returns(connection.Object);
var resourceModel = new Mock<IContextualResourceModel>();
resourceModel.Setup(r => r.Environment).Returns(environmentModel.Object);
resourceModel.Setup(r => r.IsAuthorized(AuthorizationContext.View)).Returns(true);
var explorerItemModel = new ExplorerItemModel(new Mock<IStudioResourceRepository>().Object, new Mock<IAsyncWorker>().Object, new Mock<IConnectControlSingleton>().Object);
//------------Execute Test---------------------------
var result = behavior.TestOnMouseDown(explorerItemModel, 1);
//------------Assert Results-------------------------
Assert.IsTrue(result);
}
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:23,代码来源:NavigationItemViewModelMouseDownBehaviorTests.cs
示例15: Verify_OnMouseDown_SelectOnRightClick
static void Verify_OnMouseDown_SelectOnRightClick(bool selectOnRightClick)
{
//------------Setup for test--------------------------
var eventPublisher = new Mock<IEventAggregator>();
var behavior = new TestNavigationItemViewModelMouseDownBehavior(eventPublisher.Object) { SelectOnRightClick = selectOnRightClick };
var explorerItemModel = new ExplorerItemModel(new Mock<IStudioResourceRepository>().Object, new Mock<IAsyncWorker>().Object, new Mock<IConnectControlSingleton>().Object);
//------------Execute Test---------------------------
var result = behavior.TestOnMouseDown(explorerItemModel, 1);
//------------Assert Results-------------------------
Assert.IsTrue(result);
Assert.AreEqual(selectOnRightClick, explorerItemModel.IsExplorerSelected);
}
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:15,代码来源:NavigationItemViewModelMouseDownBehaviorTests.cs
示例16: WhenIDeleteTheResource
public void WhenIDeleteTheResource(string resourceToDelete)
{
var localhost = Guid.Empty;
ExecuteService(() =>
{
var repository = ScenarioContext.Current.Get<StudioResourceRepository>("repository");
repository.Load(localhost, new TestAsyncWorker());
var resourcePath = ScenarioContext.Current.Get<string>("path");
var displayName = resourcePath.Split("\\".ToArray()).Last();
var parent = repository.FindItem(i => i.DisplayName == displayName);
Assert.IsNotNull(parent,string.Format("Did not find {0}", displayName));
var child = parent.Children.FirstOrDefault(c => c.DisplayName == resourceToDelete);
if(child == null)
{
child = new ExplorerItemModel
{
Parent = parent,
DisplayName = resourceToDelete,
ResourcePath = resourcePath + "\\" + resourceToDelete,
Permissions = SecPermissions.Contribute
};
parent.Children.Add(child);
}
string errorMessage = "";
var hasError = false;
try
{
repository.DeleteFolder(child);
}
catch(Exception exception)
{
errorMessage = exception.Message;
hasError = true;
}
ScenarioContext.Current.Add("errorMessage", errorMessage);
ScenarioContext.Current.Add("hasError", hasError);
});
}
开发者ID:ndubul,项目名称:Chillas,代码行数:43,代码来源:ExplorerSteps.cs
示例17: WhenIRenameTheResourceTo
public void WhenIRenameTheResourceTo(string oldResourceName, string newResourceName)
{
var workingDirectory = ScenarioContext.Current.Get<string>("workingDirectory");
var resourceName = workingDirectory + @"\" + oldResourceName;
var extension = Path.GetExtension(resourceName);
if(string.IsNullOrEmpty(extension))
{
Directory.CreateDirectory(resourceName);
}
else
{
File.Create(resourceName);
}
var localhost = Guid.Empty;
ExecuteService(() =>
{
var repository = ScenarioContext.Current.Get<StudioResourceRepository>("repository");
repository.Load(localhost, new TestAsyncWorker());
var resourcePath = ScenarioContext.Current.Get<string>("path");
var displayName = resourcePath.Split("\\".ToArray()).Last();
var parent = repository.FindItem(i => i.DisplayName == displayName);
if(parent.Children != null)
{
var child = parent.Children.FirstOrDefault(c => c.DisplayName == oldResourceName);
var hasError = false;
if(child == null)
{
child = new ExplorerItemModel
{
Parent = parent,
DisplayName = oldResourceName,
ResourcePath = resourcePath + "\\" + displayName,
Permissions = SecPermissions.Contribute
};
parent.Children.Add(child);
}
string errorMessage = "";
try
{
repository.RenameItem(child, resourcePath + "\\" + newResourceName);
}
catch(Exception exception)
{
errorMessage = exception.Message;
hasError = true;
}
ScenarioContext.Current.Add("errorMessage", errorMessage);
ScenarioContext.Current.Add("hasError", hasError);
}
});
}
开发者ID:ndubul,项目名称:Chillas,代码行数:57,代码来源:ExplorerSteps.cs
示例18: Verify_OnMouseDown_SetActiveEnvironmentOnClick
static void Verify_OnMouseDown_SetActiveEnvironmentOnClick(int publishCount, bool setActiveEnvironmentOnClick)
{
//------------Setup for test--------------------------
var eventPublisher = new Mock<IEventAggregator>();
eventPublisher.Setup(p => p.Publish(It.IsAny<SetActiveEnvironmentMessage>())).Verifiable();
var behavior = new TestNavigationItemViewModelMouseDownBehavior(eventPublisher.Object) { SetActiveEnvironmentOnClick = setActiveEnvironmentOnClick };
var explorerItemModel = new ExplorerItemModel(new Mock<IStudioResourceRepository>().Object, new Mock<IAsyncWorker>().Object, new Mock<IConnectControlSingleton>().Object);
//------------Execute Test---------------------------
var result = behavior.TestOnMouseDown(explorerItemModel, 1);
//------------Assert Results-------------------------
Assert.IsTrue(result);
eventPublisher.Verify(p => p.Publish(It.IsAny<SetActiveEnvironmentMessage>()), Times.Exactly(publishCount));
}
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:17,代码来源:NavigationItemViewModelMouseDownBehaviorTests.cs
示例19: WorkflowDesignerViewModelTestStartNodeNotDoubleConnect
public void WorkflowDesignerViewModelTestStartNodeNotDoubleConnect()
{
#region Setup view model constructor parameters
var repo = new Mock<IResourceRepository>();
var env = EnviromentRepositoryTest.CreateMockEnvironment();
env.Setup(e => e.ResourceRepository).Returns(repo.Object);
var crm = new Mock<IContextualResourceModel>();
crm.Setup(r => r.Environment).Returns(env.Object);
crm.Setup(r => r.ResourceName).Returns("Test");
crm.Setup(res => res.WorkflowXaml).Returns(new StringBuilder(StringResourcesTest.xmlServiceDefinition));
//, new Mock<IWizardEngine>().Object
var explorerItem = new ExplorerItemModel();
IContextualResourceModel contextualResourceModel = crm.Object;
explorerItem.DisplayName = contextualResourceModel.ResourceName;
explorerItem.EnvironmentId = contextualResourceModel.Environment.ID;
var wh = new Mock<IWorkflowHelper>();
#endregion
#region setup Mock ModelItem
var properties = new Dictionary<string, Mock<ModelProperty>>();
var propertyCollection = new Mock<ModelPropertyCollection>();
var environmentRepository = SetupEnvironmentRepo(Guid.Empty); // Set the active environment
var testAct = DsfActivityFactory.CreateDsfActivity(contextualResourceModel, new DsfActivity(), true, environmentRepository, true);
var prop = new Mock<ModelProperty>();
prop.Setup(p => p.SetValue(It.IsAny<DsfActivity>())).Verifiable();
prop.Setup(p => p.ComputedValue).Returns(testAct);
properties.Add("Action", prop);
propertyCollection.Protected().Setup<ModelProperty>("Find", "Action", true).Returns(prop.Object);
var source = new Mock<ModelItem>();
source.Setup(s => s.Properties).Returns(propertyCollection.Object);
source.Setup(s => s.ItemType).Returns(typeof(FlowStep));
#endregion
#region setup mock to change properties
//mock item adding - this is obsolote functionality but not refactored due to overhead
var args = new Mock<ModelChangedEventArgs>();
#pragma warning disable 618
args.Setup(a => a.ItemsAdded).Returns(new List<ModelItem> { source.Object });
#pragma warning restore 618
#endregion
//Execute
var wfd = new WorkflowDesignerViewModelMock(contextualResourceModel, wh.Object);
wfd.SetDataObject(explorerItem);
wfd.TestModelServiceModelChanged(args.Object);
wfd.Dispose();
//Verify
prop.Verify(p => p.SetValue(It.IsAny<DsfActivity>()), Times.Never());
}
开发者ID:Robin--,项目名称:Warewolf,代码行数:62,代码来源:WorkflowDesignerUnitTest.cs
示例20: Verify_OnMouseDown_OpenOnDoubleClick_DoesNothing
static void Verify_OnMouseDown_OpenOnDoubleClick_DoesNothing(int clickCount, bool openOnDoubleClick)
{
//------------Setup for test--------------------------
var eventPublisher = new Mock<IEventAggregator>();
eventPublisher.Setup(p => p.Publish(It.IsAny<object>())).Verifiable();
var behavior = new TestNavigationItemViewModelMouseDownBehavior(eventPublisher.Object) { OpenOnDoubleClick = openOnDoubleClick };
var connection = new Mock<IEnvironmentConnection>();
connection.Setup(c => c.ServerEvents).Returns(new Mock<IEventPublisher>().Object);
var environmentModel = new Mock<IEnvironmentModel>();
environmentModel.Setup(e => e.Connection).Returns(connection.Object);
var resourceModel = new Mock<IContextualResourceModel>();
resourceModel.Setup(r => r.Environment).Returns(environmentModel.Object);
resourceModel.Setup(r => r.IsAuthorized(AuthorizationContext.View)).Returns(true);
var explorerItemModel = new ExplorerItemModel(new Mock<IStudioResourceRepository>().Object, new Mock<IAsyncWorker>().Object, new Mock<IConnectControlSingleton>().Object) { Permissions = Permissions.Administrator };
//------------Execute Test---------------------------
var result = behavior.TestOnMouseDown(explorerItemModel, clickCount);
//------------Assert Results-------------------------
Assert.IsTrue(result);
eventPublisher.Verify(p => p.Publish(It.IsAny<object>()), Times.Never());
}
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:25,代码来源:NavigationItemViewModelMouseDownBehaviorTests.cs
注:本文中的Dev2.Models.ExplorerItemModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论