public TestSave ( IEnvironmentModel environmentModel, Newtonsoft.Json.Linq.JObject jsonObj ) : void | ||
environmentModel | IEnvironmentModel | |
jsonObj | Newtonsoft.Json.Linq.JObject | |
Результат | void |
public void ServiceCallbackHandler_Save_ManyDependants_ShowDependancyViewer() { //------------------------------Setup------------------------------------------------- Mock <IShowDependencyProvider> showDependencyProvider; Mock <IResourceRepository> resourceRepo; Guid resourceId = Guid.NewGuid(); SetupObjects(out showDependencyProvider, out resourceRepo, resourceId); var compileMessageTos = new List <ICompileMessageTO> { new CompileMessageTO() }; var envConnection = SetupConnectionWithCompileMessageList(compileMessageTos, new List <string> { "Unsaved 1", "Another Testing Dependant" }); var envModel = new Mock <IEnvironmentModel>(); envModel.Setup(e => e.ResourceRepository).Returns(resourceRepo.Object); envModel.Setup(e => e.Connection).Returns(envConnection.Object); var aggregator = new Mock <IEventAggregator>(); var envRepo = new Mock <IEnvironmentRepository>(); var handler = new ServiceCallbackHandlerMock(aggregator.Object, envRepo.Object, showDependencyProvider.Object); var jsonObj = JObject.Parse("{ 'ResourceID': '" + resourceId + "','ResourceType':'Service'}"); //------------------------------Execute ------------------------------------------------- handler.TestSave(envModel.Object, jsonObj); //------------------------------Assert Result ------------------------------------------------- showDependencyProvider.Verify(provider => provider.ShowDependencyViewer(It.IsAny <IContextualResourceModel>(), It.IsAny <IList <string> >()), Times.Once()); }
public void ServiceCallbackHandlerSaveWithValidArgsExpectedPublishesUpdateResourceMessage() { Guid resourceId = Guid.NewGuid(); var showDependencyProvider = new Mock <IShowDependencyProvider>(); var resourceModel = new Mock <IResourceModel>(); resourceModel.Setup(r => r.ResourceName).Returns("Some Testing Display Name"); resourceModel.Setup(r => r.ID).Returns(resourceId); var resourceRepo = new Mock <IResourceRepository>(); resourceRepo.Setup(r => r.ReloadResource(It.IsAny <Guid>(), It.IsAny <ResourceType>(), It.IsAny <IEqualityComparer <IResourceModel> >(), true)) .Returns(new List <IResourceModel> { resourceModel.Object }); var envModel = new Mock <IEnvironmentModel>(); envModel.Setup(e => e.ResourceRepository).Returns(resourceRepo.Object); var aggregator = new Mock <IEventAggregator>(); var envRepo = new Mock <IEnvironmentRepository>(); var handler = new ServiceCallbackHandlerMock(aggregator.Object, envRepo.Object, showDependencyProvider.Object); aggregator.Setup(e => e.Publish(It.IsAny <UpdateResourceMessage>())) .Callback <Object>(m => { var msg = (UpdateResourceMessage)m; Assert.AreEqual(resourceId, msg.ResourceModel.ID); }) .Verifiable(); var jsonObj = JObject.Parse("{ 'ResourceID': '" + resourceId + "','ResourceType':'Service'}"); handler.TestSave(envModel.Object, jsonObj); aggregator.Verify(e => e.Publish(It.IsAny <UpdateResourceMessage>()), Times.Once()); }
public void ServiceCallbackHandlerSaveWithValidArgsWithMessages() { //------------------------------Setup------------------------------------------------- Mock<IShowDependencyProvider> showDependencyProvider; Mock<IResourceRepository> resourceRepo; Guid resourceId = Guid.NewGuid(); SetupObjects(out showDependencyProvider, out resourceRepo, resourceId); var compileMessageTos = new List<ICompileMessageTO> { new CompileMessageTO() }; var envConnection = SetupConnectionWithCompileMessageList(compileMessageTos, new List<string> { "Some Testing Dependant" }); var envModel = new Mock<IEnvironmentModel>(); envModel.Setup(e => e.ResourceRepository).Returns(resourceRepo.Object); envModel.Setup(e => e.Connection).Returns(envConnection.Object); var aggregator = new Mock<IEventAggregator>(); var envRepo = new Mock<IEnvironmentRepository>(); var handler = new ServiceCallbackHandlerMock(aggregator.Object, envRepo.Object, showDependencyProvider.Object); var jsonObj = JObject.Parse("{ 'ResourceID': '" + resourceId + "','ResourceType':'Service'}"); //------------------------------Execute ------------------------------------------------- handler.TestSave(envModel.Object, jsonObj); //------------------------------Assert Result ------------------------------------------------- showDependencyProvider.Verify(provider => provider.ShowDependencyViewer(It.IsAny<IContextualResourceModel>(), It.IsAny<IList<string>>()), Times.Once()); }
public void ServiceCallbackHandlerSaveWithValidArgsExpectedPublishesUpdateResourceMessage() { Guid resourceId = Guid.NewGuid(); var showDependencyProvider = new Mock<IShowDependencyProvider>(); var resourceModel = new Mock<IResourceModel>(); resourceModel.Setup(r => r.ResourceName).Returns("Some Testing Display Name"); resourceModel.Setup(r => r.ID).Returns(resourceId); var resourceRepo = new Mock<IResourceRepository>(); resourceRepo.Setup(r => r.ReloadResource(It.IsAny<Guid>(), It.IsAny<ResourceType>(), It.IsAny<IEqualityComparer<IResourceModel>>(), true)) .Returns(new List<IResourceModel> { resourceModel.Object }); var envModel = new Mock<IEnvironmentModel>(); envModel.Setup(e => e.ResourceRepository).Returns(resourceRepo.Object); var aggregator = new Mock<IEventAggregator>(); var envRepo = new Mock<IEnvironmentRepository>(); var handler = new ServiceCallbackHandlerMock(aggregator.Object, envRepo.Object, showDependencyProvider.Object); aggregator.Setup(e => e.Publish(It.IsAny<UpdateResourceMessage>())) .Callback<Object>(m => { var msg = (UpdateResourceMessage)m; Assert.AreEqual(resourceId, msg.ResourceModel.ID); }) .Verifiable(); var jsonObj = JObject.Parse("{ 'ResourceID': '" + resourceId + "','ResourceType':'Service'}"); handler.TestSave(envModel.Object, jsonObj); aggregator.Verify(e => e.Publish(It.IsAny<UpdateResourceMessage>()), Times.Once()); }