internal static void InjectStubs_AreStubs() { Injected <FakeHolderSample> sample = Tools.Faker.InjectStubs <FakeHolderSample>(); Tools.Asserter.Is(0, sample.Dummy.Sample1.Calc()); Tools.Asserter.Is(null, sample.Dummy.Sample2.Text); }
internal static void Inject_HandlesValues() { Injected <FakeHolderSample> sample = Tools.Faker.InjectMocks <FakeHolderSample>(); Tools.Asserter.Is(0, sample.Dummy.Value1); Tools.Asserter.Is(null, sample.Dummy.Value2); }
internal static void InjectMocks_AreMocks() { Injected <FakeHolderSample> sample = Tools.Faker.InjectMocks <FakeHolderSample>(); Tools.Asserter.Throws <FakeCallException>(() => sample.Dummy.Sample1.Calc()); Tools.Asserter.Throws <FakeCallException>(() => sample.Dummy.Sample2.Text); }
public TwitterSearchJob() { IsStoppable = true; var objectSerializerFactory = new Injected <IObjectSerializerFactory>(); _objectSerializer = objectSerializerFactory.Service.GetSerializer(KnownContentTypes.Json); }
internal static void Inject_UsesValues(int num, string text) { Injected <FakeHolderSample> sample = Tools.Faker.InjectMocks <FakeHolderSample>( null, Tools.Faker.Stub <AbstractFakeSample>(), num, text); Tools.Asserter.Is(null, sample.Dummy.Sample1.Text); Tools.Asserter.Throws <FakeCallException>(() => sample.Dummy.Sample2.Calc()); Tools.Asserter.Is(num, sample.Dummy.Value1); Tools.Asserter.Is(text, sample.Dummy.Value2); }
// Register your systems and services to the controller. This can only be // done during 'OnInitialize' cycle. public void Register(params System.Type[] typesOf) { if (this.isInitialized == true) { throw new System.Exception("Cannot to registered System outsize of OnInitialize cycle"); } for (var _typeOfIndex = 0; _typeOfIndex < typesOf.Length; _typeOfIndex++) { var _instance = System.Activator.CreateInstance(typesOf[_typeOfIndex]); // When the instance is a type of the system, add it to the systems if (_instance is IEntitySystem) { var _system = _instance as IEntitySystem; this.systems.Add(_system); this.enabledSystemsCache.Add(_system); _system.OnInitialize(); _system.Internal_OnInitialize(); } // When the instance is a type of the system, add it to the services if (_instance is IService) { var _service = _instance as IService; this.services.Add(_service); _service.OnInitialize(); _service.Internal_OnInitialize(); } } // Set Values of the 'Injected' attributes Injected.SetAttributeValues(this); for (var _systemIndex = 0; _systemIndex < this.systems.Count; _systemIndex++) { Injected.SetAttributeValues(this.systems[_systemIndex]); } for (var _serviceIndex = 0; _serviceIndex < this.services.Count; _serviceIndex++) { Injected.SetAttributeValues(this.services[_serviceIndex]); } // Set Values of the 'Asset' attributes Asset.SetAttributeValues(this); for (var _systemIndex = 0; _systemIndex < this.systems.Count; _systemIndex++) { Asset.SetAttributeValues(this.systems[_systemIndex]); } for (var _serviceIndex = 0; _serviceIndex < this.services.Count; _serviceIndex++) { Asset.SetAttributeValues(this.services[_serviceIndex]); } }
protected void Start() { _injector = new Injector(); _injector.Bind <InjectableA>(new InjectableA()); _injector.Bind <InjectableB>(new InjectableB()); var injected = new Injected(); _injector.Inject(injected); injected.PrintMessages(); }
public void Setup() { _monitor = new Monitor(); _injected = new Injected(); var collection = new ServiceCollection(); //this registration is key, this is where the actions are associated with a middleware implementation. collection.AddSingleton(typeof(BusMiddleWare<>), typeof(BusMiddleWare<>)); //register the Actions. collection.AddTransient(typeof(ConsumerAction<>)); collection.AddSingleton(typeof(TestAction1<>)); collection.AddTransient(typeof(TestGenericAction<>)); //the framework we want to add middleware support with. collection.AddSingleton<FakeBus>(); collection.AddSingleton(_monitor); collection.AddSingleton(_injected); //find all the IConsumer<T> interfaces var consumers = this.GetType().Assembly.ExportedTypes.SelectMany(x => { var interfaces = x.GetInterfaces() .Where(interfaceType => interfaceType.IsGenericType) .Where(interfaceType => typeof(IConsumer<>).IsAssignableFrom(interfaceType.GetGenericTypeDefinition())) .Select(interfaceType => new { Type = x, Interface = interfaceType, ConsumedType = interfaceType.GenericTypeArguments[0] }); return interfaces; }); foreach (var consumer in consumers) { //Register IConsumer<T> collection.AddTransient(consumer.Interface, consumer.Type); } _baseScope = collection.BuildServiceProvider(); _bus = _baseScope.GetService<FakeBus>(); _bus.Subscribe<OrderPlaced>("OrderPlaced", _baseScope); _bus.Subscribe<OrderPaymentTaken>("OrderPaymentTaken", _baseScope); }
public static List <Submission> GetComment() { Injected <IFormRepository> _formRepository = new Injected <IFormRepository>(); List <Submission> submittedData = new List <Submission>(); FormDataRepository _formDataRepository = new FormDataRepository(); FormContainerBlock _formContainerBlock = new FormContainerBlock(); List <Submission> submittedDataBlock = new List <Submission>(); var formsInfo = _formRepository.Service.GetFormsInfo(null); foreach (var info in formsInfo) { submittedData = _formDataRepository.GetSubmissionData( new FormIdentity(info.FormGuid, "en"), DateTime.Now.AddDays(-100), DateTime.Now).ToList(); } return(submittedData); }
public override int GetHashCode() { unchecked { return(Declared.GetHashCode() + (Injected.GetHashCode() * 17)); } }
public OrderPaymentTakenConsumer(Monitor monitor, Injected injected) { _monitor = monitor; _injected = injected; }
internal static void Injected_NoParameterMutation(Injected <InjectSample> sample) { Tools.Tester.PreventsParameterMutation(sample, sample.Fakes); }
internal static void CreateFor_InjectedNotManuallyInjected(Fake <IOnlyMockSample> inner1, Fake <IOnlyMockSample> inner2, InjectMockSample sample, Injected <InjectMockSample> injected) { Tools.Asserter.IsNot(sample, injected.Dummy); Tools.Asserter.Is(false, injected.Fakes.Contains(inner1)); Tools.Asserter.Is(false, injected.Fakes.Contains(inner2)); injected.Dummy.TestIfMockedSeparately(); }
public GetsLocator(Injected injected) { Injected = injected; Found = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <FoundByLocator>(); }
public void SetDatabaseMode(IDatabaseMode dbMode) { DBMode = new Injected <IDatabaseMode>(dbMode); }
internal static void CreateFor_InjectedWorks(Injected <InjectMockSample> injected) { injected.Dummy.TestIfMockedSeparately(); }
static UriUtil() { UrlResolver = default; ContentLoader = default; }
internal static void Injected_GuardsNulls(Injected <InjectSample> sample) { Tools.Tester.PreventsNullRefException(sample, sample.Fakes); }
internal static void Issue018_RandomizerInjects(Injected <Sample> sample) { sample.Dummy.InternalSample.Assert().Is(sample.Fake <IInternalSample>().Dummy); }
internal static void Fake_CanFindByDummy(Injected <FakeHolderSample> sample) { Tools.Asserter.Is(sample.Fake <IFakeSample>(), sample.Fake(sample.Dummy.Sample1)); Tools.Asserter.Is(sample.Fake <AbstractFakeSample>(), sample.Fake(sample.Dummy.Sample2)); }
public void SetDatabaseMode(IDatabaseMode dbMode) { DBMode = new Injected<IDatabaseMode>(dbMode); }
public OrderPlacedConsumer(Monitor monitor, Injected injected) { _monitor = monitor; _injected = injected; }
public TestGenericAction(Monitor monitor, Injected injected) { _monitor = monitor; _injected = injected; _monitor.AddCtorTick(this); }