public void GetAuthorizationContextForService_ShouldReturnContext() { //------------Setup for test-------------------------- var service = new DeleteScheduledResource(); //------------Execute Test--------------------------- var resId = service.GetAuthorizationContextForService(); //------------Assert Results------------------------- Assert.AreEqual(AuthorizationContext.Administrator, resId); }
public void GetResourceID_ShouldReturnEmptyGuid() { //------------Setup for test-------------------------- var service = new DeleteScheduledResource(); //------------Execute Test--------------------------- var resId = service.GetResourceID(new Dictionary <string, StringBuilder>()); //------------Assert Results------------------------- Assert.AreEqual(Guid.Empty, resId); }
ExecuteMessage RunOutput(bool expectCorrectInput) { var esbMethod = new DeleteScheduledResource(); var factory = new Mock <IServerSchedulerFactory>(); var model = new Mock <IScheduledResourceModel>(); var ws = new Mock <IWorkspace>(); var trigger = new ScheduleTrigger(TaskState.Disabled, new Dev2DailyTrigger(new TaskServiceConvertorFactory(), new DailyTrigger(21)), new Dev2TaskService(new TaskServiceConvertorFactory()), new TaskServiceConvertorFactory()); var res = new ScheduledResource("a", SchedulerStatus.Enabled, DateTime.Now, trigger, "dave", Guid.NewGuid().ToString()); var security = new Mock <ISecurityWrapper>(); esbMethod.SecurityWrapper = security.Object; var inp = new Dictionary <string, StringBuilder>(); factory.Setup( a => a.CreateModel(GlobalConstants.SchedulerFolderId, It.IsAny <ISecurityWrapper>())).Returns(model.Object); var serialiser = new Dev2JsonSerializer(); if (expectCorrectInput) { model.Setup(a => a.DeleteSchedule(It.IsAny <ScheduledResource>())).Verifiable(); inp.Add("Resource", serialiser.SerializeToBuilder(res)); } esbMethod.SchedulerFactory = factory.Object; var output = esbMethod.Execute(inp, ws.Object); if (expectCorrectInput) { model.Verify(a => a.DeleteSchedule(It.IsAny <ScheduledResource>())); } return(serialiser.Deserialize <ExecuteMessage>(output)); }