本文整理汇总了C#中Dev2.Core.Tests.Environments.TestEnvironmentRespository类的典型用法代码示例。如果您正苦于以下问题:C# TestEnvironmentRespository类的具体用法?C# TestEnvironmentRespository怎么用?C# TestEnvironmentRespository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestEnvironmentRespository类属于Dev2.Core.Tests.Environments命名空间,在下文中一共展示了TestEnvironmentRespository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: DeployViewModelConnectWithServerExpectedDoesNotDisconnectOtherServers
public void DeployViewModelConnectWithServerExpectedDoesNotDisconnectOtherServers()
{
var source = EnviromentRepositoryTest.CreateMockEnvironment();
var sourceConn = Mock.Get(source.Object.Connection);
sourceConn.Setup(c => c.Disconnect()).Verifiable();
var e1 = EnviromentRepositoryTest.CreateMockEnvironment();
var c1 = Mock.Get(e1.Object.Connection);
c1.Setup(c => c.Disconnect()).Verifiable();
var s1 = e1.Object;
var e2 = EnviromentRepositoryTest.CreateMockEnvironment();
var c2 = Mock.Get(e2.Object.Connection);
c2.Setup(c => c.Disconnect()).Verifiable();
var s2 = e2.Object;
var serverProvider = new Mock<IEnvironmentModelProvider>();
serverProvider.Setup(s => s.Load()).Returns(new List<IEnvironmentModel> { s1, s2 });
var repo = new TestEnvironmentRespository(source.Object, e1.Object, e2.Object);
var studioResourceRepository = new Mock<IStudioResourceRepository>();
studioResourceRepository.Setup(repository => repository.Filter(It.IsAny<Func<IExplorerItemModel, bool>>())).Returns(new ObservableCollection<IExplorerItemModel>());
var deployViewModel = new DeployViewModel(new TestAsyncWorker(), serverProvider.Object, repo, new Mock<IEventAggregator>().Object, studioResourceRepository.Object, new Mock<IConnectControlViewModel>().Object, new Mock<IConnectControlViewModel>().Object, null, null, null, new Mock<IConnectControlSingleton>().Object);
Assert.IsTrue(source.Object.IsConnected);
Assert.IsTrue(s1.IsConnected);
Assert.IsTrue(s2.IsConnected);
deployViewModel.SelectedSourceServer = s1;
sourceConn.Verify(c => c.Disconnect(), Times.Never());
c1.Verify(c => c.Disconnect(), Times.Never());
c2.Verify(c => c.Disconnect(), Times.Never());
deployViewModel.SelectedDestinationServer = s2;
sourceConn.Verify(c => c.Disconnect(), Times.Never());
c1.Verify(c => c.Disconnect(), Times.Never());
c2.Verify(c => c.Disconnect(), Times.Never());
Assert.IsTrue(source.Object.IsConnected);
Assert.IsTrue(s1.IsConnected);
Assert.IsTrue(s2.IsConnected);
}
示例3: SetupDeployViewModel
protected static DeployStatsCalculator SetupDeployViewModel(out DeployViewModel deployViewModel)
{
var source = EnviromentRepositoryTest.CreateMockEnvironment();
var destination = EnviromentRepositoryTest.CreateMockEnvironment();
source.Setup(a => a.AuthorizationService).Returns(new Mock<IAuthorizationService>().Object);
destination.Setup(a => a.AuthorizationService).Returns(new Mock<IAuthorizationService>().Object);
var serverProvider = new Mock<IEnvironmentModelProvider>();
serverProvider.Setup(s => s.Load()).Returns(new List<IEnvironmentModel> { source.Object, destination.Object });
var repo = new TestEnvironmentRespository(source.Object, destination.Object);
var deployStatsCalculator = new DeployStatsCalculator();
IExplorerItemModel resourceVm;
var studioResourceRepository = CreateModels(false, source.Object, out resourceVm);
deployViewModel = new DeployViewModel(AsyncWorkerTests.CreateSynchronousAsyncWorker().Object, serverProvider.Object, repo, new Mock<IEventAggregator>().Object, studioResourceRepository, new Mock<IConnectControlViewModel>().Object, new Mock<IConnectControlViewModel>().Object, deployStatsCalculator)
{
SelectedSourceServer = source.Object,
SelectedDestinationServer = destination.Object
};
return deployStatsCalculator;
}
示例4: EnvironmentRepositoryFindWithNonMatchingCriteriaExpectedReturnsEmptyList
public void EnvironmentRepositoryFindWithNonMatchingCriteriaExpectedReturnsEmptyList()
{
var source = CreateMockEnvironment();
var e1 = CreateMockEnvironment();
var e2 = CreateMockEnvironment();
var repo = new TestEnvironmentRespository(source.Object, e1.Object, e2.Object);
var actual = repo.Find(e => e.ID == Guid.NewGuid()).ToList();
Assert.AreEqual(0, actual.Count);
}
示例5: EnvironmentRepositorySaveWithSingleItemExpectedDoesNotInvokesWriteSession
public void EnvironmentRepositorySaveWithSingleItemExpectedDoesNotInvokesWriteSession()
{
var source = new Mock<IEnvironmentModel>();
var e1 = new Mock<IEnvironmentModel>();
var repo = new TestEnvironmentRespository(source.Object);
repo.Save(e1.Object);
Assert.AreEqual(0, repo.WriteSessionHitCount);
}
示例6: StudioResourceRepository_AddServerNode_Existing_ItemExpandedAndSelected
public void StudioResourceRepository_AddServerNode_Existing_ItemExpandedAndSelected()
{
//------------Setup for test--------------------------
Mock<IContextualResourceModel> resourceModel = new Mock<IContextualResourceModel>();
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);
var environmentModel = Dev2MockFactory.SetupEnvironmentModel(resourceModel, new List<IResourceModel>()).Object;
var serverItemModel = new ExplorerItemModel { DisplayName = "localhost", ResourceType = ResourceType.Server, EnvironmentId = environmentModel.ID, ResourcePath = "", ResourceId = Guid.NewGuid() };
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);
new EnvironmentRepository(testEnvironmentRespository);
IEnvironmentModel internalEnvironmentModel = environmentModel;
studioResourceRepository.GetCurrentEnvironment = () => internalEnvironmentModel.ID;
ExplorerItemModel serverExplorerItem = new ExplorerItemModel(studioResourceRepository, AsyncWorkerTests.CreateSynchronousAsyncWorker().Object, new Mock<IConnectControlSingleton>().Object) { EnvironmentId = Guid.NewGuid(), ResourceType = ResourceType.Server };
studioResourceRepository.AddServerNode(serverExplorerItem);
//------------Execute Test---------------------------
studioResourceRepository.AddServerNode(serverExplorerItem);
//------------Assert Results-------------------------
Assert.AreEqual(2, studioResourceRepository.ExplorerItemModels.Count);
Assert.IsTrue(studioResourceRepository.ExplorerItemModels[1].IsExplorerSelected);
Assert.IsTrue(studioResourceRepository.ExplorerItemModels[1].IsExplorerExpanded);
}
示例7: 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;
}
示例8: EnvironmentRepositoryFindSingleWithNullExpectedReturnsNull
public void EnvironmentRepositoryFindSingleWithNullExpectedReturnsNull()
{
var source = CreateMockEnvironment();
var e1 = CreateMockEnvironment();
var e2 = CreateMockEnvironment();
var repo = new TestEnvironmentRespository(source.Object, e1.Object, e2.Object);
var actual = repo.FindSingle(null);
Assert.IsNull(actual);
}
示例9: SetupResourceModel
static Mock<IContextualResourceModel> SetupResourceModel()
{
RootWebSite.IsTestMode = true;
Mock<IEnvironmentModel> environment = new Mock<IEnvironmentModel>();
environment.SetupGet(r => r.Name).Returns("localhost");
Mock<IEnvironmentConnection> connection = new Mock<IEnvironmentConnection>();
connection.SetupGet(e => e.AppServerUri).Returns(new Uri("http://www.azure.com"));
environment.SetupGet(r => r.Connection).Returns(connection.Object);
var testEnvRepo = new TestEnvironmentRespository(environment.Object);
// ReSharper disable ObjectCreationAsStatement
new EnvironmentRepository(testEnvRepo);
// ReSharper restore ObjectCreationAsStatement
EventPublishers.Aggregator = new Mock<IEventAggregator>().Object;
var resourceModel = new Mock<IContextualResourceModel>();
resourceModel.SetupGet(m => m.Environment).Returns(environment.Object);
resourceModel.SetupGet(m => m.Category).Returns("MyFolder");
return resourceModel;
}
示例10: EnvironmentRepositoryRemoveWithSingleItemExpectedDisconnectsAndRemovesItem
public void EnvironmentRepositoryRemoveWithSingleItemExpectedDisconnectsAndRemovesItem()
{
var source = new Mock<IEnvironmentModel>();
var c1 = CreateMockConnection();
var c2 = CreateMockConnection();
var c3 = CreateMockConnection();
c1.Setup(c => c.Disconnect()).Verifiable();
c2.Setup(c => c.Disconnect()).Verifiable();
c3.Setup(c => c.Disconnect()).Verifiable();
var e1 = new EnvironmentModel(Guid.NewGuid(), c1.Object, new Mock<IResourceRepository>().Object, new Mock<IStudioResourceRepository>().Object);
var e2 = new EnvironmentModel(Guid.NewGuid(), c2.Object, new Mock<IResourceRepository>().Object, new Mock<IStudioResourceRepository>().Object);
var e3 = new EnvironmentModel(Guid.NewGuid(), c3.Object, new Mock<IResourceRepository>().Object, new Mock<IStudioResourceRepository>().Object);
var repo = new TestEnvironmentRespository(source.Object, e1, e2, e3);
repo.Remove(e2);
var actual = repo.All().ToList();
c1.Verify(c => c.Disconnect(), Times.Never());
c2.Verify(c => c.Disconnect(), Times.Once());
c3.Verify(c => c.Disconnect(), Times.Never());
Assert.AreEqual(3, actual.Count);
Assert.AreEqual(1, repo.RemoveInternalHitCount);
Assert.AreSame(source.Object, actual[0]);
Assert.AreSame(e1, actual[1]);
Assert.AreSame(e3, actual[2]);
}
示例11: EnvironmentRepositoryWriteSessionWithNonExistingFileExpectedCreatesFile
public void EnvironmentRepositoryWriteSessionWithNonExistingFileExpectedCreatesFile()
{
var path = EnvironmentRepository.GetEnvironmentsFilePath();
var bakPath = RetryUtility.RetryMethod(() => BackupFile(path), 15, 1000, null);
var source = new Mock<IEnvironmentModel>();
var repo = new TestEnvironmentRespository(source.Object) { IsReadWriteEnabled = true };
repo.WriteSession(null);
var exists = File.Exists(path);
Assert.AreEqual(true, exists);
// ReSharper disable ImplicitlyCapturedClosure
RetryUtility.RetryAction(() => DeleteFile(path), 15, 1000);
// ReSharper restore ImplicitlyCapturedClosure
RetryUtility.RetryAction(() => RestoreFile(path, bakPath), 15, 1000);
}
示例12: EnvironmentRepositoryRemoveWithManyItemsExpectedDisconnectsAndRemovesItems
public void EnvironmentRepositoryRemoveWithManyItemsExpectedDisconnectsAndRemovesItems()
{
// DO NOT use mock as test requires IEquatable of IEnvironmentModel
var source = new Mock<IEnvironmentModel>();
var c1 = CreateMockConnection();
var c2 = CreateMockConnection();
var c3 = CreateMockConnection();
c1.Setup(c => c.Disconnect()).Verifiable();
c2.Setup(c => c.Disconnect()).Verifiable();
c3.Setup(c => c.Disconnect()).Verifiable();
var e1 = new EnvironmentModel(Guid.NewGuid(), c1.Object, new Mock<IResourceRepository>().Object, new Mock<IStudioResourceRepository>().Object);
var e2 = new EnvironmentModel(Guid.NewGuid(), c2.Object, new Mock<IResourceRepository>().Object, new Mock<IStudioResourceRepository>().Object);
var e3 = new EnvironmentModel(Guid.NewGuid(), c3.Object, new Mock<IResourceRepository>().Object, new Mock<IStudioResourceRepository>().Object);
var repo = new TestEnvironmentRespository(source.Object, e1, e2, e3);
repo.Remove(new List<IEnvironmentModel> { e1, e3 });
var actual = repo.All().ToList();
c1.Verify(c => c.Disconnect(), Times.Once());
c2.Verify(c => c.Disconnect(), Times.Never());
c3.Verify(c => c.Disconnect(), Times.Once());
Assert.AreEqual(2, actual.Count);
Assert.AreEqual(2, repo.RemoveInternalHitCount);
Assert.AreSame(source.Object, actual[0]);
Assert.AreSame(e2, actual[1]);
}
示例13: EnvironmentRepositoryRemoveWithManyItemsExpectedDoesNotInvokesWriteSession
public void EnvironmentRepositoryRemoveWithManyItemsExpectedDoesNotInvokesWriteSession()
{
var source = new Mock<IEnvironmentModel>();
var e1 = new Mock<IEnvironmentModel>();
var e2 = new Mock<IEnvironmentModel>();
var repo = new TestEnvironmentRespository(source.Object);
repo.Remove(new List<IEnvironmentModel> { e1.Object, e2.Object });
Assert.AreEqual(0, repo.WriteSessionHitCount);
}
示例14: EnvironmentRepositoryReadSessionWithOneEnvironmentExpectedReturnsOneEnvironment
public void EnvironmentRepositoryReadSessionWithOneEnvironmentExpectedReturnsOneEnvironment()
{
var path = EnvironmentRepository.GetEnvironmentsFilePath();
var bakPath = RetryUtility.RetryMethod(() => BackupFile(path), 15, 1000, null);
var source = new Mock<IEnvironmentModel>();
var repo = new TestEnvironmentRespository(source.Object) { IsReadWriteEnabled = true };
repo.WriteSession(new List<Guid> { Guid.NewGuid() });
var result = repo.ReadSession();
Assert.AreEqual(1, result.Count);
// ReSharper disable ImplicitlyCapturedClosure
RetryUtility.RetryAction(() => DeleteFile(path), 15, 1000);
// ReSharper restore ImplicitlyCapturedClosure
RetryUtility.RetryAction(() => RestoreFile(path, bakPath), 15, 1000);
}
示例15: EnvironmentRepositoryReadSessionWithNonExistingFileExpectedReturnsEmptyList
public void EnvironmentRepositoryReadSessionWithNonExistingFileExpectedReturnsEmptyList()
{
var path = EnvironmentRepository.GetEnvironmentsFilePath();
var bakPath = RetryUtility.RetryMethod(() => BackupFile(path), 15, 1000, null);
var source = new Mock<IEnvironmentModel>();
var repo = new TestEnvironmentRespository(source.Object) { IsReadWriteEnabled = true };
var result = repo.ReadSession();
Assert.AreEqual(0, result.Count);
RetryUtility.RetryAction(() => RestoreFile(path, bakPath), 15, 1000);
}