本文整理汇总了C#中Dev2.Studio.ViewModels.DataList.DataListViewModel类的典型用法代码示例。如果您正苦于以下问题:C# DataListViewModel类的具体用法?C# DataListViewModel怎么用?C# DataListViewModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataListViewModel类属于Dev2.Studio.ViewModels.DataList命名空间,在下文中一共展示了DataListViewModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public void Init()
{
PrivateType p = new PrivateType(typeof(Dev2DataLanguageParser));
var cache = p.GetStaticField("_expressionCache") as ConcurrentDictionary<string, IList<IIntellisenseResult>>;
Assert.IsNotNull(cache);
cache.Clear();
var cache2 = p.GetStaticField("_payloadCache") as ConcurrentDictionary<Tuple<string, string>, IList<IIntellisenseResult>>;
Assert.IsNotNull(cache2);
cache2.Clear();
Monitor.Enter(DataListSingletonTest.DataListSingletonTestGuard);
var testEnvironmentModel = ResourceModelTest.CreateMockEnvironment();
_resourceModel = new ResourceModel(testEnvironmentModel.Object)
{
ResourceName = "test",
ResourceType = ResourceType.Service,
DataList = @"
<DataList>
<Scalar/>
<Country/>
<State />
<City>
<Name/>
<GeoLocation />
</City>
</DataList>
"
};
IDataListViewModel setupDatalist = new DataListViewModel();
DataListSingleton.SetDataList(setupDatalist);
DataListSingleton.ActiveDataList.InitializeDataListViewModel(_resourceModel);
}
示例2: Init
public void Init()
{
Monitor.Enter(DataListSingletonTest.DataListSingletonTestGuard);
var testEnvironmentModel = ResourceModelTest.CreateMockEnvironment();
_resourceModel = new ResourceModel(testEnvironmentModel.Object)
{
ResourceName = "test",
ResourceType = ResourceType.Service,
DataList = @"
<DataList>
<Scalar/>
<Country/>
<State />
<City>
<Name/>
<GeoLocation />
</City>
</DataList>
"
};
IDataListViewModel setupDatalist = new DataListViewModel();
DataListSingleton.SetDataList(setupDatalist);
DataListSingleton.ActiveDataList.InitializeDataListViewModel(_resourceModel);
}
示例3: CreateDataListViewModel
internal IDataListViewModel CreateDataListViewModel(IResourceModel resourceModel)
{
DataListViewModel dLVM = new DataListViewModel();
dLVM.InitializeDataListViewModel(resourceModel);
return dLVM;
}
示例4: CreateDataListViewModelWithDefaultResourceModel
internal IDataListViewModel CreateDataListViewModelWithDefaultResourceModel() {
TestResourceModel testResourceModel = new TestResourceModel();
IDataListViewModel dataListViewModel = new DataListViewModel();
dataListViewModel.InitializeDataListViewModel(testResourceModel);
return dataListViewModel;
}
示例5: 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);
}
示例6: GivenIHaveTheFollowingVariableList
public void GivenIHaveTheFollowingVariableList(string variableList)
{
const string Root = "<DataList>##</DataList>";
var datalist = Root.Replace("##", variableList);
ScenarioContext.Current.Add("dataList", datalist);
var testEnvironmentModel = ResourceModelTest.CreateMockEnvironment();
var resourceModel = new ResourceModel(testEnvironmentModel.Object)
{
ResourceName = "test",
ResourceType = ResourceType.Service,
DataList = datalist
};
IDataListViewModel setupDatalist = new DataListViewModel();
DataListSingleton.SetDataList(setupDatalist);
DataListSingleton.ActiveDataList.InitializeDataListViewModel(resourceModel);
}
示例7: 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);
}
示例8: 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"));
}
示例9: DataListViewModel_MissingDataListParts_WithRecsetPartNotInDataList_ShouldReturnPartInList
public void DataListViewModel_MissingDataListParts_WithRecsetPartNotInDataList_ShouldReturnPartInList()
{
//------------Setup for test--------------------------
var dataListViewModel = new DataListViewModel(new Mock<IEventAggregator>().Object);
const string recsetName = "recset";
const string firstFieldName = "f1";
var dataListParts = new List<IDataListVerifyPart>();
var part = CreateRecsetPart(recsetName, firstFieldName);
dataListParts.Add(part.Object);
//----------------------Precondition----------------------------
//------------Execute Test---------------------------
List<IDataListVerifyPart> missingDataListParts = dataListViewModel.MissingDataListParts(dataListParts);
//------------Assert Results-------------------------
Assert.AreEqual(1, missingDataListParts.Count);
}
示例10: 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);
}
示例11: DataListViewModel_RemoveDataListItem_WithScalarItem_ShouldRemoveFromScalarCollection
public void DataListViewModel_RemoveDataListItem_WithScalarItem_ShouldRemoveFromScalarCollection()
{
//------------Setup for test--------------------------
var dataListViewModel = new DataListViewModel(new Mock<IEventAggregator>().Object);
var scalarItem = new DataListItemModel("scalar");
dataListViewModel.ScalarCollection.Add(scalarItem);
//----------------------Precondition----------------------------
Assert.AreEqual(1, dataListViewModel.ScalarCollection.Count);
//------------Execute Test---------------------------
dataListViewModel.RemoveDataListItem(scalarItem);
//------------Assert Results-------------------------
Assert.AreEqual(0, dataListViewModel.ScalarCollection.Count);
}
示例12: 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
//.........这里部分代码省略.........
示例13: 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);
}
示例14: 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);
}
示例15: 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;
}