本文整理汇总了C#中Dev2.Studio.ViewModels.DataList.DataListViewModel.InitializeDataListViewModel方法的典型用法代码示例。如果您正苦于以下问题:C# DataListViewModel.InitializeDataListViewModel方法的具体用法?C# DataListViewModel.InitializeDataListViewModel怎么用?C# DataListViewModel.InitializeDataListViewModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dev2.Studio.ViewModels.DataList.DataListViewModel
的用法示例。
在下文中一共展示了DataListViewModel.InitializeDataListViewModel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDataListViewModel
internal IDataListViewModel CreateDataListViewModel(IResourceModel resourceModel)
{
DataListViewModel dLVM = new DataListViewModel();
dLVM.InitializeDataListViewModel(resourceModel);
return dLVM;
}
示例2: CreateDataListViewModelWithDefaultResourceModel
internal IDataListViewModel CreateDataListViewModelWithDefaultResourceModel() {
TestResourceModel testResourceModel = new TestResourceModel();
IDataListViewModel dataListViewModel = new DataListViewModel();
dataListViewModel.InitializeDataListViewModel(testResourceModel);
return dataListViewModel;
}
示例3: ZipDesignerViewModel_Validate_CorrectFieldsAreValidated
public void ZipDesignerViewModel_Validate_CorrectFieldsAreValidated()
{
//------------Setup for test-------------------------
var dataListViewModel = new DataListViewModel();
dataListViewModel.InitializeDataListViewModel(new ResourceModel(null));
DataListSingleton.SetDataList(dataListViewModel);
var viewModel = ZipViewModel();
//------------Execute Test---------------------------
viewModel.Validate();
//------------Assert Results-------------------------
Assert.AreEqual(1, viewModel.ValidateInputPathHitCount);
Assert.AreEqual(1, viewModel.ValidateUserNameAndPasswordHitCount);
Assert.AreEqual(1, viewModel.ValidateDestinationUsernameAndPasswordHitCount);
}
示例4: Setup
void Setup()
{
//_mockMediatorRepo = new Mock<IMediatorRepo>();
_mockResourceModel = Dev2MockFactory.SetupResourceModelMock();
//_mockMediatorRepo.Setup(c => c.addKey(It.IsAny<Int32>(), It.IsAny<MediatorMessages>(), It.IsAny<String>()));
//_mockMediatorRepo.Setup(c => c.deregisterAllItemMessages(It.IsAny<Int32>()));
_dataListViewModel = new DataListViewModel(new Mock<IEventAggregator>().Object);
_dataListViewModel.InitializeDataListViewModel(_mockResourceModel.Object);
//Mock<IMainViewModel> _mockMainViewModel = Dev2MockFactory.SetupMainViewModel();
_dataListViewModel.RecsetCollection.Clear();
_dataListViewModel.ScalarCollection.Clear();
IDataListItemModel carRecordset = DataListItemModelFactory.CreateDataListModel("Car", "A recordset of information about a car", enDev2ColumnArgumentDirection.Both);
carRecordset.Children.Add(DataListItemModelFactory.CreateDataListModel("Make", "Make of vehicle", carRecordset));
carRecordset.Children.Add(DataListItemModelFactory.CreateDataListModel("Model", "Model of vehicle", carRecordset));
_dataListViewModel.RecsetCollection.Add(carRecordset);
_dataListViewModel.ScalarCollection.Add(DataListItemModelFactory.CreateDataListModel("Country", "name of Country", enDev2ColumnArgumentDirection.Both));
DataListSingleton.SetDataList(_dataListViewModel);
}
示例5: ServiceDesingerViewModel_IsAsyncVisible_NotWorkflowResource_False
public void ServiceDesingerViewModel_IsAsyncVisible_NotWorkflowResource_False()
{
//------------Setup for test--------------------------
var resourceID = Guid.NewGuid();
var resourceModel = CreateResourceModel(Guid.Empty, false);
resourceModel.Setup(model => model.ResourceType).Returns(Studio.Core.AppResources.Enums.ResourceType.Service);
resourceModel.Setup(model => model.DataList).Returns("<DataList><n1/></DataList>");
var dataListViewModel = new DataListViewModel();
dataListViewModel.InitializeDataListViewModel(resourceModel.Object);
dataListViewModel.ScalarCollection.Add(new DataListItemModel("n1"));
DataListSingleton.SetDataList(dataListViewModel);
var rootModel = CreateResourceModel(Guid.Empty);
var envRepository = new Mock<IEnvironmentRepository>();
envRepository.Setup(r => r.FindSingle(It.IsAny<Expression<Func<IEnvironmentModel, bool>>>())).Returns(resourceModel.Object.Environment);
envRepository.Setup(r => r.ActiveEnvironment).Returns(resourceModel.Object.Environment);
var resourceType = resourceModel.Object.ResourceType.ToString();
var activity = new DsfActivity { ResourceID = new InArgument<Guid>(resourceID), EnvironmentID = new InArgument<Guid>(Guid.Empty), UniqueID = Guid.NewGuid().ToString(), SimulationMode = SimulationMode.OnDemand, Type = new InArgument<string>(resourceType) };
var modelItem = CreateModelItem(activity);
//------------Execute Test---------------------------
var viewModel = new ServiceDesignerViewModel(modelItem, rootModel.Object, envRepository.Object, new Mock<IEventAggregator>().Object);
//------------Assert Results-------------------------
Assert.IsFalse(viewModel.IsAsyncVisible);
}
示例6: ServiceDesignerViewModel_InitializeResourceIDNull_StillCorrectlySetsUp
public void ServiceDesignerViewModel_InitializeResourceIDNull_StillCorrectlySetsUp()
{
//------------Setup for test--------------------------
var resourceID = Guid.NewGuid();
var resourceModel = CreateResourceModel(Guid.Empty, false);
resourceModel.Setup(model => model.DataList).Returns("<DataList><n1/></DataList>");
var dataListViewModel = new DataListViewModel();
dataListViewModel.InitializeDataListViewModel(resourceModel.Object);
dataListViewModel.ScalarCollection.Add(new DataListItemModel("n1"));
DataListSingleton.SetDataList(dataListViewModel);
var rootModel = CreateResourceModel(Guid.Empty);
var envRepository = new Mock<IEnvironmentRepository>();
envRepository.Setup(r => r.FindSingle(It.IsAny<Expression<Func<IEnvironmentModel, bool>>>())).Returns(resourceModel.Object.Environment);
envRepository.Setup(r => r.ActiveEnvironment).Returns(resourceModel.Object.Environment);
var activity = new DsfActivity { ResourceID = new InArgument<Guid>(resourceID), EnvironmentID = new InArgument<Guid>(Guid.Empty), UniqueID = Guid.NewGuid().ToString(), SimulationMode = SimulationMode.OnDemand };
var modelItem = CreateModelItem(activity);
//------------Execute Test---------------------------
var viewModel = new ServiceDesignerViewModel(modelItem, rootModel.Object, envRepository.Object, new Mock<IEventAggregator>().Object);
//------------Assert Results-------------------------
Assert.IsNotNull(viewModel.ResourceModel);
var inputMapping = viewModel.ModelItem.GetProperty<string>("InputMapping");
var outputMapping = viewModel.ModelItem.GetProperty<string>("OutputMapping");
Assert.AreEqual("<Inputs><Input Name=\"n1\" Source=\"[[n1]]\" /></Inputs>", inputMapping);
Assert.AreEqual("<Outputs><Output Name=\"n1\" MapsTo=\"[[n1]]\" Value=\"[[n1]]\" /></Outputs>", outputMapping);
}
示例7: ServiceDesingerViewModel_SetRunWorkflowAsync_True_OutputMappingEnabledFalse
public void ServiceDesingerViewModel_SetRunWorkflowAsync_True_OutputMappingEnabledFalse()
{
//------------Setup for test--------------------------
var resourceID = Guid.NewGuid();
var resourceModel = CreateResourceModel(Guid.Empty, false);
resourceModel.Setup(model => model.DataList).Returns("<DataList><n1/></DataList>");
var dataListViewModel = new DataListViewModel();
dataListViewModel.InitializeDataListViewModel(resourceModel.Object);
dataListViewModel.ScalarCollection.Add(new DataListItemModel("n1"));
DataListSingleton.SetDataList(dataListViewModel);
var rootModel = CreateResourceModel(Guid.Empty);
var envRepository = new Mock<IEnvironmentRepository>();
envRepository.Setup(r => r.FindSingle(It.IsAny<Expression<Func<IEnvironmentModel, bool>>>())).Returns(resourceModel.Object.Environment);
envRepository.Setup(r => r.ActiveEnvironment).Returns(resourceModel.Object.Environment);
var activity = new DsfActivity { ResourceID = new InArgument<Guid>(resourceID), EnvironmentID = new InArgument<Guid>(Guid.Empty), UniqueID = Guid.NewGuid().ToString(), SimulationMode = SimulationMode.OnDemand };
var modelItem = CreateModelItem(activity);
var viewModel = new ServiceDesignerViewModel(modelItem, rootModel.Object, envRepository.Object, new Mock<IEventAggregator>().Object) { RunWorkflowAsync = true };
//------------Execute Test---------------------------
//------------Assert Results-------------------------
Assert.IsTrue(viewModel.RunWorkflowAsync);
Assert.IsFalse(viewModel.OutputMappingEnabled);
}
示例8: ServiceDesignerViewModel_WhenRemoteEnvironmentLoads_ShouldNotSetVersionMemoIfCorrect
public void ServiceDesignerViewModel_WhenRemoteEnvironmentLoads_ShouldNotSetVersionMemoIfCorrect()
{
//------------Setup for test--------------------------
var resourceID = Guid.NewGuid();
var connection = new Mock<IEnvironmentConnection>();
connection.Setup(conn => conn.ServerEvents).Returns(new EventPublisher());
var environmentID = Guid.NewGuid();
var environment = new Mock<IEnvironmentModel>();
environment.Setup(e => e.Connection).Returns(connection.Object);
environment.Setup(e => e.ID).Returns(environmentID);
environment.Setup(e => e.IsConnected).Returns(true);
environment.Setup(model => model.IsLocalHost).Returns(false);
environment.Setup(model => model.IsLocalHostCheck()).Returns(false);
var errors = new ObservableReadOnlyList<IErrorInfo>();
var resourceModel = new Mock<IContextualResourceModel>();
resourceModel.Setup(r => r.ResourceName).Returns("TestResource");
resourceModel.Setup(r => r.ServerID).Returns(Guid.NewGuid());
resourceModel.Setup(r => r.WorkflowXaml).Returns(new StringBuilder("<root/>"));
resourceModel.Setup(m => m.Errors).Returns(errors);
resourceModel.Setup(m => m.ID).Returns(resourceID);
resourceModel.Setup(m => m.Environment).Returns(environment.Object);
resourceModel.Setup(m => m.GetErrors(It.IsAny<Guid>())).Returns(errors);
resourceModel.Setup(m => m.HasErrors).Returns(() => false);
resourceModel.SetupProperty(m => m.IsValid);
resourceModel.Setup(m => m.RemoveError(It.IsAny<IErrorInfo>())).Callback((IErrorInfo error) => errors.Remove(error));
resourceModel.Setup(model => model.DataList).Returns("<DataList><n1/></DataList>");
var resources = new Mock<IResourceRepository>();
// ReSharper disable MaximumChainedReferences
resources.Setup(a => a.FindSingle(It.IsAny<Expression<Func<IResourceModel, bool>>>(), true, false))
.Callback((Expression<Func<IResourceModel, bool>> expression, bool b,bool c) => Assert.IsTrue(expression.ToString().Contains("c => (c.ID == ")))
.Returns(resourceModel.Object).Verifiable();
// ReSharper restore MaximumChainedReferences
environment.Setup(a => a.ResourceRepository).Returns(resources.Object);
var dataListViewModel = new DataListViewModel();
dataListViewModel.InitializeDataListViewModel(resourceModel.Object);
dataListViewModel.ScalarCollection.Add(new DataListItemModel("n1"));
DataListSingleton.SetDataList(dataListViewModel);
var rootModel = CreateResourceModel(resourceID);
var envRepository = new Mock<IEnvironmentRepository>();
envRepository.Setup(r => r.FindSingle(It.IsAny<Expression<Func<IEnvironmentModel, bool>>>())).Returns(resourceModel.Object.Environment);
envRepository.Setup(r => r.ActiveEnvironment).Returns(resourceModel.Object.Environment);
var activity = new DsfActivity
{
ResourceID = new InArgument<Guid>(resourceID),
EnvironmentID = new InArgument<Guid>(Guid.Empty),
UniqueID = Guid.NewGuid().ToString(),
SimulationMode = SimulationMode.OnDemand,
InputMapping = "<Inputs></Inputs>",
OutputMapping = "<Outputs></Outputs>"
};
var modelItem = CreateModelItem(activity);
var worker = new Mock<IAsyncWorker>();
// ReSharper disable MaximumChainedReferences
worker.Setup(a => a.Start(It.IsAny<System.Action>(), It.IsAny<System.Action>())).Callback(
// ReSharper restore MaximumChainedReferences
(
System.Action a, System.Action b) =>
{
a.Invoke();
b.Invoke();
}
);
//------------Execute Test---------------------------
// ReSharper disable UnusedVariable
var viewModel = new ServiceDesignerViewModel(modelItem, rootModel.Object, envRepository.Object, new Mock<IEventAggregator>().Object, worker.Object);
// ReSharper restore UnusedVariable
environment.Setup(a => a.IsConnected).Returns(true);
connection.Setup(a => a.Verify(It.IsAny<Action<ConnectResult>>(), true)).Verifiable();
environment.Raise((a => a.ResourcesLoaded += null), new ResourcesLoadedEventArgs { Model = environment.Object });
//------------Assert Results-------------------------
Assert.IsTrue(viewModel.LastValidationMemo.Errors.Count == 0);
}
示例9: ServiceDesignerViewModel_WhenRemoteEnvironmentLoads_ShouldUseNameToFindEnvironment
public void ServiceDesignerViewModel_WhenRemoteEnvironmentLoads_ShouldUseNameToFindEnvironment()
{
//------------Setup for test--------------------------
var resourceID = Guid.Empty;
var connection = new Mock<IEnvironmentConnection>();
connection.Setup(conn => conn.ServerEvents).Returns(new EventPublisher());
var environmentID = Guid.NewGuid();
var environment = new Mock<IEnvironmentModel>();
environment.Setup(e => e.Connection).Returns(connection.Object);
environment.Setup(e => e.ID).Returns(environmentID);
environment.Setup(e => e.IsConnected).Returns(true);
environment.Setup(model => model.IsLocalHost).Returns(false);
environment.Setup(e => e.IsLocalHostCheck()).Returns(false);
var errors = new ObservableReadOnlyList<IErrorInfo>();
var resourceModel = new Mock<IContextualResourceModel>();
resourceModel.Setup(r => r.ResourceName).Returns("TestResource").Verifiable();
resourceModel.Setup(r => r.ServerID).Returns(Guid.NewGuid());
resourceModel.Setup(r => r.WorkflowXaml).Returns(new StringBuilder("<root/>"));
resourceModel.Setup(m => m.Errors).Returns(errors);
resourceModel.Setup(m => m.ID).Returns(resourceID);
resourceModel.Setup(m => m.Environment).Returns(environment.Object);
resourceModel.Setup(m => m.GetErrors(It.IsAny<Guid>())).Returns(errors);
resourceModel.Setup(m => m.HasErrors).Returns(() => false);
resourceModel.SetupProperty(m => m.IsValid);
resourceModel.Setup(m => m.RemoveError(It.IsAny<IErrorInfo>())).Callback((IErrorInfo error) => errors.Remove(error));
resourceModel.Setup(model => model.DataList).Returns("<DataList><n1/></DataList>");
var resources = new Mock<IResourceRepository>();
environment.Setup(a => a.ResourceRepository).Returns(resources.Object);
var dataListViewModel = new DataListViewModel();
dataListViewModel.InitializeDataListViewModel(resourceModel.Object);
dataListViewModel.ScalarCollection.Add(new DataListItemModel("n1"));
DataListSingleton.SetDataList(dataListViewModel);
var rootModel = CreateResourceModel(resourceID);
var envRepository = new Mock<IEnvironmentRepository>();
envRepository.Setup(r => r.FindSingle(It.IsAny<Expression<Func<IEnvironmentModel, bool>>>())).Returns(resourceModel.Object.Environment);
envRepository.Setup(r => r.ActiveEnvironment).Returns(resourceModel.Object.Environment);
var activity = new DsfActivity
{
ServiceName = "bob",
ResourceID = new InArgument<Guid>(resourceID),
EnvironmentID = new InArgument<Guid>(Guid.Empty),
UniqueID = Guid.Empty.ToString(),
SimulationMode = SimulationMode.OnDemand,
InputMapping = "<Inputs><Input Name=\"n1\" Source=\"[[n1]]\" /></Inputs>",
OutputMapping = "<Outputs><Output Name=\"n1\" MapsTo=\"[[n1]]\" Value=\"[[n1]]\" /></Outputs>"
};
var modelItem = CreateModelItem(activity);
var worker = new Mock<IAsyncWorker>();
// ReSharper disable MaximumChainedReferences
worker.Setup(a => a.Start(It.IsAny<System.Action>(), It.IsAny<System.Action>()))
.Callback((System.Action a, System.Action b) =>
// ReSharper restore MaximumChainedReferences
{
a.Invoke();
b.Invoke();
}
);
//------------Execute Test---------------------------
// ReSharper disable UnusedVariable
var viewModel = new ServiceDesignerViewModel(modelItem, rootModel.Object, envRepository.Object, new Mock<IEventAggregator>().Object, worker.Object);
var webFact = new Mock<IWebActivityFactory>();
var wa = new Mock<IWebActivity>();
// ReSharper disable MaximumChainedReferences
webFact.Setup(
a => a.CreateWebActivity(It.IsAny<Object>(), It.IsAny<IContextualResourceModel>(), It.IsAny<string>())).Returns(wa.Object).Verifiable();
// ReSharper restore MaximumChainedReferences
viewModel.ActivityFactory = webFact.Object;
var mappingF = new Mock<IDataMappingViewModelFactory>();
var mapping = new Mock<IDataMappingViewModel>();
mapping.Setup(a => a.GetOutputString(It.IsAny<IList<IInputOutputViewModel>>())).Returns("bob");
// ReSharper disable once MaximumChainedReferences
mappingF.Setup(a => a.CreateModel(It.IsAny<IWebActivity>(), It.IsAny<NotifyCollectionChangedEventHandler>()))
.Returns(mapping.Object);
viewModel.MappingFactory = mappingF.Object;
// ReSharper restore UnusedVariable
// ReSharper disable MaximumChainedReferences
// ReSharper disable MaximumChainedReferences
resources.Setup(a => a.FindSingle(It.IsAny<Expression<Func<IResourceModel, bool>>>(), true, false))
.Returns(resourceModel.Object)
.Callback((Expression<Func<IResourceModel, bool>> expression, bool b) => Assert.IsTrue(expression.ToString().Contains("c => (c.ResourceName == ")))
.Verifiable();
// ReSharper restore MaximumChainedReferences
//.........这里部分代码省略.........
示例10: GetDecisionElementsWhenItemAlreadyInDataListShouldNotReturnRecsetIfScalarNonExistent
public void GetDecisionElementsWhenItemAlreadyInDataListShouldNotReturnRecsetIfScalarNonExistent()
{
//Execute
Mock<IContextualResourceModel> resourceModel = Dev2MockFactory.ResourceModel;
var eventAggregator = new EventAggregator();
var model = CreateWorkflowDesignerViewModel(eventAggregator, resourceModel.Object, null, false);
var dataListViewModel = new DataListViewModel();
dataListViewModel.InitializeDataListViewModel(resourceModel.Object);
var recsetModel = new DataListItemModel("RecSet");
dataListViewModel.RecsetCollection.Add(recsetModel);
dataListViewModel.RecsetCollection[2].Children.Add(new DataListItemModel("aasszzz", parent: recsetModel));
const string expression = "Dev2.Data.Decision.Dev2DataListDecisionHandler.Instance.ExecuteDecisionStack(\"{!TheStack!:[{!Col1!:![[a]]!,!Col2!:!Is Equal!,!Col3!:!0!,!PopulatedColumnCount!:2,!EvaluationFn!:!IsEqual!}],!TotalDecisions!:1,!ModelName!:!Dev2DecisionStack!,!Mode!:!AND!,!TrueArmText!:!True!,!FalseArmText!:!False!,!DisplayText!:!If ]] Is Equal [[scalar]]!}\",AmbientDataList)";
var actual = model.GetDecisionElements(expression, dataListViewModel);
model.Dispose();
//Assert
Assert.AreEqual(1, actual.Count, "Find missing returned an unexpected number of results when finding variables in a decision");
Assert.AreEqual("{!TheStack!:[{!Col1!:!a!,!Col2!:!Is Equal!,!Col3!:!0!,!PopulatedColumnCount!:2,!EvaluationFn!:!IsEqual!}],!TotalDecisions!:1,!ModelName!:!Dev2DecisionStack!,!Mode!:!AND!,!TrueArmText!:!True!,!FalseArmText!:!False!,!DisplayText!:!If Is Equal scalar!}", actual[0], "Find missing found an invalid variable in a decision");
}
示例11: ServiceDesignerViewModel_WhenResourceHasSource_ShouldGetSourceName
public void ServiceDesignerViewModel_WhenResourceHasSource_ShouldGetSourceName()
{
//------------Setup for test--------------------------
var resourceID = Guid.NewGuid();
var connection = new Mock<IEnvironmentConnection>();
connection.Setup(conn => conn.ServerEvents).Returns(new EventPublisher());
var environmentID = Guid.NewGuid();
var environment = new Mock<IEnvironmentModel>();
environment.Setup(e => e.Connection).Returns(connection.Object);
environment.Setup(e => e.ID).Returns(environmentID);
environment.Setup(e => e.IsConnected).Returns(true);
environment.Setup(model => model.IsLocalHost).Returns(false);
environment.Setup(e => e.IsLocalHostCheck()).Returns(false);
var errors = new ObservableReadOnlyList<IErrorInfo>();
var resourceModel = new Mock<IContextualResourceModel>();
resourceModel.Setup(r => r.ResourceName).Returns("TestResource");
resourceModel.Setup(r => r.ServerID).Returns(Guid.NewGuid());
resourceModel.Setup(r => r.WorkflowXaml).Returns(new StringBuilder("<root/>"));
resourceModel.Setup(m => m.Errors).Returns(errors);
resourceModel.Setup(m => m.ID).Returns(resourceID);
resourceModel.Setup(m => m.Environment).Returns(environment.Object);
resourceModel.Setup(m => m.GetErrors(It.IsAny<Guid>())).Returns(errors);
resourceModel.Setup(m => m.HasErrors).Returns(() => false);
resourceModel.SetupProperty(m => m.IsValid);
resourceModel.Setup(m => m.RemoveError(It.IsAny<IErrorInfo>())).Callback((IErrorInfo error) => errors.Remove(error));
resourceModel.Setup(model => model.DataList).Returns("<DataList><n1/></DataList>");
var dataListViewModel = new DataListViewModel();
dataListViewModel.InitializeDataListViewModel(resourceModel.Object);
dataListViewModel.ScalarCollection.Add(new DataListItemModel("n1"));
DataListSingleton.SetDataList(dataListViewModel);
var rootModel = CreateResourceModel(resourceID);
var envRepository = new Mock<IEnvironmentRepository>();
envRepository.Setup(r => r.FindSingle(It.IsAny<Expression<Func<IEnvironmentModel, bool>>>())).Returns(resourceModel.Object.Environment);
envRepository.Setup(r => r.ActiveEnvironment).Returns(resourceModel.Object.Environment);
var activity = new DsfActivity
{
ResourceID = new InArgument<Guid>(resourceID),
EnvironmentID = new InArgument<Guid>(Guid.Empty),
UniqueID = Guid.NewGuid().ToString(),
SimulationMode = SimulationMode.OnDemand,
InputMapping = "<Inputs><Input Name=\"n1\" Source=\"[[n1]]\" /></Inputs>",
OutputMapping = "<Outputs><Output Name=\"n1\" MapsTo=\"[[n1]]\" Value=\"[[n1]]\" /></Outputs>"
};
var modelItem = CreateModelItem(activity);
var resRepo = new Mock<IResourceRepository>();
var srcRes = new Mock<IResourceModel>();
srcRes.Setup(a => a.DisplayName).Returns("bob");
resRepo.Setup(a => a.FindSingle(It.IsAny<Expression<Func<IResourceModel, bool>>>(), false, false)).Returns(srcRes.Object);
environment.Setup(a => a.ResourceRepository).Returns(resRepo.Object);
//------------Execute Test---------------------------
var viewModel = new ServiceDesignerViewModel(modelItem, rootModel.Object, envRepository.Object, new Mock<IEventAggregator>().Object);
//------------Assert Results-------------------------
Assert.AreEqual("bob", viewModel.Properties.FirstOrDefault(a => a.Key == "Source :").Value);
}
示例12: InsertItemExpectedTextboxTextChanged_SpaceInFieldName_ErrorStatusUpdated
public void InsertItemExpectedTextboxTextChanged_SpaceInFieldName_ErrorStatusUpdated()
{
const string ExpectedText = "[[City(). Name]]";
Mock<IResourceModel> mockResourceModel = new Mock<IResourceModel>();
mockResourceModel.Setup(model => model.DataList).Returns("<ADL><City><Name></Name></City></ADL>");
var dataListViewModel = new DataListViewModel();
dataListViewModel.InitializeDataListViewModel(mockResourceModel.Object);
DataListSingleton.SetDataList(dataListViewModel);
Mock<IIntellisenseProvider> intellisenseProvider = new Mock<IIntellisenseProvider>();
intellisenseProvider.Setup(a => a.HandlesResultInsertion).Returns(true);
intellisenseProvider.Setup(
a => a.PerformResultInsertion(It.IsAny<string>(), It.IsAny<IntellisenseProviderContext>())).Returns(ExpectedText);
IntellisenseProviderResult intellisenseProviderResult =
new IntellisenseProviderResult(intellisenseProvider.Object, ExpectedText, "cake");
IntellisenseTextBox textBox = new IntellisenseTextBox();
textBox.CreateVisualTree();
textBox.InsertItem(intellisenseProviderResult, true);
Thread.Sleep(250);
Thread.Sleep(100);
Assert.AreEqual(ExpectedText, textBox.Text, "Expected [ " + ExpectedText + " ] But got [ " + textBox.Text + " ]");
Assert.IsTrue(textBox.HasError, "Expected [ True ] But got [ " + textBox.HasError + " ]");
}
示例13: CreateDataListViewModel
static IDataListViewModel CreateDataListViewModel(Mock<IContextualResourceModel> mockResourceModel, IEventAggregator eventAggregator = null)
{
var dataListViewModel = new DataListViewModel(eventAggregator ?? new Mock<IEventAggregator>().Object);
dataListViewModel.InitializeDataListViewModel(mockResourceModel.Object);
return dataListViewModel;
}
示例14: WriteResourceModel_DataListContainingScalarWithError_WithDoubleBracketedScalar_Expected_Positive
public void WriteResourceModel_DataListContainingScalarWithError_WithDoubleBracketedScalar_Expected_Positive()
{
//------------Setup for test--------------------------
_mockResourceModel = Dev2MockFactory.SetupResourceModelMock();
_dataListViewModel = new DataListViewModel(new Mock<IEventAggregator>().Object);
_dataListViewModel.InitializeDataListViewModel(_mockResourceModel.Object);
_dataListViewModel.RecsetCollection.Clear();
_dataListViewModel.ScalarCollection.Clear();
IDataListItemModel carRecordset = DataListItemModelFactory.CreateDataListModel("[[Car]]", "A recordset of information about a car", enDev2ColumnArgumentDirection.Both);
carRecordset.Children.Add(DataListItemModelFactory.CreateDataListModel("Make", "Make of vehicle", carRecordset));
carRecordset.Children.Add(DataListItemModelFactory.CreateDataListModel("Model", "Model of vehicle", carRecordset));
_dataListViewModel.RecsetCollection.Add(carRecordset);
var scalarDataListItemWithError = DataListItemModelFactory.CreateDataListModel("[[Country]]", "name of Country", enDev2ColumnArgumentDirection.Both);
scalarDataListItemWithError.HasError = true;
scalarDataListItemWithError.ErrorMessage = "This is an Error";
_dataListViewModel.ScalarCollection.Add(scalarDataListItemWithError);
_dataListViewModel.ScalarCollection.Add(scalarDataListItemWithError);
_dataListViewModel.ValidateNames(scalarDataListItemWithError);
DataListSingleton.SetDataList(_dataListViewModel);
//------------Execute Test---------------------------
var xmlDataList = _dataListViewModel.WriteToResourceModel();
//------------Assert Results-------------------------
Assert.AreEqual(2, _dataListViewModel.ScalarCollection.Count);
Assert.IsTrue(_dataListViewModel.ScalarCollection[0].DisplayName == "Country");
Assert.IsTrue(_dataListViewModel.ScalarCollection[1].DisplayName == "Country");
Assert.IsFalse(xmlDataList.Contains("Country"));
}
示例15: CreateServiceDesignerViewModelWithEmptyResourceID
static ServiceDesignerViewModel CreateServiceDesignerViewModelWithEmptyResourceID(Guid instanceID, params IErrorInfo[] resourceErrors)
{
var rootModel = CreateResourceModel(Guid.NewGuid(), false, resourceErrors);
rootModel.Setup(model => model.ResourceType).Returns(Studio.Core.AppResources.Enums.ResourceType.WorkflowService);
var resourceModel = CreateResourceModel(Guid.Empty, false);
resourceModel.Setup(model => model.ResourceType).Returns(Studio.Core.AppResources.Enums.ResourceType.WorkflowService);
resourceModel.Setup(model => model.DataList).Returns("<DataList><n1/></DataList>");
resourceModel.Setup(model => model.ResourceName).Returns("TestResource");
var dataListViewModel = new DataListViewModel();
dataListViewModel.InitializeDataListViewModel(resourceModel.Object);
dataListViewModel.ScalarCollection.Add(new DataListItemModel("n1"));
DataListSingleton.SetDataList(dataListViewModel);
var modelItem = CreateModelItem(instanceID, resourceModel.Object.ID, resourceModel.Object.Environment.ID, null);
var envRepository = new Mock<IEnvironmentRepository>();
envRepository.Setup(e => e.ActiveEnvironment).Returns(resourceModel.Object.Environment);
envRepository.Setup(r => r.FindSingle(It.IsAny<Expression<Func<IEnvironmentModel, bool>>>())).Returns(resourceModel.Object.Environment);
var worker = new Mock<IAsyncWorker>().Object;
return new ServiceDesignerViewModel(modelItem.Object, rootModel.Object, envRepository.Object, new Mock<IEventAggregator>().Object, worker);
}