public void TestFluentCreation() { var settings = InjectionSettings .WithInjectionMode(InjectionMode.Scoped) .WithRootNamespace("Someroot") .LimitImplementationsToInterfaceNamespace() .WithInterfacePrefix("I") .WithInterfaceSuffixes(new List <string> { "Repository", "Service" }) .WithStrictNaming(); Assert.True(settings.InterfaceRootNamespaces.Count > 0); var settings2 = InjectionSettings .WithInjectionMode(InjectionMode.Scoped) .WithRootNamespaces("Someroot", "someOtherRoot") .LimitImplementationsToInterfaceNamespace() .WithInterfacePrefix("I") .WithInterfaceSuffixes(new List <string> { "Repository", "Service" }) .WithStrictNaming(); Assert.True(settings2.InterfaceRootNamespaces.Count > 1); }
public void WhenObjectsAreSpecified_AsExplicitImplementationNamespaceProviders_ThenTheNamespaceIsAddedToTheImplementationNamespaceListExpectedNumberOfTimes(List <string> rootNamespaces, int expectedCount, IEnumerable <Type> types) { var settings = InjectionSettings .WithInjectionMode(InjectionMode.Scoped) .WithRootNamespacesOf(typeof(TestObjects.TestObject1)) .AllowImplementationsInNamespacesOf(types) .WithInterfacePrefix("I") .WithInterfaceSuffixes(new List <string> { "Repository", "Service" }) .WithStrictNaming(); Assert.Equal(expectedCount, settings.AllowedImplementationNamespaces.Count); Assert.True(settings.AllowedImplementationNamespaces.All(rootNamespaces.Contains)); }
public void WhenObjectIsSpecified_AsImplementationNamespaceProvider_ThenTheNamespaceIsAddedToTheList() { var settings = InjectionSettings .WithInjectionMode(InjectionMode.Scoped) .WithRootNamespaceOf(typeof(TestObjects.TestObject1)) .AllowImplementationsInAssemblyOf(typeof(TestObjects.Level2_2.TestObject2_2)) .WithInterfacePrefix("I") .WithInterfaceSuffixes(new List <string> { "Repository", "Service" }) .WithStrictNaming(); Assert.True(settings.InterfaceRootNamespaces.Count == 1); Assert.Equal(TestObjectRootNamespace, settings.AllowedImplementationNamespaces?.First()); }
public IHttpActionResult Put(string exePath, [FromBody] InjectionSettings options) { try { if (!HookService.TryCreateAndInject(exePath, options.RedirectionPort, options.RedirectedIps.ToArray())) { return(BadRequest($"Couldn't find exe at {exePath} !")); } return(Ok()); } catch (ArgumentException e) { return(BadRequest($"Invalid {e.ParamName} provided !")); } catch (Exception e) { return(new ExceptionResult(e, this)); } }
public IHttpActionResult Put(int pId, [FromBody] InjectionSettings options) { try { if (!HookService.TryInject(pId, options.RedirectionPort, options.RedirectedIps.ToArray())) { return(BadRequest("Process has already been injected")); } return(Ok()); } catch (ArgumentException e) { return(BadRequest($"Invalid {e.ParamName} provided !")); } catch (Exception e) { return(new ExceptionResult(e, this)); } }