public void TestInit() { handlerResults = null; permissableService = new Mock <IPermissableService>(); context = new PermissableSaveActionContext(); handler = (x) => { handlerResults = x; }; saveAction = new PermissableSaveAction(permissableService.Object, handler); }
public void TestConstructor_NullHandler() { var testInstance = new PermissableSaveAction(permissableService.Object, null); var serviceField = typeof(PermissableSaveAction).GetField("service", BindingFlags.Instance | BindingFlags.NonPublic); Assert.IsNotNull(serviceField); var serviceValue = serviceField.GetValue(testInstance); Assert.IsNotNull(serviceValue); var delegateField = typeof(PermissableSaveAction).GetField("addedPermissableEntityResultsDelegate", BindingFlags.Instance | BindingFlags.NonPublic); Assert.IsNotNull(delegateField); var delegateValue = delegateField.GetValue(testInstance); Assert.IsNotNull(delegateValue); }
public void TestConstructor() { Action <List <AddedPermissableEntityResult> > handler = (x) => { }; var testInstance = new PermissableSaveAction(permissableService.Object, handler); var serviceField = typeof(PermissableSaveAction).GetField("service", BindingFlags.Instance | BindingFlags.NonPublic); Assert.IsNotNull(serviceField); var serviceValue = serviceField.GetValue(testInstance); Assert.IsNotNull(serviceValue); var delegateField = typeof(PermissableSaveAction).GetField("addedPermissableEntityResultsDelegate", BindingFlags.Instance | BindingFlags.NonPublic); Assert.IsNotNull(delegateField); var delegateValue = delegateField.GetValue(testInstance); Assert.IsNotNull(delegateValue); Assert.IsTrue(Object.ReferenceEquals(handler, delegateValue)); }