public void ValidateRemove() { DependentModel delegateModel = new DependentModel() { OwnerId = mockHdId, DelegateId = mockParentHdId }; Mock <IUserDelegateDelegate> mockDependentDelegate = new Mock <IUserDelegateDelegate>(); mockDependentDelegate.Setup(s => s.Delete(It.Is <UserDelegate>(d => d.OwnerId == mockHdId && d.DelegateId == mockParentHdId), true)).Returns(new DBResult <UserDelegate>() { Status = DBStatusCode.Deleted, }); Mock <IUserProfileDelegate> mockUserProfileDelegate = new Mock <IUserProfileDelegate>(); mockUserProfileDelegate.Setup(s => s.GetUserProfile(mockParentHdId)).Returns(new DBResult <UserProfile>() { Payload = new UserProfile() }); Mock <INotificationSettingsService> mockNotificationSettingsService = new Mock <INotificationSettingsService>(); mockNotificationSettingsService.Setup(s => s.QueueNotificationSettings(It.IsAny <NotificationSettingsRequest>())); IDependentService service = new DependentService( new Mock <ILogger <DependentService> >().Object, mockUserProfileDelegate.Object, new Mock <IPatientService>().Object, mockNotificationSettingsService.Object, mockDependentDelegate.Object ); RequestResult <DependentModel> actualResult = service.Remove(delegateModel); Assert.Equal(Common.Constants.ResultType.Success, actualResult.ResultStatus); }
public void ItShouldInjectTheFactoredServices() { // Act DependentService actual = GetService <DependentService>(); // Assert actual.Should().NotBeNull(); actual.Service1.Should().NotBeNull(); actual.Service2.Should().NotBeNull(); actual.Service3.Should().NotBeNull(); }
public void ItShouldInjectTheFactoredServices() { // Arrange string expectedExtraData = Guid.NewGuid().ToString(); // Act DependentService actual = Context.GetService <DependentService>(expectedExtraData); // Assert actual.Should().NotBeNull(); actual.Service1.Should().NotBeNull(); actual.Service2.Should().NotBeNull(); }
private void ButtonStop_Click(object sender, System.EventArgs e) { //check to see if the service can be stopped. if (WSController.CanStop == true) { //get an array of dependent services, loop through the array and //prompt the user to stop all dependent services. ServiceController[] DependentServices = WSController.DependentServices; //if the length of the array is greater than or equal to 1. if (DependentServices.Length >= 1) { foreach (ServiceController DependentService in DependentServices) { //make sure the dependent service is not already stopped. if (DependentService.Status.ToString() != "Stopped") { if (MessageBox.Show("Would you like to also stop this dependent service?\n" + DependentService.DisplayName, "Dependent Service", MessageBoxButtons.YesNo).ToString() == "Yes") { // not checking at this point whether the dependent service can be stopped. // developer may want to include this check to avoid exception. DependentService.Stop(); DependentService.WaitForStatus(ServiceControllerStatus.Stopped); } else { return; } } } } //check the status of the service if (WSController.Status.ToString() == "Running" || WSController.Status.ToString() == "Paused") { WSController.Stop(); } WSController.WaitForStatus(System.ServiceProcess.ServiceControllerStatus.Stopped); SetButtonStatus(); } }
public void DynamicTypeBuilder_StringParam(DynamicTypeBuilder builder, IExportLocatorScope scope, IDisposalScope disposalScope, InjectionContext context) { var proxyType = builder.CreateType(typeof(IComplexProvider <string>), out List <DynamicTypeBuilder.DelegateInfo> methods); string value = "hello world"; DependentService <string> service = null; var func = new ActivationStrategyDelegate((s, d, c) => { Assert.True(c.Keys.Any(key => key.ToString().StartsWith(UniqueStringId.Prefix) && Equals(c.GetExtraData(key), value))); return(service = new DependentService <string>(value)); }); var instance = (IComplexProvider <string>)Activator.CreateInstance(proxyType, scope, disposalScope, context, func); var instanceService = instance.CreateValue(value); Assert.NotNull(instanceService); Assert.Same(service, instanceService); }