• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Environments.TestEnvironmentRespository类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Dev2.Core.Tests.Environments.TestEnvironmentRespository的典型用法代码示例。如果您正苦于以下问题:C# TestEnvironmentRespository类的具体用法?C# TestEnvironmentRespository怎么用?C# TestEnvironmentRespository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TestEnvironmentRespository类属于Dev2.Core.Tests.Environments命名空间,在下文中一共展示了TestEnvironmentRespository类的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: 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);
        }
开发者ID:ndubul,项目名称:Chillas,代码行数:45,代码来源:DeployViewModelTest.cs


示例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;
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:23,代码来源:DeployViewModelTestBase.cs


示例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);
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:11,代码来源:EnviromentRepositoryTest.cs


示例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);
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:10,代码来源:EnviromentRepositoryTest.cs


示例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);
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:30,代码来源:StudioResourceRepositoryTests.cs


示例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;
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:27,代码来源:DeployViewModelTestBase.cs


示例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);
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:10,代码来源:EnviromentRepositoryTest.cs


示例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;
 }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:18,代码来源:RootWebSiteTest.cs


示例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]);
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:30,代码来源:EnviromentRepositoryTest.cs


示例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);
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:17,代码来源:EnviromentRepositoryTest.cs


示例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]);
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:31,代码来源:EnviromentRepositoryTest.cs


示例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);
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:11,代码来源:EnviromentRepositoryTest.cs


示例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);
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:17,代码来源:EnviromentRepositoryTest.cs


示例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);
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:13,代码来源:EnviromentRepositoryTest.cs


示例16: EnvironmentRepositoryFindWithNullExpectedReturnsEmptyList

        public void EnvironmentRepositoryFindWithNullExpectedReturnsEmptyList()
        {
            var source = CreateMockEnvironment();
            var e1 = CreateMockEnvironment();
            var e2 = CreateMockEnvironment();

            var repo = new TestEnvironmentRespository(source.Object, e1.Object, e2.Object);
            var actual = repo.Find(null);

            Assert.AreEqual(0, actual.Count);
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:11,代码来源:EnviromentRepositoryTest.cs


示例17: EnvironmentRepositorySaveWithSingleNullExpectedDoesNothing

        public void EnvironmentRepositorySaveWithSingleNullExpectedDoesNothing()
        {
            var source = new Mock<IEnvironmentModel>();

            var repo = new TestEnvironmentRespository(source.Object);
            var startCount = repo.All().Count;

            repo.Save((ICollection<IEnvironmentModel>)null);
            Assert.AreEqual(startCount, repo.All().Count);
            Assert.AreEqual(0, repo.AddInternalHitCount);
            Assert.AreEqual(0, repo.WriteSessionHitCount);
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:12,代码来源:EnviromentRepositoryTest.cs


示例18: EnvironmentRepositoryRemoveWithSingleItemExpectedDoesNotInvokesWriteSession

        public void EnvironmentRepositoryRemoveWithSingleItemExpectedDoesNotInvokesWriteSession()
        {
            var source = new Mock<IEnvironmentModel>();
            var c1 = CreateMockConnection();
            var c2 = CreateMockConnection();
            var c3 = CreateMockConnection();

            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(e1);
            Assert.AreEqual(0, repo.WriteSessionHitCount);
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:16,代码来源:EnviromentRepositoryTest.cs


示例19: EnvironmentRepositoryWriteSessionWithExistingFileExpectedOverwritesFile

        public void EnvironmentRepositoryWriteSessionWithExistingFileExpectedOverwritesFile()
        {
            var path = EnvironmentRepository.GetEnvironmentsFilePath();
            var bakPath = RetryUtility.RetryMethod(() => BackupFile(path), 15, 1000, null);

            var c1 = CreateMockConnection();
            var e1 = new EnvironmentModel(Guid.NewGuid(), c1.Object, new Mock<IResourceRepository>().Object, new Mock<IStudioResourceRepository>().Object);
            var repo = new TestEnvironmentRespository(e1) { IsReadWriteEnabled = true };

            // Create file
            repo.WriteSession(new List<Guid> { Guid.NewGuid() });

            var xml = XElement.Load(path);
            var actual = xml.Descendants("Environment").Count();
            Assert.AreEqual(1, actual);

            // Overwrite file
            repo.WriteSession(new List<Guid> { Guid.NewGuid(), Guid.NewGuid() });

            xml = XElement.Load(path);
            actual = xml.Descendants("Environment").Count();
            Assert.AreEqual(2, actual);

            // ReSharper disable ImplicitlyCapturedClosure
            RetryUtility.RetryAction(() => DeleteFile(path), 15, 1000);
            // ReSharper restore ImplicitlyCapturedClosure
            RetryUtility.RetryAction(() => RestoreFile(path, bakPath), 15, 1000);
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:28,代码来源:EnviromentRepositoryTest.cs


示例20: EnvironmentRepositoryRemoveWithSingleNonExistingItemExpectedDoesNotRemoveItem

        public void EnvironmentRepositoryRemoveWithSingleNonExistingItemExpectedDoesNotRemoveItem()
        {
            var source = new Mock<IEnvironmentModel>();
            var c1 = CreateMockConnection();
            var c2 = CreateMockConnection();
            var c3 = CreateMockConnection();

            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);
            var startCount = repo.All().Count;

            repo.Remove(e3);

            Assert.AreEqual(startCount, repo.All().Count);
            Assert.AreEqual(1, repo.RemoveInternalHitCount);
            Assert.AreEqual(0, repo.WriteSessionHitCount);
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:20,代码来源:EnviromentRepositoryTest.cs



注:本文中的Dev2.Core.Tests.Environments.TestEnvironmentRespository类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Operations.Dev2NumberFormatter类代码示例发布时间:2022-05-24
下一篇:
C# Communication.ExecuteMessage类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap